highcharts-rails 5.0.14 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +60 -0
- data/Rakefile +54 -5
- data/app/assets/images/highcharts/earth.svg +432 -0
- data/app/assets/javascripts/highcharts.js +5103 -3147
- data/app/assets/javascripts/highcharts/highcharts-3d.js +930 -277
- data/app/assets/javascripts/highcharts/highcharts-more.js +1374 -249
- data/app/assets/javascripts/highcharts/lib/canvg.js +3073 -0
- data/app/assets/javascripts/highcharts/lib/jspdf.js +16624 -0
- data/app/assets/javascripts/highcharts/lib/rgbcolor.js +299 -0
- data/app/assets/javascripts/highcharts/lib/svg2pdf.js +3488 -0
- data/app/assets/javascripts/highcharts/modules/accessibility.js +654 -212
- data/app/assets/javascripts/highcharts/modules/annotations.js +1552 -274
- data/app/assets/javascripts/highcharts/modules/boost-canvas.js +773 -0
- data/app/assets/javascripts/highcharts/modules/boost.js +636 -210
- data/app/assets/javascripts/highcharts/modules/broken-axis.js +2 -2
- data/app/assets/javascripts/highcharts/modules/bullet.js +364 -0
- data/app/assets/javascripts/highcharts/modules/data.js +766 -38
- data/app/assets/javascripts/highcharts/modules/drag-panes.js +588 -0
- data/app/assets/javascripts/highcharts/modules/drilldown.js +106 -36
- data/app/assets/javascripts/highcharts/modules/export-data.js +597 -0
- data/app/assets/javascripts/highcharts/modules/exporting.js +424 -162
- data/app/assets/javascripts/highcharts/modules/funnel.js +144 -22
- data/app/assets/javascripts/highcharts/modules/gantt.js +1154 -0
- data/app/assets/javascripts/highcharts/modules/grid-axis.js +1 -1
- data/app/assets/javascripts/highcharts/modules/heatmap.js +406 -80
- data/app/assets/javascripts/highcharts/modules/histogram-bellcurve.js +513 -0
- data/app/assets/javascripts/highcharts/modules/item-series.js +126 -0
- data/app/assets/javascripts/highcharts/modules/no-data-to-display.js +31 -13
- data/app/assets/javascripts/highcharts/modules/offline-exporting.js +179 -57
- data/app/assets/javascripts/highcharts/modules/oldie.js +1378 -0
- data/app/assets/javascripts/highcharts/modules/overlapping-datalabels.js +8 -6
- data/app/assets/javascripts/highcharts/modules/parallel-coordinates.js +494 -0
- data/app/assets/javascripts/highcharts/modules/pareto.js +275 -0
- data/app/assets/javascripts/highcharts/modules/sankey.js +641 -0
- data/app/assets/javascripts/highcharts/modules/series-label.js +355 -145
- data/app/assets/javascripts/highcharts/modules/solid-gauge.js +122 -1
- data/app/assets/javascripts/highcharts/modules/static-scale.js +64 -0
- data/app/assets/javascripts/highcharts/modules/stock.js +1944 -676
- data/app/assets/javascripts/highcharts/modules/streamgraph.js +139 -0
- data/app/assets/javascripts/highcharts/modules/sunburst.js +2403 -0
- data/app/assets/javascripts/highcharts/modules/tilemap.js +1199 -0
- data/app/assets/javascripts/highcharts/modules/treemap.js +538 -134
- data/app/assets/javascripts/highcharts/modules/variable-pie.js +490 -0
- data/app/assets/javascripts/highcharts/modules/variwide.js +283 -0
- data/app/assets/javascripts/highcharts/modules/vector.js +294 -0
- data/app/assets/javascripts/highcharts/modules/windbarb.js +490 -0
- data/app/assets/javascripts/highcharts/modules/wordcloud.js +681 -0
- data/app/assets/javascripts/highcharts/modules/xrange.js +615 -0
- data/app/assets/javascripts/highcharts/themes/avocado.js +54 -0
- data/app/assets/javascripts/highcharts/themes/dark-blue.js +6 -6
- data/app/assets/javascripts/highcharts/themes/dark-green.js +6 -6
- data/app/assets/javascripts/highcharts/themes/dark-unica.js +6 -6
- data/app/assets/javascripts/highcharts/themes/gray.js +14 -10
- data/app/assets/javascripts/highcharts/themes/grid-light.js +6 -6
- data/app/assets/javascripts/highcharts/themes/grid.js +7 -5
- data/app/assets/javascripts/highcharts/themes/sand-signika.js +8 -7
- data/app/assets/javascripts/highcharts/themes/skies.js +15 -9
- data/app/assets/javascripts/highcharts/themes/sunset.js +53 -0
- data/app/assets/stylesheets/highcharts/highcharts.css +802 -0
- data/app/assets/stylesheets/highcharts/highcharts.scss +665 -0
- data/lib/highcharts/version.rb +1 -1
- metadata +31 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license Highcharts JS
|
2
|
+
* @license Highcharts JS v6.0.0 (2017-10-04)
|
3
3
|
* Highcharts Drilldown module
|
4
4
|
*
|
5
5
|
* Author: Torstein Honsi
|
@@ -44,6 +44,17 @@
|
|
44
44
|
|
45
45
|
// Add language
|
46
46
|
extend(defaultOptions.lang, {
|
47
|
+
/**
|
48
|
+
* The text for the button that appears when drilling down, linking
|
49
|
+
* back to the parent series. The parent series' name is inserted for
|
50
|
+
* `{series.name}`.
|
51
|
+
*
|
52
|
+
* @type {String}
|
53
|
+
* @default Back to {series.name}
|
54
|
+
* @since 3.0.8
|
55
|
+
* @product highcharts highmaps
|
56
|
+
* @apioption lang.drillUpText
|
57
|
+
*/
|
47
58
|
drillUpText: '◁ Back to {series.name}'
|
48
59
|
});
|
49
60
|
|
@@ -60,6 +71,21 @@
|
|
60
71
|
*/
|
61
72
|
defaultOptions.drilldown = {
|
62
73
|
|
74
|
+
/**
|
75
|
+
* When this option is false, clicking a single point will drill down
|
76
|
+
* all points in the same category, equivalent to clicking the X axis
|
77
|
+
* label.
|
78
|
+
*
|
79
|
+
* @type {Boolean}
|
80
|
+
* @sample {highcharts} highcharts/drilldown/allowpointdrilldown-false/
|
81
|
+
* Don't allow point drilldown
|
82
|
+
* @default true
|
83
|
+
* @since 4.1.7
|
84
|
+
* @product highcharts
|
85
|
+
* @apioption drilldown.allowPointDrilldown
|
86
|
+
*/
|
87
|
+
|
88
|
+
|
63
89
|
|
64
90
|
/**
|
65
91
|
* Additional styles to apply to the X axis label for a point that
|
@@ -67,30 +93,16 @@
|
|
67
93
|
* to interaction.
|
68
94
|
*
|
69
95
|
* @type {CSSObject}
|
70
|
-
* @see In
|
71
|
-
* style/style-by-css), active label styles can be set with the `.highcharts-
|
72
|
-
* drilldown-axis-label` class.
|
96
|
+
* @see In styled mode, active label styles can be set with the `.highcharts-drilldown-axis-label` class.
|
73
97
|
* @sample {highcharts} highcharts/drilldown/labels/ Label styles
|
74
98
|
* @default { "cursor": "pointer", "color": "#003399", "fontWeight": "bold", "textDecoration": "underline" }
|
75
99
|
* @since 3.0.8
|
76
100
|
* @product highcharts highmaps
|
77
101
|
*/
|
78
102
|
activeAxisLabelStyle: {
|
79
|
-
|
80
|
-
/**
|
81
|
-
*/
|
82
103
|
cursor: 'pointer',
|
83
|
-
|
84
|
-
/**
|
85
|
-
*/
|
86
104
|
color: '#003399',
|
87
|
-
|
88
|
-
/**
|
89
|
-
*/
|
90
105
|
fontWeight: 'bold',
|
91
|
-
|
92
|
-
/**
|
93
|
-
*/
|
94
106
|
textDecoration: 'underline'
|
95
107
|
},
|
96
108
|
|
@@ -100,8 +112,7 @@
|
|
100
112
|
* interaction.
|
101
113
|
*
|
102
114
|
* @type {CSSObject}
|
103
|
-
* @see In
|
104
|
-
* style/style-by-css), active data label styles can be applied with
|
115
|
+
* @see In styled mode, active data label styles can be applied with
|
105
116
|
* the `.highcharts-drilldown-data-label` class.
|
106
117
|
* @sample {highcharts} highcharts/drilldown/labels/ Label styles
|
107
118
|
* @default { "cursor": "pointer", "color": "#003399", "fontWeight": "bold", "textDecoration": "underline" }
|
@@ -109,21 +120,9 @@
|
|
109
120
|
* @product highcharts highmaps
|
110
121
|
*/
|
111
122
|
activeDataLabelStyle: {
|
112
|
-
|
113
|
-
/**
|
114
|
-
*/
|
115
123
|
cursor: 'pointer',
|
116
|
-
|
117
|
-
/**
|
118
|
-
*/
|
119
124
|
color: '#003399',
|
120
|
-
|
121
|
-
/**
|
122
|
-
*/
|
123
125
|
fontWeight: 'bold',
|
124
|
-
|
125
|
-
/**
|
126
|
-
*/
|
127
126
|
textDecoration: 'underline'
|
128
127
|
},
|
129
128
|
|
@@ -161,6 +160,8 @@
|
|
161
160
|
animation: {
|
162
161
|
|
163
162
|
/**
|
163
|
+
* Duration for the drilldown animation.
|
164
|
+
* @default 500
|
164
165
|
*/
|
165
166
|
duration: 500
|
166
167
|
},
|
@@ -189,20 +190,76 @@
|
|
189
190
|
position: {
|
190
191
|
|
191
192
|
/**
|
193
|
+
* Horizontal alignment.
|
194
|
+
* @type {String}
|
192
195
|
*/
|
193
196
|
align: 'right',
|
194
197
|
|
195
198
|
/**
|
199
|
+
* The X offset of the button.
|
200
|
+
* @type {Number}
|
196
201
|
*/
|
197
202
|
x: -10,
|
198
203
|
|
199
204
|
/**
|
205
|
+
* The Y offset of the button.
|
206
|
+
* @type {Number}
|
200
207
|
*/
|
201
208
|
y: 10
|
209
|
+
|
210
|
+
/**
|
211
|
+
* Vertical alignment of the button.
|
212
|
+
*
|
213
|
+
* @type {String}
|
214
|
+
* @default top
|
215
|
+
* @validvalue ["top", "middle", "bottom"]
|
216
|
+
* @product highcharts highmaps
|
217
|
+
* @apioption drilldown.drillUpButton.position.verticalAlign
|
218
|
+
*/
|
202
219
|
}
|
203
|
-
|
204
|
-
|
220
|
+
/**
|
221
|
+
* What box to align the button to. Can be either `plotBox` or
|
222
|
+
* `spacingBox.
|
223
|
+
*
|
224
|
+
* @type {String}
|
225
|
+
* @default plotBox
|
226
|
+
* @validvalue ["plotBox", "spacingBox"]
|
227
|
+
* @since 3.0.8
|
228
|
+
* @product highcharts highmaps
|
229
|
+
* @apioption drilldown.drillUpButton.relativeTo
|
230
|
+
*/
|
231
|
+
|
232
|
+
/**
|
233
|
+
* A collection of attributes for the button. The object takes SVG attributes
|
234
|
+
* like `fill`, `stroke`, `stroke-width` or `r`, the border radius.
|
235
|
+
* The theme also supports `style`, a collection of CSS properties for
|
236
|
+
* the text. Equivalent attributes for the hover state are given in
|
237
|
+
* `theme.states.hover`.
|
238
|
+
*
|
239
|
+
* @type {Object}
|
240
|
+
* @see In styled mode, drill-up button styles can be applied with the
|
241
|
+
* `.highcharts-drillup-button` class.
|
242
|
+
* @sample {highcharts} highcharts/drilldown/drillupbutton/
|
243
|
+
* Button theming
|
244
|
+
* @sample {highmaps} highcharts/drilldown/drillupbutton/
|
245
|
+
* Button theming
|
246
|
+
* @since 3.0.8
|
247
|
+
* @product highcharts highmaps
|
248
|
+
* @apioption drilldown.drillUpButton.theme
|
249
|
+
*/
|
205
250
|
}
|
251
|
+
|
252
|
+
/**
|
253
|
+
* An array of series configurations for the drill down. Each series
|
254
|
+
* configuration uses the same syntax as the [series](#series) option
|
255
|
+
* set. These drilldown series are hidden by default. The drilldown
|
256
|
+
* series is linked to the parent series' point by its `id`.
|
257
|
+
*
|
258
|
+
* @type {Array<Object>}
|
259
|
+
* @since 3.0.8
|
260
|
+
* @product highcharts highmaps
|
261
|
+
* @apioption drilldown.series
|
262
|
+
*/
|
206
263
|
};
|
207
264
|
|
208
265
|
|
@@ -271,6 +328,17 @@
|
|
271
328
|
* @apioption chart.events.drillupall
|
272
329
|
*/
|
273
330
|
|
331
|
+
/**
|
332
|
+
* The `id` of a series in the [drilldown.series](#drilldown.series)
|
333
|
+
* array to use for a drilldown for this point.
|
334
|
+
*
|
335
|
+
* @type {String}
|
336
|
+
* @sample {highcharts} highcharts/drilldown/basic/ Basic drilldown
|
337
|
+
* @since 3.0.8
|
338
|
+
* @product highcharts
|
339
|
+
* @apioption series.line.data.drilldown
|
340
|
+
*/
|
341
|
+
|
274
342
|
/**
|
275
343
|
* A general fadeIn method
|
276
344
|
*/
|
@@ -422,7 +490,7 @@
|
|
422
490
|
}
|
423
491
|
});
|
424
492
|
}
|
425
|
-
|
493
|
+
this.pointer.reset();
|
426
494
|
this.redraw();
|
427
495
|
this.showDrillUpButton();
|
428
496
|
};
|
@@ -695,7 +763,7 @@
|
|
695
763
|
group = this.group,
|
696
764
|
// For 3d column series all columns are added to one group
|
697
765
|
// so we should not delete the whole group. #5297
|
698
|
-
removeGroup = group !== this.chart.
|
766
|
+
removeGroup = group !== this.chart.columnGroup,
|
699
767
|
series = this;
|
700
768
|
|
701
769
|
// Cancel mouse events on the series group (#2787)
|
@@ -925,14 +993,16 @@
|
|
925
993
|
point.doDrilldown(undefined, undefined, e);
|
926
994
|
}
|
927
995
|
});
|
928
|
-
/*
|
996
|
+
/*
|
997
|
+
wrap(point, 'importEvents', function (proceed) { // wrapping importEvents makes point.click event work
|
929
998
|
if (!this.hasImportedEvents) {
|
930
999
|
proceed.call(this);
|
931
1000
|
H.addEvent(this, 'click', function () {
|
932
1001
|
this.doDrilldown();
|
933
1002
|
});
|
934
1003
|
}
|
935
|
-
})
|
1004
|
+
});
|
1005
|
+
*/
|
936
1006
|
|
937
1007
|
}
|
938
1008
|
|
@@ -0,0 +1,597 @@
|
|
1
|
+
/**
|
2
|
+
* @license Highcharts JS v6.0.0 (2017-10-04)
|
3
|
+
* Exporting module
|
4
|
+
*
|
5
|
+
* (c) 2010-2017 Torstein Honsi
|
6
|
+
*
|
7
|
+
* License: www.highcharts.com/license
|
8
|
+
*/
|
9
|
+
'use strict';
|
10
|
+
(function(factory) {
|
11
|
+
if (typeof module === 'object' && module.exports) {
|
12
|
+
module.exports = factory;
|
13
|
+
} else {
|
14
|
+
factory(Highcharts);
|
15
|
+
}
|
16
|
+
}(function(Highcharts) {
|
17
|
+
(function(Highcharts) {
|
18
|
+
/**
|
19
|
+
* Experimental data export module for Highcharts
|
20
|
+
*
|
21
|
+
* (c) 2010-2017 Torstein Honsi
|
22
|
+
*
|
23
|
+
* License: www.highcharts.com/license
|
24
|
+
*/
|
25
|
+
|
26
|
+
// @todo
|
27
|
+
// - Deprecate repo and plugins page
|
28
|
+
// - Before official release, set up systematic tests for all series types
|
29
|
+
|
30
|
+
/* eslint max-len: ["warn", 80, 4] */
|
31
|
+
|
32
|
+
var each = Highcharts.each,
|
33
|
+
pick = Highcharts.pick,
|
34
|
+
win = Highcharts.win,
|
35
|
+
doc = win.document,
|
36
|
+
seriesTypes = Highcharts.seriesTypes,
|
37
|
+
downloadAttrSupported = doc.createElement('a').download !== undefined;
|
38
|
+
|
39
|
+
Highcharts.setOptions({
|
40
|
+
/**
|
41
|
+
* @optionparent exporting
|
42
|
+
*/
|
43
|
+
exporting: {
|
44
|
+
/**
|
45
|
+
* Options for exporting data to CSV or ExCel, or displaying the data
|
46
|
+
* in a HTML table or a JavaScript structure. Requires the
|
47
|
+
* `export-data.js` module. This module adds data export options to the
|
48
|
+
* export menu and provides functions like `Chart.getCSV`,
|
49
|
+
* `Chart.getTable`, `Chart.getDataRows` and `Chart.viewData`.
|
50
|
+
*
|
51
|
+
* @sample highcharts/export-data/categorized/ Categorized data
|
52
|
+
* @sample highcharts/export-data/stock-timeaxis/ Highstock time axis
|
53
|
+
*
|
54
|
+
* @since 6.0.0
|
55
|
+
*/
|
56
|
+
csv: {
|
57
|
+
/**
|
58
|
+
* Formatter callback for the column headers. Parameters are:
|
59
|
+
* - `item` - The series or axis object)
|
60
|
+
* - `key` - The point key, for example y or z
|
61
|
+
* - `keyLength` - The amount of value keys for this item, for
|
62
|
+
* example a range series has the keys `low` and `high` so the
|
63
|
+
* key length is 2.
|
64
|
+
*
|
65
|
+
* By default it returns the series name, followed by the key if
|
66
|
+
* there is more than one key. For the axis it returns the axis
|
67
|
+
* title or "Category" or "DateTime" by default.
|
68
|
+
*
|
69
|
+
* Return `false` to use Highcharts' proposed header.
|
70
|
+
*
|
71
|
+
* @type {Function|null}
|
72
|
+
*/
|
73
|
+
columnHeaderFormatter: null,
|
74
|
+
/**
|
75
|
+
* Which date format to use for exported dates on a datetime X axis.
|
76
|
+
* See `Highcharts.dateFormat`.
|
77
|
+
*/
|
78
|
+
dateFormat: '%Y-%m-%d %H:%M:%S',
|
79
|
+
/**
|
80
|
+
* The item delimiter in the exported data. Use `;` for direct
|
81
|
+
* exporting to Excel.
|
82
|
+
*/
|
83
|
+
itemDelimiter: ',',
|
84
|
+
/**
|
85
|
+
* The line delimiter in the exported data, defaults to a newline.
|
86
|
+
*/
|
87
|
+
lineDelimiter: '\n'
|
88
|
+
},
|
89
|
+
/**
|
90
|
+
* Export-data module required. Show a HTML table below the chart with
|
91
|
+
* the chart's current data.
|
92
|
+
*
|
93
|
+
* @sample highcharts/export-data/showtable/ Show the table
|
94
|
+
* @since 6.0.0
|
95
|
+
*/
|
96
|
+
showTable: false
|
97
|
+
},
|
98
|
+
/**
|
99
|
+
* @optionparent lang
|
100
|
+
*/
|
101
|
+
lang: {
|
102
|
+
/**
|
103
|
+
* Export-data module only. The text for the menu item.
|
104
|
+
* @since 6.0.0
|
105
|
+
*/
|
106
|
+
downloadCSV: 'Download CSV',
|
107
|
+
/**
|
108
|
+
* Export-data module only. The text for the menu item.
|
109
|
+
* @since 6.0.0
|
110
|
+
*/
|
111
|
+
downloadXLS: 'Download XLS',
|
112
|
+
/**
|
113
|
+
* Export-data module only. The text for the menu item.
|
114
|
+
* @since 6.0.0
|
115
|
+
*/
|
116
|
+
viewData: 'View data table'
|
117
|
+
}
|
118
|
+
});
|
119
|
+
|
120
|
+
// Add an event listener to handle the showTable option
|
121
|
+
Highcharts.Chart.prototype.callbacks.push(function(chart) {
|
122
|
+
Highcharts.addEvent(chart, 'render', function() {
|
123
|
+
if (chart.options.exporting.showTable) {
|
124
|
+
chart.viewData();
|
125
|
+
}
|
126
|
+
});
|
127
|
+
});
|
128
|
+
|
129
|
+
// Set up key-to-axis bindings. This is used when the Y axis is datetime or
|
130
|
+
// categorized. For example in an arearange series, the low and high values
|
131
|
+
// sholud be formatted according to the Y axis type, and in order to link them
|
132
|
+
// we need this map.
|
133
|
+
Highcharts.Chart.prototype.setUpKeyToAxis = function() {
|
134
|
+
if (seriesTypes.arearange) {
|
135
|
+
seriesTypes.arearange.prototype.keyToAxis = {
|
136
|
+
low: 'y',
|
137
|
+
high: 'y'
|
138
|
+
};
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Export-data module required. Returns a two-dimensional array containing the
|
144
|
+
* current chart data.
|
145
|
+
*
|
146
|
+
* @returns {Array.<Array>}
|
147
|
+
* The current chart data
|
148
|
+
*/
|
149
|
+
Highcharts.Chart.prototype.getDataRows = function() {
|
150
|
+
var csvOptions = (this.options.exporting && this.options.exporting.csv) || {},
|
151
|
+
xAxis,
|
152
|
+
xAxes = this.xAxis,
|
153
|
+
rows = {},
|
154
|
+
rowArr = [],
|
155
|
+
dataRows,
|
156
|
+
names = [],
|
157
|
+
i,
|
158
|
+
x,
|
159
|
+
xTitle,
|
160
|
+
// Options
|
161
|
+
columnHeaderFormatter = function(item, key, keyLength) {
|
162
|
+
|
163
|
+
if (csvOptions.columnHeaderFormatter) {
|
164
|
+
var s = csvOptions.columnHeaderFormatter(item, key, keyLength);
|
165
|
+
if (s !== false) {
|
166
|
+
return s;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
|
171
|
+
if (item instanceof Highcharts.Axis) {
|
172
|
+
return (item.options.title && item.options.title.text) ||
|
173
|
+
(item.isDatetimeAxis ? 'DateTime' : 'Category');
|
174
|
+
}
|
175
|
+
return item ?
|
176
|
+
item.name + (keyLength > 1 ? ' (' + key + ')' : '') :
|
177
|
+
'Category';
|
178
|
+
},
|
179
|
+
xAxisIndices = [];
|
180
|
+
|
181
|
+
// Loop the series and index values
|
182
|
+
i = 0;
|
183
|
+
|
184
|
+
this.setUpKeyToAxis();
|
185
|
+
|
186
|
+
each(this.series, function(series) {
|
187
|
+
var keys = series.options.keys,
|
188
|
+
pointArrayMap = keys || series.pointArrayMap || ['y'],
|
189
|
+
valueCount = pointArrayMap.length,
|
190
|
+
xTaken = !series.requireSorting && {},
|
191
|
+
categoryMap = {},
|
192
|
+
datetimeValueAxisMap = {},
|
193
|
+
xAxisIndex = Highcharts.inArray(series.xAxis, xAxes),
|
194
|
+
j;
|
195
|
+
|
196
|
+
// Map the categories for value axes
|
197
|
+
each(pointArrayMap, function(prop) {
|
198
|
+
|
199
|
+
var axisName = (
|
200
|
+
(series.keyToAxis && series.keyToAxis[prop]) ||
|
201
|
+
prop
|
202
|
+
) + 'Axis';
|
203
|
+
|
204
|
+
categoryMap[prop] = (
|
205
|
+
series[axisName] &&
|
206
|
+
series[axisName].categories
|
207
|
+
) || [];
|
208
|
+
datetimeValueAxisMap[prop] = (
|
209
|
+
series[axisName] &&
|
210
|
+
series[axisName].isDatetimeAxis
|
211
|
+
);
|
212
|
+
});
|
213
|
+
|
214
|
+
if (
|
215
|
+
series.options.includeInCSVExport !== false &&
|
216
|
+
series.visible !== false // #55
|
217
|
+
) {
|
218
|
+
|
219
|
+
// Build a lookup for X axis index and the position of the first
|
220
|
+
// series that belongs to that X axis. Includes -1 for non-axis
|
221
|
+
// series types like pies.
|
222
|
+
if (!Highcharts.find(xAxisIndices, function(index) {
|
223
|
+
return index[0] === xAxisIndex;
|
224
|
+
})) {
|
225
|
+
xAxisIndices.push([xAxisIndex, i]);
|
226
|
+
}
|
227
|
+
|
228
|
+
// Add the column headers, usually the same as series names
|
229
|
+
j = 0;
|
230
|
+
while (j < valueCount) {
|
231
|
+
names.push(columnHeaderFormatter(
|
232
|
+
series,
|
233
|
+
pointArrayMap[j],
|
234
|
+
pointArrayMap.length
|
235
|
+
));
|
236
|
+
j++;
|
237
|
+
}
|
238
|
+
|
239
|
+
each(series.points, function(point, pIdx) {
|
240
|
+
var key = point.x,
|
241
|
+
prop,
|
242
|
+
val;
|
243
|
+
|
244
|
+
if (xTaken) {
|
245
|
+
if (xTaken[key]) {
|
246
|
+
key += '|' + pIdx;
|
247
|
+
}
|
248
|
+
xTaken[key] = true;
|
249
|
+
}
|
250
|
+
|
251
|
+
j = 0;
|
252
|
+
|
253
|
+
if (!rows[key]) {
|
254
|
+
// Generate the row
|
255
|
+
rows[key] = [];
|
256
|
+
// Contain the X values from one or more X axes
|
257
|
+
rows[key].xValues = [];
|
258
|
+
}
|
259
|
+
rows[key].x = point.x;
|
260
|
+
rows[key].xValues[xAxisIndex] = point.x;
|
261
|
+
|
262
|
+
// Pies, funnels, geo maps etc. use point name in X row
|
263
|
+
if (!series.xAxis || series.exportKey === 'name') {
|
264
|
+
rows[key].name = point.name;
|
265
|
+
}
|
266
|
+
|
267
|
+
while (j < valueCount) {
|
268
|
+
prop = pointArrayMap[j]; // y, z etc
|
269
|
+
val = point[prop];
|
270
|
+
rows[key][i + j] = pick(
|
271
|
+
categoryMap[prop][val], // Y axis category if present
|
272
|
+
datetimeValueAxisMap[prop] ?
|
273
|
+
Highcharts.dateFormat(csvOptions.dateFormat, val) :
|
274
|
+
null,
|
275
|
+
val
|
276
|
+
);
|
277
|
+
j++;
|
278
|
+
}
|
279
|
+
|
280
|
+
});
|
281
|
+
i = i + j;
|
282
|
+
}
|
283
|
+
});
|
284
|
+
|
285
|
+
// Make a sortable array
|
286
|
+
for (x in rows) {
|
287
|
+
if (rows.hasOwnProperty(x)) {
|
288
|
+
rowArr.push(rows[x]);
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
var xAxisIndex, column;
|
293
|
+
dataRows = [names];
|
294
|
+
|
295
|
+
i = xAxisIndices.length;
|
296
|
+
while (i--) { // Start from end to splice in
|
297
|
+
xAxisIndex = xAxisIndices[i][0];
|
298
|
+
column = xAxisIndices[i][1];
|
299
|
+
xAxis = xAxes[xAxisIndex];
|
300
|
+
|
301
|
+
// Sort it by X values
|
302
|
+
rowArr.sort(function(a, b) { // eslint-disable-line no-loop-func
|
303
|
+
return a.xValues[xAxisIndex] - b.xValues[xAxisIndex];
|
304
|
+
});
|
305
|
+
|
306
|
+
// Add header row
|
307
|
+
xTitle = columnHeaderFormatter(xAxis);
|
308
|
+
dataRows[0].splice(column, 0, xTitle);
|
309
|
+
|
310
|
+
// Add the category column
|
311
|
+
each(rowArr, function(row) { // eslint-disable-line no-loop-func
|
312
|
+
var category = row.name;
|
313
|
+
if (!category) {
|
314
|
+
if (xAxis.isDatetimeAxis) {
|
315
|
+
if (row.x instanceof Date) {
|
316
|
+
row.x = row.x.getTime();
|
317
|
+
}
|
318
|
+
category = Highcharts.dateFormat(
|
319
|
+
csvOptions.dateFormat,
|
320
|
+
row.x
|
321
|
+
);
|
322
|
+
} else if (xAxis.categories) {
|
323
|
+
category = pick(
|
324
|
+
xAxis.names[row.x],
|
325
|
+
xAxis.categories[row.x],
|
326
|
+
row.x
|
327
|
+
);
|
328
|
+
} else {
|
329
|
+
category = row.x;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
// Add the X/date/category
|
334
|
+
row.splice(column, 0, category);
|
335
|
+
});
|
336
|
+
}
|
337
|
+
dataRows = dataRows.concat(rowArr);
|
338
|
+
|
339
|
+
return dataRows;
|
340
|
+
};
|
341
|
+
|
342
|
+
/**
|
343
|
+
* Export-data module required. Returns the current chart data as a CSV string.
|
344
|
+
*
|
345
|
+
* @param {Boolean} useLocalDecimalPoint
|
346
|
+
* Whether to use the local decimal point as detected from the browser.
|
347
|
+
* This makes it easier to export data to Excel in the same locale as
|
348
|
+
* the user is.
|
349
|
+
*
|
350
|
+
* @returns {String}
|
351
|
+
* CSV representation of the data
|
352
|
+
*/
|
353
|
+
Highcharts.Chart.prototype.getCSV = function(useLocalDecimalPoint) {
|
354
|
+
var csv = '',
|
355
|
+
rows = this.getDataRows(),
|
356
|
+
csvOptions = this.options.exporting.csv,
|
357
|
+
// use ';' for direct to Excel
|
358
|
+
itemDelimiter = csvOptions.itemDelimiter,
|
359
|
+
// '\n' isn't working with the js csv data extraction
|
360
|
+
lineDelimiter = csvOptions.lineDelimiter;
|
361
|
+
|
362
|
+
// Transform the rows to CSV
|
363
|
+
each(rows, function(row, i) {
|
364
|
+
var val = '',
|
365
|
+
j = row.length,
|
366
|
+
n = useLocalDecimalPoint ? (1.1).toLocaleString()[1] : '.';
|
367
|
+
while (j--) {
|
368
|
+
val = row[j];
|
369
|
+
if (typeof val === 'string') {
|
370
|
+
val = '"' + val + '"';
|
371
|
+
}
|
372
|
+
if (typeof val === 'number') {
|
373
|
+
if (n === ',') {
|
374
|
+
val = val.toString().replace('.', ',');
|
375
|
+
}
|
376
|
+
}
|
377
|
+
row[j] = val;
|
378
|
+
}
|
379
|
+
// Add the values
|
380
|
+
csv += row.join(itemDelimiter);
|
381
|
+
|
382
|
+
// Add the line delimiter
|
383
|
+
if (i < rows.length - 1) {
|
384
|
+
csv += lineDelimiter;
|
385
|
+
}
|
386
|
+
});
|
387
|
+
return csv;
|
388
|
+
};
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Export-data module required. Build a HTML table with the chart's current
|
392
|
+
* data.
|
393
|
+
*
|
394
|
+
* @sample highcharts/export-data/viewdata/
|
395
|
+
* View the data from the export menu
|
396
|
+
* @returns {String}
|
397
|
+
* HTML representation of the data.
|
398
|
+
*/
|
399
|
+
Highcharts.Chart.prototype.getTable = function(useLocalDecimalPoint) {
|
400
|
+
var html = '<table><thead>',
|
401
|
+
rows = this.getDataRows();
|
402
|
+
|
403
|
+
// Transform the rows to HTML
|
404
|
+
each(rows, function(row, i) {
|
405
|
+
var tag = i ? 'td' : 'th',
|
406
|
+
val,
|
407
|
+
j,
|
408
|
+
n = useLocalDecimalPoint ? (1.1).toLocaleString()[1] : '.';
|
409
|
+
|
410
|
+
html += '<tr>';
|
411
|
+
for (j = 0; j < row.length; j = j + 1) {
|
412
|
+
val = row[j];
|
413
|
+
// Add the cell
|
414
|
+
if (typeof val === 'number') {
|
415
|
+
val = val.toString();
|
416
|
+
if (n === ',') {
|
417
|
+
val = val.replace('.', n);
|
418
|
+
}
|
419
|
+
html += '<' + tag + ' class="number">' + val + '</' + tag + '>';
|
420
|
+
|
421
|
+
} else {
|
422
|
+
html += '<' + tag + ' class="text">' +
|
423
|
+
(val === undefined ? '' : val) + '</' + tag + '>';
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
html += '</tr>';
|
428
|
+
|
429
|
+
// After the first row, end head and start body
|
430
|
+
if (!i) {
|
431
|
+
html += '</thead><tbody>';
|
432
|
+
}
|
433
|
+
|
434
|
+
});
|
435
|
+
html += '</tbody></table>';
|
436
|
+
|
437
|
+
return html;
|
438
|
+
};
|
439
|
+
|
440
|
+
/**
|
441
|
+
* File download using download attribute if supported.
|
442
|
+
*
|
443
|
+
* @private
|
444
|
+
*/
|
445
|
+
Highcharts.Chart.prototype.fileDownload = function(href, extension, content) {
|
446
|
+
var a,
|
447
|
+
blobObject,
|
448
|
+
name;
|
449
|
+
|
450
|
+
if (this.options.exporting.filename) {
|
451
|
+
name = this.options.exporting.filename;
|
452
|
+
} else if (this.title) {
|
453
|
+
name = this.title.textStr.replace(/ /g, '-').toLowerCase();
|
454
|
+
} else {
|
455
|
+
name = 'chart';
|
456
|
+
}
|
457
|
+
|
458
|
+
// MS specific. Check this first because of bug with Edge (#76)
|
459
|
+
if (win.Blob && win.navigator.msSaveOrOpenBlob) {
|
460
|
+
// Falls to msSaveOrOpenBlob if download attribute is not supported
|
461
|
+
blobObject = new win.Blob(
|
462
|
+
['\uFEFF' + content], // #7084
|
463
|
+
{
|
464
|
+
type: 'text/csv'
|
465
|
+
}
|
466
|
+
);
|
467
|
+
win.navigator.msSaveOrOpenBlob(blobObject, name + '.' + extension);
|
468
|
+
|
469
|
+
// Download attribute supported
|
470
|
+
} else if (downloadAttrSupported) {
|
471
|
+
a = doc.createElement('a');
|
472
|
+
a.href = href;
|
473
|
+
a.download = name + '.' + extension;
|
474
|
+
this.container.appendChild(a); // #111
|
475
|
+
a.click();
|
476
|
+
a.remove();
|
477
|
+
|
478
|
+
} else {
|
479
|
+
Highcharts.error('The browser doesn\'t support downloading files');
|
480
|
+
}
|
481
|
+
};
|
482
|
+
|
483
|
+
/**
|
484
|
+
* Call this on click of 'Download CSV' button
|
485
|
+
*
|
486
|
+
* @private
|
487
|
+
*/
|
488
|
+
Highcharts.Chart.prototype.downloadCSV = function() {
|
489
|
+
var csv = this.getCSV(true);
|
490
|
+
this.fileDownload(
|
491
|
+
'data:text/csv,\uFEFF' + encodeURIComponent(csv),
|
492
|
+
'csv',
|
493
|
+
csv,
|
494
|
+
'text/csv'
|
495
|
+
);
|
496
|
+
};
|
497
|
+
|
498
|
+
/**
|
499
|
+
* Call this on click of 'Download XLS' button
|
500
|
+
*
|
501
|
+
* @private
|
502
|
+
*/
|
503
|
+
Highcharts.Chart.prototype.downloadXLS = function() {
|
504
|
+
var uri = 'data:application/vnd.ms-excel;base64,',
|
505
|
+
template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" ' +
|
506
|
+
'xmlns:x="urn:schemas-microsoft-com:office:excel" ' +
|
507
|
+
'xmlns="http://www.w3.org/TR/REC-html40">' +
|
508
|
+
'<head><!--[if gte mso 9]><xml><x:ExcelWorkbook>' +
|
509
|
+
'<x:ExcelWorksheets><x:ExcelWorksheet>' +
|
510
|
+
'<x:Name>Ark1</x:Name>' +
|
511
|
+
'<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions>' +
|
512
|
+
'</x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook>' +
|
513
|
+
'</xml><![endif]-->' +
|
514
|
+
'<style>td{border:none;font-family: Calibri, sans-serif;} ' +
|
515
|
+
'.number{mso-number-format:"0.00";} ' +
|
516
|
+
'.text{ mso-number-format:"\@";}</style>' +
|
517
|
+
'<meta name=ProgId content=Excel.Sheet>' +
|
518
|
+
'<meta charset=UTF-8>' +
|
519
|
+
'</head><body>' +
|
520
|
+
this.getTable(true) +
|
521
|
+
'</body></html>',
|
522
|
+
base64 = function(s) {
|
523
|
+
return win.btoa(unescape(encodeURIComponent(s))); // #50
|
524
|
+
};
|
525
|
+
this.fileDownload(
|
526
|
+
uri + base64(template),
|
527
|
+
'xls',
|
528
|
+
template,
|
529
|
+
'application/vnd.ms-excel'
|
530
|
+
);
|
531
|
+
};
|
532
|
+
|
533
|
+
/**
|
534
|
+
* Export-data module required. View the data in a table below the chart.
|
535
|
+
*/
|
536
|
+
Highcharts.Chart.prototype.viewData = function() {
|
537
|
+
if (!this.dataTableDiv) {
|
538
|
+
this.dataTableDiv = doc.createElement('div');
|
539
|
+
this.dataTableDiv.className = 'highcharts-data-table';
|
540
|
+
|
541
|
+
// Insert after the chart container
|
542
|
+
this.renderTo.parentNode.insertBefore(
|
543
|
+
this.dataTableDiv,
|
544
|
+
this.renderTo.nextSibling
|
545
|
+
);
|
546
|
+
}
|
547
|
+
|
548
|
+
this.dataTableDiv.innerHTML = this.getTable();
|
549
|
+
};
|
550
|
+
|
551
|
+
|
552
|
+
// Add "Download CSV" to the exporting menu.
|
553
|
+
var exportingOptions = Highcharts.getOptions().exporting;
|
554
|
+
if (exportingOptions) {
|
555
|
+
|
556
|
+
Highcharts.extend(exportingOptions.menuItemDefinitions, {
|
557
|
+
downloadCSV: {
|
558
|
+
textKey: 'downloadCSV',
|
559
|
+
onclick: function() {
|
560
|
+
this.downloadCSV();
|
561
|
+
}
|
562
|
+
},
|
563
|
+
downloadXLS: {
|
564
|
+
textKey: 'downloadXLS',
|
565
|
+
onclick: function() {
|
566
|
+
this.downloadXLS();
|
567
|
+
}
|
568
|
+
},
|
569
|
+
viewData: {
|
570
|
+
textKey: 'viewData',
|
571
|
+
onclick: function() {
|
572
|
+
this.viewData();
|
573
|
+
}
|
574
|
+
}
|
575
|
+
});
|
576
|
+
|
577
|
+
exportingOptions.buttons.contextButton.menuItems.push(
|
578
|
+
'separator',
|
579
|
+
'downloadCSV',
|
580
|
+
'downloadXLS',
|
581
|
+
'viewData'
|
582
|
+
);
|
583
|
+
}
|
584
|
+
|
585
|
+
// Series specific
|
586
|
+
if (seriesTypes.map) {
|
587
|
+
seriesTypes.map.prototype.exportKey = 'name';
|
588
|
+
}
|
589
|
+
if (seriesTypes.mapbubble) {
|
590
|
+
seriesTypes.mapbubble.prototype.exportKey = 'name';
|
591
|
+
}
|
592
|
+
if (seriesTypes.treemap) {
|
593
|
+
seriesTypes.treemap.prototype.exportKey = 'name';
|
594
|
+
}
|
595
|
+
|
596
|
+
}(Highcharts));
|
597
|
+
}));
|