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?
You need the export-data module. It extends a chart with downloadCSV
method.
function downlaodCsv() {
chart.downloadCSV()
}
live example: http://jsfiddle.net/z1j4enox/