HELLO EVERYONE, THIS IS ME NAFE ISLAM. How are you doing? In below, it’s a coding of time vs movement category. In here, when you run the code it takes time initially to show up due to rendering. I want to make a change in a way that the first appearance of the graph come faster then it will render. How to do that? I really wanna know this. Anyone kind hearted person help me out that would be wonderful!
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function (){
var dps1 = [], dps2 = [], dps3 = [];
var chart = new CanvasJS.Chart("chartContainer",{
title:{
text: "TIME vs. Movement category"
},
axisX:{
title: "TIME SLOT"
},
axisY:{
title: "% of Movement Category"
},
data: [
{
type: "stackedArea100",
name: "Standstill/Tilting",
showInLegend: "true",
yValueFormatString: "#,##0.##\"%\"",
dataPoints: dps1
},
{
type: "stackedArea100",
name: "On Foot",
showInLegend: "true",
yValueFormatString: "#,##0.##\"%\"",
dataPoints: dps2
},
{
type: "stackedArea100",
name: "On Vehicle",
showInLegend: "true",
yValueFormatString: "#,##0.##\"%\"",
dataPoints: dps3
}
]
});
getData();
chart.render();
function getData(chart) {
$.when($.getJSON("https://api.myjson.com/bins/tw3zs", function(data) {
for(var i = 0; i < data.length; i++) {
dps1.push({
label: data[i].label,
y: data[i].y1
});
dps2.push({
label: data[i].label,
y: data[i].y2
});
dps3.push({
label: data[i].label,
y: data[i].y3
});
}
})).done(function(){
chart.render();
});
}
setInterval(function(){
getData();
chart.render();
}, 100000);
};
</script>
</head>
<body>
<div id="chartContainer" style="height: 600px; width: 100%;"></div>
<script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
<script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
</body>
</html>
THANK YOU!!