when I do it in static, it doesn’t cause any kind of trouble!
This is what happened after running your code! I want to get rid of this problem very soon please.
Dear Vishwas R,
I have seen all these documentation but couldn’t apply this shift() method properly for expected results. Could you please place the shift() method in this coding to get the expected results please? PLEASE PLEASE & PLEASE. It’s a request.
Dear vishwas R, could you please change the necessary edition of the coding for me ? It will be highly appreciated.
How do I apply this shift() method when there are Multi dps …. Please send the full html file! that would be wonderful. Thank you
actually when I run this code, after a while you can see the graph gets squeezed so no can understand what is going on? How can I solve this problem and the json data will be provided from the server. Please help me out here.
Also how can I create jsfiddle and share it live so it will be helpful for you.
THank you
Could you please change the code wherever it’s required to run the json data to produce graph? It would be wonderful if you could send me the full html file.
Thank you
I solved the problem. Problem was in mismatched brackets!
THANK YOU
Thanks vishmas R for trying to help but I am afraid it’s not working still after adding
<script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
Any other way I can try?
if (dps.length > 10 )
{
dps.shift();
}
One more question, Where do I need to put these above code in the coding?? For your convenience I am posting this code for you. Also, Make the whole coding in one single HTML file please.
CODING
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function () {
var dps1 = [], dps2 = [], dps3 = [];
var chart = new CanvasJS.Chart("chartContainer",{
title:{
text: "TIME SLOT vs. MOVEMENT CATEGORY"
},
axisX:{
title: "TIME SLOT"
},
axisY:{
title: "Percentage of movement category"
},
data: [
{
type: "stackedArea100",
name: "STANDSTILL",
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/a98dm", 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>
</body>
</html>
THANK YOU!!
THANK YOU. IT WORKED.
@priyanka M S
Thank you so so much for your help.
HTML:
<div id="chartContainer" style="height: 300px; width: 150%;"></div>
JAVASCRIPT:
var dps1 = [], dps2 = [], dps3 = [];
var chart = new CanvasJS.Chart("chartContainer",{
title:{
text: "Y Values based on Frequency of Date"
},
axisX:{
title: "Date"
},
axisY:{
title: "Frequecy of dates"
},
data: [
{
type: "stackedArea100",
name: "STANDSTILL",
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() {
$.getJSON("https://api.myjson.com/bins/a98dm", 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
});
}
});
}
setInterval(function(){
getData();
chart.render();
}, 5000);
I WANT TO COMBINE THIS 2 codes into a simple HTML File. How can I do that? Please write the whole code in the post after edition please. ALso how can i make it dynamic?
I have one more question! could you please explain how did u create this? https://api.myjson.com/bins/a98dm
Please let me know. It’s really urgent.
HOW CAN I WRITE THIS CODE IN NOTEPAD++ by combining all the html,css and javascript?