Home Forums Chart Support How can I use PHP MySQL Dynamic data Reply To: How can I use PHP MySQL Dynamic data

#7015

$.getJSON(“livechart.php?type=drop&&node=”+node, function (result) {
dps=result;
var chart1 = new CanvasJS.Chart(“dynamicdropContainer”,{
title :{
text: “”
},
axisX: {
title: “Time”
},
axisY: {
title: “Packets Drop”,
minimum: 0,
},
data: [{
type: “column”,
indexLabelFontColor: “black”,
color: “red”,
dataPoints : dps

}]
});
chart1.render();
var xVal = result.length + 1;
var yVal = result;
var updateInterval = 1000;
var count=0;
var updateChart = function () {
var group_id=result[result.length-1].grpid+1;
$.getJSON(“newdata.php?type=drop&&node=”+node+”&&grpid=”+group_id, function (e){
if(e[0].label.length!=0){
result.push({label: e[0].label,grpid:e[0].grpid,y: e[0].y});
}

});

if(result.length-count>=250){
result.shift();
}
chart1.render();

};
setInterval(function(){updateChart()}, updateInterval);
});

here first iam getting 300 records and next from newdata.php in update function am getting one by one record which i push the record to result and render the chart .. when i did n’t use shift or aplice am getting the chart with all the records but when iam using shift or splice then my chart structs on right hand side.

could you please check is there any mistake in my code