I’m building an application in PHP which shows every 10 seconds a new chart from a CSV file. Every ten seconds a new set of datapoints is injected in this CSV file and with CanvasJS I generate the chart of this file on my page.
I tried with an example on this forum to achieve this but it didn’t work out:
var updateChart = function ()
$.get("/scores.panterra.nl/files/scores.csv", getDataPointsFromCSV);
function getDataPointsFromCSV(csv) {
var points;
var csvLines = csv.split(/[\r?\n|\r|\n]+/);
for (var i = 0; i < csvLines.length; i++) {
if (csvLines[i].length > 0) {
points = csvLines[i].split(",");
dataPoints.push({
label: points[0],
y: parseFloat(points[1])
});
dataPoints2.push({
label: points[2],
y: parseFloat(points[3])
});
}
}
chart.render();
}
};
setInterval(function () {
updateChart()
}, 1000);
Without the updateCart and setInterval() it works for only one chart.
I hope you can provide me with some help.