1👍
The way you populate oacData doesn’t sound right. I would expect this:
var oacData = [];
$.each(ChartData, function(i, item) {
oacData.push(
{
value: ChartData[i].totalTonne,
color: "#F7464A",
highlight: "#FF5A5E",
label: ChartData[i].wasteType
}
);
});
- Chartjs-Ng2-charts set color for one specific value in dataset
- Chartjs-Changing Fonts In Javascript's CanvasJS
0👍
Now oacData is objects within an array within an array.
That’s why Chart.js can’t parse your data.
Just omit the brackets like:
var oacData = $.each(ChartData, function(i, item) {
{
value: ChartData[i].totalTonne;
color: "#F7464A";
highlight: "#FF5A5E";
label: ChartData[i].wasteType;
}
});
And you will have an array with objects.
- Chartjs-Array data not rendering in data table using this.props – ReactJS
- Chartjs-How to show only each 15th x-labels in line chart chart.js in angular 6?
Source:stackexchange.com