$(document).ready(function() {
var dataPoints = [];
var chart = new CanvasJS.Chart(“chartContainer”, {
	animationEnabled: true,
	exportEnabled: true,
	theme: “light2”,
	zoomEnabled: true,
	title: {
		text: “Attendance”
	},
	axisX: {
		title: “Date”,
		titleFontSize: 10
	},
	axisY: {
		title: “Number of Present”,
		titleFontSize: 10,
	},
	data: [{
		type: “column”,
		dataPoints: dataPoints
	}]
});
function addData(data) {
	var dps = data.attendance;
	for (var i = 0; i < dps.length; i++) {
		dataPoints.push({
			x: new Date(dps[i][0]),
			y: parseInt(dps[i][1])
		});
	}
	chart.render();
}
$.getJSON(“http://localhost/fyp/results.json”, addData);
}
This would be my json file after running (results.json):
{“attendance”:[[1520809200000,”1″]]}
so, whenever i want to render the chart, i need to run “results.json” at the browse, then the chart will run according to the details in my mysql.
but i dont want to extra loading the “Results.json” file. i want it to render and get the data from mysql automatically. i dont know where do i wrong