Home Forums Chart Support Xport Multiple Series Graph as CSV

Xport Multiple Series Graph as CSV

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

    I am using this https://jsfiddle.net/canvasjs/317xw25f/ as a reference however it is only designed for single series graph and I do not understand most of the codes.
    Would anyone be able to modify a new fiddle based on the above for a multi series graph CSV export function?

    This is what my graph looks like graph

    Thank you

    #35176

    @sptrainee31,

    It is possible to convert chart data into comma-separated CSV and download it with a few lines of code. Please find the code snippet for the same below,

    function convertChartDataToCSV(args) {
      var result = '',
          ctr, keys, columnDelimiter, lineDelimiter, data;
    
      data = args.data || null;
      if (data == null || !data.length) {
        return null;
      }
    
      columnDelimiter = args.columnDelimiter || ',';
      lineDelimiter = args.lineDelimiter || '\n';
    
      var mergedData = mergeData(data);
    
      keys = Object.keys(mergedData[0]);
      result = '';
      result += keys.join(columnDelimiter);
      result += lineDelimiter;
    
      mergedData.forEach(function (item) {
        ctr = 0;
        keys.forEach(function (key) {
          if (ctr > 0) result += columnDelimiter;
          result += (typeof (item[key]) != undefined ? item[key] : "");
          ctr++;
        });
        result += lineDelimiter;
      });
      return result;
    }

    Please take a look at this JSFiddle for working code. Also take a look at this 3rd party plugin, which seems to be working with multi-series chart as well.

    Considering this thread as a duplicate of Question about Multi Series Graph CSV Export and 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.