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

Improve bubble and scatter csv re: #62 #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions export-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
i,
x,

// Options

// Options
dateFormat = options.dateFormat || '%Y-%m-%d %H:%M:%S';

if (this.options.chart.type == 'bubble' || this.options.chart.type == 'scatter') {
return this.getBubbleDataRows()
}
// Loop the series and index values
i = 0;
each(this.series, function (series) {
Expand Down Expand Up @@ -106,6 +110,44 @@
return dataRows;
};

/**
* Get the data rows from bubble and scatter charts
*/
Highcharts.Chart.prototype.getBubbleDataRows = function () {
var dataRows = [];
var bubble = false;

if (this.options.chart.type == 'bubble') {
bubble = true;
}

// Headers
var headers = [
'Series',
this.options.xAxis[0].title.text,
this.options.yAxis[0].title.text,
];

if (bubble) {
headers.push('Bubble Size')
}

dataRows.push(headers);

// Row: Series, X, Y, (Z)
each(this.series, function (series) {
each(series.points, function (point) {
var row = [series.name, point.x, point.y];
if (bubble) {
row.push(point.z);
}
dataRows.push(row);
});
});

return dataRows;
};

/**
* Get a CSV string
*/
Expand Down Expand Up @@ -247,7 +289,7 @@
'</head><body>' +
this.getTable(true) +
'</body></html>',
base64 = function (s) {
base64 = function (s) {
return window.btoa(unescape(encodeURIComponent(s))); // #50
};
getContent(
Expand Down