angular-highcharts
angular-highcharts copied to clipboard
Type '{ type: string; name: string; data: any; }[]' not assignable to type
Im getting this error and the descriptions on how to fix it make no sense.
I tried
as Highcharts.SeriesColumnOptions and as Highcharts.SeriesLineDataOptions
and this is my code:
new Chart({ title: { text: 'Pareto' }, xAxis: { categories: ['a', 'b', 'c'], crosshair: true }, yAxis: [{ title: { text: 'r' } }], series: [{ //line 272 type: 'column', name: 'p1', data: [1,2,3] }, { type: 'line', name: 'p2', data: [3,2,1] }] })
ERROR in mycomp.component.ts(272,9): error TS2322: Type '{ type: string; name: string; data: any; }[]' is not assignable to type '(SeriesAbandsOptions | SeriesAdOptions | SeriesAoOptions | SeriesApoOptions | SeriesAreaOptions | SeriesArearangeOptions | SeriesAreasplineOptions | SeriesAreasplinerangeOptions | ... 82 more ... | SeriesZigzagOptions)[]'.
Type '{ type: string; name: string; data: any; }' is not assignable to type 'SeriesAbandsOptions | SeriesAdOptions | SeriesAoOptions | SeriesApoOptions | SeriesAreaOptions | SeriesArearangeOptions | SeriesAreasplineOptions | SeriesAreasplinerangeOptions | ... 82 more ... | SeriesZigzagOptions'.
Type '{ type: string; name: string; data: any; }' is not assignable to type 'SeriesZigzagOptions'.
Types of property 'type' are incompatible.
Type 'string' is not assignable to type '"zigzag"'.
mycomp.component.ts(288,9): error TS2322: Type '{ type: string; name: string; data: any; }[]' is not assignable to type '(SeriesAbandsOptions | SeriesAdOptions | SeriesAoOptions | SeriesApoOptions | SeriesAreaOptions | SeriesArearangeOptions | SeriesAreasplineOptions | SeriesAreasplinerangeOptions | ... 82 more ... | SeriesZigzagOptions)[]'.
mycomp.component.ts(39,9): error TS2322: Type 'string' is not assignable to type '"area" | "map" | "line" | "polygon" | "areaspline" | "bar" | "column" | "pie" | "scatter" | "spline" | "abands" | "ad" | "ao" | "apo" | "arearange" | "areasplinerange" | "aroon" | ... 73 more ... | "zigzag"'.
mysecondcomp.component.ts(60,9): error TS2322: Type 'string' is not assignable to type '"area" | "map" | "line" | "polygon" | "areaspline" | "bar" | "column" | "pie" | "scatter" | "spline" | "abands" | "ad" | "ao" | "apo" | "arearange" | "areasplinerange" | "aroon" | ... 73 more ... | "zigzag"'.
im using angular 7.1.3
series: [ { name: "Countries", color: "#E0E0E0", enableMouseTracking: false, type: undefined, },
fixed my problem
series: [ { name: "Countries", color: "#E0E0E0", enableMouseTracking: false, type: undefined, },
fixed my problem
it works for me
but before there is no need to declare type in seris so now why we need to do it?
The above solutions fix the problem, but can somebody please tell how to send the initial data
series: [ { name: "Countries", color: "#E0E0E0", enableMouseTracking: false, type: undefined, },
fixed my problem
tks!
series: [ { name: "Countries", color: "#E0E0E0", enableMouseTracking: false, type: undefined, },
fixed my problem
I am using Angular 8 to render a heatmap, and got an error when setting the series type to 'heatmap' in the app.component.ts file. At this point my chart type was already set to 'heatmap', and in the series, setting the type to undefined fixed by problem. My series looks like this:
series: [
{
type: undefined,
name: 'Curriculum Mapping',
turboThreshold: 30000,
data: this.getData(),
boostThreshold: 30000,
borderWidth: 0,
nullColor: '#EFEFEF',
tooltip: {
// headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
pointFormat: '<b>{point.custom.event} {point.custom.outcome} {point.value}</b>'
}
}
]
I was struggling with the same problem. Thank you for this post stating that the type needs to be defined in the series.
In my case, I had to provide the exact type (potentially, because I accepted enforce stricter type checking
when creating my project).