export csv from highcharts

孤人 提交于 2019-12-11 21:12:53

问题


I'm using angular-5,angular2-highcharts version 0.5.5 and highcharts version 6.0.7.

I want to add in my html in not in the chart a button for download the chart in png or csv.

Png one works fine, but I can't got it with csv:

This is my code:

downloadPng(): void {   //this one works
   this.chart.exportChart({
      type: 'image/png',
      filename: this.title
    });
}

downloadCsv(): void {   //this one crashes
   this.chart.exportChart({
      type: 'text/csv',
      filename: this.title
    },{
      itemDelimiter: ';',
      csv: this.chart.getCSV() 
    });
}

When crashes it redirects to

https://export.highcharts.com/

with this text

unexpected return from chart generation - please check your input data

I think I need to do something else for csv export. Can anybody help me?


回答1:


You need the export-data module. It extends a chart with downloadCSV method.

function downlaodCsv() {
  chart.downloadCSV()
}

live example: http://jsfiddle.net/z1j4enox/



来源:https://stackoverflow.com/questions/49919506/export-csv-from-highcharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!