Reputation: 11862
I use angular
and chart.js
.
How to add element to data array. I do not understand why the guy is not good.
I want add any data in data
public readingChartData: ChartDataSets[] = [
{
data: [],
fill: false,
borderColor: '#648ed0',
label: 'Chambre froide'
}];
type of data
is Array<number | null | undefined> | ChartPoint[]
type of element.value
is number
const p: ChartPoint = {
x: element.value
};
this.readingChartData[0].data.push(p);
I have this error:
Argument of type 'ChartPoint' is not assignable to parameter of type 'number & ChartPoint'.
Type 'ChartPoint' is not assignable to type 'number'.ts(2345)
Upvotes: 1
Views: 1988
Reputation: 11862
I find a solution:
(this.readingChartData[0].data as number[]).push(element.value);
Upvotes: 3