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 95 forks source link

Export to csv - different order #33

Open sebastianbochan opened 9 years ago

sebastianbochan commented 9 years ago

It seems that categories are mixed with series.

Example: http://jsfiddle.net/cqjvD/448/

As a result we should receive

image

TorsteinHonsi commented 9 years ago

So you want to switch rows and columns.

The module currently exports each series into a column. The reason for that is perhaps best explained by an example. Imagine how it would be to work with long data series like that in a spreadsheet if the data series were laid out in rows.

Related to our work with Highcharts Cloud, we have investigated how other charting tools handle this. Google Spreadsheets always relates columns to series by default. Excel does an intelligent guess based on what is longer. If there are more rows than columns, columns are interpreted as series and vice versa.

What we could do in this module is to add an option, switchRowsAndColumns. But I believe the default should be kept as it is. Alternatively follow Excel's lead on implementing an intelligent guess, but I think that just complicates things and introduces an unpredictable result when running in a programming environment.

TorsteinHonsi commented 9 years ago

I did a refactoring in export-csv today, so that we can access the raw data rows before concatenated in to CSV. This allows a hook to switch rows and columns: http://jsfiddle.net/highcharts/2oa8a9cx/.