highcharts / export-csv

Highcharts plugin to export chart data to CSV
http://www.highcharts.com/plugin-registry/single/7/Export-CSV
MIT License
76 stars 94 forks source link

Export CSV with X-axis title, that is not DateTime or Category #71

Closed absessive closed 8 years ago

absessive commented 8 years ago

When using the export-csv plugin, the only possible title for the X-axis is Category or DateTime. How do I change that to use the actual title.

For eg. http://jsfiddle.net/highcharts/cqjvd/ In that chart I would rather have 'Month' as title for the X-axis, but https://github.com/highslide-software/export-csv/blob/master/export-csv.js#L96 makes that the only possibility be of title to be either 'DateTime' or 'Category'. How do I get around that?

alammers commented 7 years ago

I have tried to implement the columnHeaderFormatter inside exporting > csv but I could not get this to work. Could you please help me? Used code as seen below.

columnHeaderFormatter: function (series, key) { return 'text'; }

TorsteinHonsi commented 7 years ago

Sure, here's a demo: http://jsfiddle.net/highcharts/cqjvD/1262/

alammers commented 7 years ago

Hmm that's what I used as well, but I didn't get it to work in my project... What I was actually looking for was a way to change the 'Category' in that demo to a custom name. Is that possible?

TorsteinHonsi commented 7 years ago

Yes, if you change your chart's xAxis.title, it will be reflected in the column header: http://jsfiddle.net/highcharts/cqjvD/1264/

Also, I have released a new minor that runs the columnHeaderFormatter also for the axis header.

alammers commented 7 years ago

Thank you for the help. It turned out we had an old version of the export bundle installed. Updating it fixed the problem for us ;)