chartist-js / chartist

Simple responsive charts
https://chartist.dev
MIT License
13.34k stars 2.54k forks source link

Problem with time series chart #1076

Open voizabela opened 6 years ago

voizabela commented 6 years ago

Hi, I'm trying to do time series chart in Angular 4. Basically when I copied example code from chartist.js site without changing anything. I had this error with argument name. ([ts] Argument of type '{ series: { name: string; data: { x: Date; y: number; }[]; }[]; }' is not assignable to parameter of type 'IChartistData'. Types of property 'series' are incompatible. Type '{ name: string; data: { x: Date; y: number; }[]; }[]' is not assignable to type 'IChartistSeriesData[] | number[] | number[][]'.)

I had 0.11.0 version Chartist.

var chart = new Chartist.Line('.ct-chart', { series: [ { name: 'series-1',/// here is error data: [ {x: new Date(143134652600), y: 53}, {x: new Date(143234652600), y: 40}, {x: new Date(143340052600), y: 45}, {x: new Date(143366652600), y: 40}, {x: new Date(143410652600), y: 20}, {x: new Date(143508652600), y: 32}, {x: new Date(143569652600), y: 18}, {x: new Date(143579652600), y: 11} ] }, { name: 'series-2', data: [ {x: new Date(143134652600), y: 53}, {x: new Date(143234652600), y: 35}, {x: new Date(143334652600), y: 30}, {x: new Date(143384652600), y: 30}, {x: new Date(143568652600), y: 10} ] } ] I don't know what is wrong. Please help

nophub commented 6 years ago

I have the exact same issue with my code. Also using angular4, working in Visual Studio Code.

tobo77 commented 5 years ago

I bumped into the same issue. Any solutions? Using Angular 7

pierre-fromager commented 5 years ago

Fixing the definition as below does the trick ?

interface IChartistSeriesData { name?: string; value?: number; data?: Array<number> | Array<{x:number,y:number}> | Array<{x:Date,y:number}>; className?: string; meta?: any; }

pierre-fromager commented 5 years ago

https://github.com/DefinitelyTyped/DefinitelyTyped/pull/35490

tobo77 commented 5 years ago

Hi! Thanks for coming back to me. Meanwhile i switched to chart.js for my current project. Next project i considere chartist again!

Mittwoch, 15. Mai 2019, 17:25 +0200 von notifications@github.com notifications@github.com:

Fixing the definition as below does the trick ? interface IChartistSeriesData { name?: string; value?: number; data?: Array | Array<{x:number,y:number}> | Array<{x:Date,y:number}>; className?: string; meta?: any; } ā€” You are receiving this because you commented. Reply to this email directly, view it on GitHub , or mute the thread .

Arantiryo commented 1 year ago

Hello @voizabela šŸ‘‹

Chartist has recently been updated to version 1.0 with some new exciting changes like ESM and TypeScript support. The migration guide can be found right here.

Please let me know if the question is still relevant to you so we can further look into it!