How to replace my javascript datapoints to my mysql database? My array x and y ??? i have trouble in plotting my mysql database...
ex.
array("x" =>(HERE), "y" =>HERE),
by database $row['year'];
<?php
$dataPoints = array(
array("x" => 946665000000, "y" => 40),
array("x" => 978287400000, "y" => 20),
array("x" => 1009823400000, "y" => 100),
array("x" => 1041359400000, "y" => 300),
array("x" => 1072895400000, "y" => 500),
array("x" => 1104517800000, "y" => 500),
array("x" => 1136053800000, "y" => 400),
array("x" => 1167589800000, "y" => 400),
);
?>
<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script>
window.onload = function () {
var chart1 = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title:{
text: "Number of Enrollees by Year"
},
axisY: {
title: "Students in numbers",
valueFormatString: "#",
suffix: "",
prefix: ""
},
data: [{
type: "spline",
markerSize: 5,
xValueFormatString: "YYYY",
yValueFormatString: "##0. Enrolees",
xValueType: "dateTime",
dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
}]
});
chart1.render();
}
</script>
Its just a template from chartjs.com
Please help me guys form database php to javascript...