Bonjour,

Je cherche a intégrer ce code :

"*if (dps.length > 10 )
{
dps.shift();
}
"

a mon code graphique ci dessous afin que les points de données ne continuent pas à s'accumuler, et pour supprimer les anciennes valeurs du début du tableau.

j'ai essayé de modifier dps et mettre différents nom et le placer a différents endroits dans mon code mais celà ne fonctionne pas.

Merci d'avance pour votre aide.

""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);
}"

Aucune réponse