Home Forums Chart Support Auto refresh chart through different CSV

Auto refresh chart through different CSV

Viewing 2 posts - 1 through 2 (of 2 total)
  • #25801

    pan

    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.

    #25822

    @mcdennem,

    Can you kindly share a sample project along with sample CSV file over Google-Drive or Onedrive so that we can run it locally at our end, understand the scenario better and help you out?


    Shashi Ranjan
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.