0👍
✅
Try this and you will get result:
window.onload = function () {
var data = [
{
"season": "Thanksgiving",
"ordercount": "15000"
},
{
"season": "Christmas",
"ordercount": "300000"
},
{
"season": "Newyear",
"ordercount": "100000"
}
]
var seasondata = []
for (let index = 0; index < data.length; index++) {
const element = data[index];
seasondata.push({label: data[index]["season"], y:Number(data[index]["ordercount"])})
}
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "My First Chart in CanvasJS"
},
data: [
{
// Change type to "doughnut", "line", "splineArea", etc.
type: "bar",
dataPoints: seasondata
}
]
});
chart.render();
}
Put your json data into variable and then create and array and then place that into datapoints Your order count is string so convert that into number and it will work.
You can also check the result here in this link:
Source:stackexchange.com