@dimas19801,
Please refer Tutorial on Creating Charts from JSON Data & AJAX.
The JSON data needs to parsed before passing it to chart-options. Check out the below code snippet for the same.
$.getJSON("https://api.npoint.io/6be170cb804361d314e3", function(chartData) {
for(var i = 0; i < chartData.length; i++){
dps.push({ x: new Date(chartData[i].x), y: chartData[i].y});
}
chart = new CanvasJS.Chart("wtChart", {
title: {
text: "Chart from External JSON Data"
},
data: [
{
type: "column",
dataPoints: dps
}
]
});
chart.render();
});
Please check this JSFiddle for complete code.
—
Vishwas R
Team CanvasJS