bambinou,
You have to parse the json before assigning to dataPoints. Here is the code to do the same.
<script type=”text/javascript”>
window.onload = function () {
var jsonData = <?php echo json_encode($rows); ?>;
var dataPoints = [];
for (var i = 0; i <= jsonData.length - 1; i++) {
dataPoints.push({ x: new Date(jsonData[i].y), y: Number(jsonData[i].label) });
}
var chart = new CanvasJS.Chart("chartContainer", {
theme: "theme2",
title:{
text: "Earthquakes – per month"
},
animationEnabled: true,
axisX: {
//valueFormatString: "MMM",
interval:1,
intervalType: "week"
},
axisY:{
includeZero: false
},
data: [
{
type: "line",
lineThickness: 3,
dataPoints: dataPoints
}
]
});
chart.render();
}
</script>