Skip to content
This repository has been archived by the owner on May 29, 2018. It is now read-only.

Commit

Permalink
Fixed #73, categories missing from Y axis
Browse files Browse the repository at this point in the history
  • Loading branch information
TorsteinHonsi committed Nov 25, 2015
1 parent a91b014 commit 828f302
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions export-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
*
* Author: Torstein Honsi
* Licence: MIT
* Version: 1.3.6
* Version: 1.3.7
*/
/*global Highcharts, window, document, Blob */
(function (Highcharts) {

'use strict';

var each = Highcharts.each,
pick = Highcharts.pick,
downloadAttrSupported = document.createElement('a').download !== undefined;

Highcharts.setOptions({
Expand Down Expand Up @@ -47,8 +48,14 @@
pointArrayMap = keys || series.pointArrayMap || ['y'],
valueCount = pointArrayMap.length,
requireSorting = series.requireSorting,
categoryMap = {},
j;

// Map the categories for value axes
each(pointArrayMap, function (prop) {
categoryMap[prop] = (series[prop + 'Axis'] && series[prop + 'Axis'].categories) || [];
});

if (series.options.includeInCSVExport !== false && series.visible !== false) { // #55
j = 0;
while (j < valueCount) {
Expand All @@ -57,7 +64,9 @@
}

each(series.points, function (point, pIdx) {
var key = requireSorting ? point.x : pIdx;
var key = requireSorting ? point.x : pIdx,
prop,
val;

j = 0;

Expand All @@ -72,7 +81,9 @@
}

while (j < valueCount) {
rows[key][i + j] = point[pointArrayMap[j]];
prop = pointArrayMap[j]; // y, z etc
val = point[prop];
rows[key][i + j] = pick(categoryMap[prop][val], val); // Pick a Y axis category if present
j = j + 1;
}

Expand Down Expand Up @@ -103,7 +114,7 @@
if (xAxis.isDatetimeAxis) {
category = Highcharts.dateFormat(dateFormat, row.x);
} else if (xAxis.categories) {
category = Highcharts.pick(xAxis.names[row.x], xAxis.categories[row.x], row.x)
category = pick(xAxis.names[row.x], xAxis.categories[row.x], row.x)
} else {
category = row.x;
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Export Data",
"version": "1.3.6",
"version": "1.3.7",
"title": "Export chart data to CSV, XLS, HTML or JS array",
"demo": [
"http://jsfiddle.net/highcharts/cqjvD/",
Expand Down

0 comments on commit 828f302

Please sign in to comment.