Hi Sandeep,
Thanks for your email response to my initial request.
My question is:
How can I use the below chart (for example) to plot a real-time data that is continuously fed to a text file ?
Thanks.
Karim
<!DOCTYPE HTML>
<html>
<head>
<meta charset=”UTF-8″>
<script>
window.onload = function () {
var dps = [];
var chart = new CanvasJS.Chart(“chartContainer”, {
exportEnabled: true,
title :{
text: “Dynamic Spline Chart”
},
axisY: {
includeZero: false
},
data: [{
type: “spline”,
markerSize: 0,
dataPoints: dps
}]
});
var xVal = 0;
var yVal = 100;
var updateInterval = 1000;
var dataLength = 50; // number of dataPoints visible at any point
var updateChart = function (count) {
count = count || 1;
// count is number of times loop runs to generate random dataPoints.
for (var j = 0; j < count; j++) {
yVal = yVal + Math.round(5 + Math.random() *(-5-5));
dps.push({
x: xVal,
y: yVal
});
xVal++;
}
if (dps.length > dataLength) {
dps.shift();
}
chart.render();
};
updateChart(dataLength);
setInterval(function(){ updateChart() }, updateInterval);
}
</script>
</head>
<body>
<div id=”chartContainer” style=”height: 370px; max-width: 920px; margin: 0px auto;”></div>
<script src=”../../canvasjs.min.js”></script>
</body>
</html>