Home Forums Chart Support chart from csv multiple lines

chart from csv multiple lines

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

    Dear all

    is it possible to plot a cahrt from a .CSV with multiple lines like this example.

    Thank you and best regards

    Nicola

    FILE CHART EXAMPLE https___www_borsavalori_ch_VECCHIO_assets_examples_exampleCSV_png
    FILE CSV WITH DATA https___www_borsavalori_ch_VECCHIO_assets_examples_provaCSV_csv

    I have to use _ because with slash I is not possible to send to you

    #32960

    @nicolapresa,

    Yes, it’s possible to create a multi-series chart with data from a CSV file. You can get the CSV data using AJAX call and parse the same to the format accepted by CanvasJS.

    Here is the code snippet for the same,

      for(var j = 0; j < noOfSeries; j++)
        chart.options.data.push({ type: "line", showInLegend: true, dataPoints: [] });
    
      for (var i = 1; i < csvLines.length; i++) {
        if (csvLines[i].length > 0) {
          points = csvLines[i].split(";");
          dateTime = points[0].split(".");
          dateTime = dateTime[2] - 1 + "-" + dateTime[1] + "-" + dateTime [0];
    
          for(var j = 1; j < points.length; j++) {
            chart.options.data[j-1].dataPoints.push({x: new Date(dateTime), y: points[j] === "" ? null : Number(points[j])});
          }
        }
      }

    Kindly take a look at this JSFiddle for an example on creating multi-series chart with the data from CSV.

    multi series chart with data from csv

    Considering this thread as duplicate of chart from csv multiple lines. Hence closing the same.


    Adithya Menon
    Team CanvasJS

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

You must be logged in to reply to this topic.