Hello,
I am trying to insert this code:
if (dps.length > 10 )
{
dps.shift();
}
a my chart code below so data points don’t keep accumulating, and to remove old values from the beginning of the array.
I tried to modify dps and put different name and place it in different places in my code but it doesn’t work.
Thank you in advance for your help.
"window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",{
title:{
text:"Vent Km/h"
},
axisX: {
title: "Heure"
},
axisY: {
title: "Vent Km/h"
},
data: [{
type: "line",
dataPoints : [],
},
]
});
$.getJSON("service.php", function(data) {
$.each((data), function(key, value){
chart.options.data[0].dataPoints.push({label: value[0], y: parseInt(value[1])});
});
chart.render();
updateChart();
});
function updateChart() {
$.getJSON("service.php", function(data) {
chart.options.data[0].dataPoints = [];
$.each((data), function(key, value){
chart.options.data[0].dataPoints.push({label: value[0], y: parseInt(value[1])});
});
chart.render();
updateChart();
});
}
setInterval(function(){updateChart()}, 2000);
}"