I wanted to make a dropdown list, when a user clicks on the drop down, it will show the charts.
This is my website. http://fkiattendance.xyz/staff_report.php
But the charts doesnt come out. it shows in the json_encode.
staff_report.php
<script type=”text/javascript”>
window.onload = function () {
var chart = new CanvasJS.Chart(“chartContainer”,{
title:{
text:”Attendance”
},
data: [{
type: “column”,
dataPoints : [],
}]
});
$.getJSON(“report.php?type=”+TME2073, function(data) {
$.each((data), function(key, value){
chart.options.data[0].dataPoints.push({label: new Date(value[0]), y: parseInt(value[1])});
});
chart.render();
updateChart();
});
function updateChart() {
$.getJSON(“report.php?type=”+TME2073, function(data) {
chart.options.data[0].dataPoints = [];
chart.options.data[1].dataPoints = [];
$.each((data), function(key, value){
chart.options.data[0].dataPoints.push({label: new Date(value[0]), y: parseInt(value[1])});
});
chart.render();
});
}
setInterval(function(){updateChart()}, 1000);
}
</script>