2👍
✅
You have misplaced code in particular window.onload
inside the json return, depending when function(data) return this display chart, below the improved and fixed code (not tested).
$(function(){
$.getJSON('includes/salesjson.php', function(data){
var lineChartData = {
labels : data[0],
datasets : [
{
label: "My First dataset",
fillColor : "rgba(220,220,220,0.2)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(220,220,220,1)",
data : data[1]
}
]
};
var ctx = document.getElementById("myChart").getContext("2d");
var chart = new Chart(ctx).Line(lineChartData, {
responsive: false
});
});
});
Source:stackexchange.com