From 19a50453af9bf085a01c2af4ff527a84e068b07e Mon Sep 17 00:00:00 2001 From: sorenwojo Date: Fri, 15 Jan 2016 10:16:38 +0100 Subject: [PATCH] Added option for export all data Able to export all "raw" data instead of only displayed data. This is configurable by option: exportAllRawData. Not completely sure about the consequences for other graph types. But works fine with line plot. --- export-csv.js | 72 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/export-csv.js b/export-csv.js index 85b0106..b01bb08 100644 --- a/export-csv.js +++ b/export-csv.js @@ -64,31 +64,53 @@ j = j + 1; } - each(series.points, function (point, pIdx) { - var key = requireSorting ? point.x : pIdx, - prop, - val; - - j = 0; - - if (!rows[key]) { - rows[key] = []; - } - rows[key].x = point.x; - - // Pies, funnels etc. use point name in X row - if (!series.xAxis) { - rows[key].name = point.name; - } - - while (j < valueCount) { - 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; - } - - }); + if (options.exportAllRawData) { + each(series.xData, function (xValue, pIdx) { + var key = requireSorting ? xValue : pIdx, + prop, + val; + + j = 0; + + if (!rows[key]) { + rows[key] = []; + } + rows[key].x = xValue; + + while (j < valueCount) { + prop = pointArrayMap[j]; // y, z etc + val = series.yData[pIdx]; + rows[key][i + j] = pick(categoryMap[prop][val], val); // Pick a Y axis category if present + j = j + 1; + } + }); + } else { + each(series.points, function (point, pIdx) { + var key = requireSorting ? point.x : pIdx, + prop, + val; + + j = 0; + + if (!rows[key]) { + rows[key] = []; + } + rows[key].x = point.x; + + // Pies, funnels etc. use point name in X row + if (!series.xAxis) { + rows[key].name = point.name; + } + + while (j < valueCount) { + 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; + } + + }); + } i = i + j; } });