hello, i have a problem here. there is something wrong with my chart.
here is the result Result
please help me
window.onload = function()
{
var dataPoints = [];
var dataPoints2 = [];
var chart2;
chart2 = new CanvasJS.Chart(“Temp”,{
animationEnabled: true,
title:{
text:”Temp”
},
exportFileName: “Temp 17 June 2018”,
exportEnabled: true,
axisY:
{
includeZero: false,
title: “Temp (C)”,
suffix: ” C”
},
axisX:
{
includeZero: false,
valueFormatString: “YYYY-MM-DD HH:mm:ss”,
title: “Time”
},
legend:
{
cursor:”pointer”,
fontSize: 22,
fontColor: “dimGrey”,
},
data:
[{
name: “S 1”,
type: “line”,
dataPoints : dataPoints,
},
{
name: “S 2”,
type: “line”,
dataPoints : dataPoints2,
}]
});
function getData() {
$.getJSON(“../menu/g.php”, function(data) {
for(var i = 0; i < data.length; i++){
dataPoints.push({
x: new Date(data[i].Time),
y: data[i].Temp1
});
dataPoints2.push({
x: new Date(data[i].Time),
y: data[i].Temp2
});
}
});
}
setInterval(function(){
getData();
chart2.render();
chart.render();
if (datapoints.length > 5){
datapoints.shift();
datapoints2.shift();
}
}, 1000);
}