highcharts-rails 4.1.9 → 4.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v4.1.9 (2015-10-07)
2
+ * @license Highcharts JS v4.1.10 (2015-12-07)
3
3
  * Plugin for displaying a message when there is no data visible in chart.
4
4
  *
5
5
  * (c) 2010-2014 Highsoft AS
@@ -8,7 +8,13 @@
8
8
  * License: www.highcharts.com/license
9
9
  */
10
10
 
11
- (function (H) {
11
+ (function (factory) {
12
+ if (typeof module === 'object' && module.exports) {
13
+ module.exports = factory;
14
+ } else {
15
+ factory(Highcharts);
16
+ }
17
+ }(function (H) {
12
18
 
13
19
  var seriesTypes = H.seriesTypes,
14
20
  chartPrototype = H.Chart.prototype,
@@ -36,7 +42,7 @@
36
42
  fontSize: '12px',
37
43
  color: '#60606a'
38
44
  }
39
- // useHTML: false // docs
45
+ // useHTML: false
40
46
  };
41
47
 
42
48
  /**
@@ -134,4 +140,4 @@
134
140
  H.addEvent(chart, 'redraw', handleNoData);
135
141
  });
136
142
 
137
- }(Highcharts));
143
+ }));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v4.1.9 (2015-10-07)
2
+ * @license Highcharts JS v4.1.10 (2015-12-07)
3
3
  * Client side exporting module
4
4
  *
5
5
  * (c) 2015 Torstein Honsi / Oystein Moseng
@@ -7,271 +7,274 @@
7
7
  * License: www.highcharts.com/license
8
8
  */
9
9
 
10
- // JSLint options:
11
- /*global Highcharts, HighchartsAdapter, document, window, Blob, MSBlobBuilder */
12
-
13
- (function (Highcharts) {
14
-
15
- // Dummy object so we can reuse our canvas-tools.js without errors
16
- Highcharts.CanVGRenderer = {};
17
-
18
- /**
19
- * Add a new method to the Chart object to perform a local download
20
- */
21
- Highcharts.Chart.prototype.exportChartLocal = function (exportingOptions, chartOptions) {
22
- var chart = this,
23
- options = Highcharts.merge(chart.options.exporting, exportingOptions),
24
- webKit = navigator.userAgent.indexOf('WebKit') > -1 && navigator.userAgent.indexOf("Chrome") < 0, // Webkit and not chrome
25
- scale = options.scale || 2,
26
- chartCopyContainer,
27
- domurl = window.URL || window.webkitURL || window,
28
- images,
29
- imagesEmbedded = 0,
30
- el,
31
- i,
32
- l,
33
- fallbackToExportServer = function () {
34
- if (options.fallbackToExportServer === false) {
35
- throw 'Fallback to export server disabled';
36
- }
37
- chart.exportChart(options);
38
- },
39
- // Get data:URL from image URL
40
- // Pass in callbacks to handle results. finallyCallback is always called at the end of the process. Supplying this callback is optional.
41
- // All callbacks receive two arguments: imageURL, and callbackArgs. callbackArgs is used only by callbacks and can contain whatever.
42
- imageToDataUrl = function (imageURL, callbackArgs, successCallback, taintedCallback, noCanvasSupportCallback, failedLoadCallback, finallyCallback) {
43
- var img = new Image();
44
- if (!webKit) {
45
- img.crossOrigin = 'Anonymous'; // For some reason Safari chokes on this attribute
46
- }
47
- img.onload = function () {
48
- var canvas = document.createElement('canvas'),
49
- ctx = canvas.getContext && canvas.getContext('2d'),
50
- dataURL;
10
+ /*global MSBlobBuilder */
11
+ (function (factory) {
12
+ if (typeof module === 'object' && module.exports) {
13
+ module.exports = factory;
14
+ } else {
15
+ factory(Highcharts);
16
+ }
17
+ }(function (Highcharts) {
51
18
 
52
- if (!ctx) {
53
- noCanvasSupportCallback(imageURL, callbackArgs);
54
- } else {
55
- canvas.height = img.height * scale;
56
- canvas.width = img.width * scale;
57
- ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
19
+ // Dummy object so we can reuse our canvas-tools.js without errors
20
+ Highcharts.CanVGRenderer = {};
58
21
 
59
- // Now we try to get the contents of the canvas.
60
- try {
61
- dataURL = canvas.toDataURL();
62
- successCallback(dataURL, callbackArgs);
63
- } catch (e) {
64
- // Failed - either tainted canvas or something else went horribly wrong
65
- if (e.name === 'SecurityError' || e.name === 'SECURITY_ERR' || e.message === 'SecurityError') {
66
- taintedCallback(imageURL, callbackArgs);
67
- } else {
68
- throw e;
69
- }
70
- }
71
- }
72
- if (finallyCallback) {
73
- finallyCallback(imageURL, callbackArgs);
74
- }
75
- };
76
- img.onerror = function () {
77
- failedLoadCallback(imageURL, callbackArgs);
78
- if (finallyCallback) {
79
- finallyCallback(imageURL, callbackArgs);
22
+ /**
23
+ * Add a new method to the Chart object to perform a local download
24
+ */
25
+ Highcharts.Chart.prototype.exportChartLocal = function (exportingOptions, chartOptions) {
26
+ var chart = this,
27
+ options = Highcharts.merge(chart.options.exporting, exportingOptions),
28
+ webKit = navigator.userAgent.indexOf('WebKit') > -1 && navigator.userAgent.indexOf('Chrome') < 0, // Webkit and not chrome
29
+ scale = options.scale || 2,
30
+ chartCopyContainer,
31
+ domurl = window.URL || window.webkitURL || window,
32
+ images,
33
+ imagesEmbedded = 0,
34
+ el,
35
+ i,
36
+ l,
37
+ fallbackToExportServer = function () {
38
+ if (options.fallbackToExportServer === false) {
39
+ throw 'Fallback to export server disabled';
80
40
  }
81
- };
82
- img.src = imageURL;
83
- },
84
- // Get blob URL from SVG code. Falls back to normal data URI.
85
- svgToDataUrl = function (svg) {
86
- try {
87
- // Safari requires data URI since it doesn't allow navigation to blob URLs
88
- // Firefox has an issue with Blobs and internal references, leading to gradients not working using Blobs (#4550)
89
- if (!webKit && navigator.userAgent.toLowerCase().indexOf('firefox') < 0) {
90
- return domurl.createObjectURL(new Blob([svg], { type: 'image/svg+xml;charset-utf-16'}));
41
+ chart.exportChart(options);
42
+ },
43
+ // Get data:URL from image URL
44
+ // Pass in callbacks to handle results. finallyCallback is always called at the end of the process. Supplying this callback is optional.
45
+ // All callbacks receive two arguments: imageURL, and callbackArgs. callbackArgs is used only by callbacks and can contain whatever.
46
+ imageToDataUrl = function (imageURL, callbackArgs, successCallback, taintedCallback, noCanvasSupportCallback, failedLoadCallback, finallyCallback) {
47
+ var img = new Image();
48
+ if (!webKit) {
49
+ img.crossOrigin = 'Anonymous'; // For some reason Safari chokes on this attribute
91
50
  }
92
- } catch (e) {
93
- // Ignore
94
- }
95
- return 'data:image/svg+xml;charset=UTF-8,' + encodeURIComponent(svg);
96
- },
97
- // Download contents by dataURL/blob
98
- download = function (dataURL, extension) {
99
- var a = document.createElement('a'),
100
- filename = (options.filename || 'chart') + '.' + extension,
101
- windowRef;
51
+ img.onload = function () {
52
+ var canvas = document.createElement('canvas'),
53
+ ctx = canvas.getContext && canvas.getContext('2d'),
54
+ dataURL;
102
55
 
103
- // IE specific blob implementation
104
- if (navigator.msSaveOrOpenBlob) {
105
- navigator.msSaveOrOpenBlob(dataURL, filename);
106
- return;
107
- }
56
+ if (!ctx) {
57
+ noCanvasSupportCallback(imageURL, callbackArgs);
58
+ } else {
59
+ canvas.height = img.height * scale;
60
+ canvas.width = img.width * scale;
61
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
108
62
 
109
- // Try HTML5 download attr if supported
110
- if (typeof a.download !== 'undefined') {
111
- a.href = dataURL;
112
- a.download = filename; // HTML5 download attribute
113
- a.target = '_blank';
114
- document.body.appendChild(a);
115
- a.click();
116
- document.body.removeChild(a);
117
- } else {
118
- // No download attr, just opening data URI
63
+ // Now we try to get the contents of the canvas.
64
+ try {
65
+ dataURL = canvas.toDataURL();
66
+ successCallback(dataURL, callbackArgs);
67
+ } catch (e) {
68
+ // Failed - either tainted canvas or something else went horribly wrong
69
+ if (e.name === 'SecurityError' || e.name === 'SECURITY_ERR' || e.message === 'SecurityError') {
70
+ taintedCallback(imageURL, callbackArgs);
71
+ } else {
72
+ throw e;
73
+ }
74
+ }
75
+ }
76
+ if (finallyCallback) {
77
+ finallyCallback(imageURL, callbackArgs);
78
+ }
79
+ };
80
+ img.onerror = function () {
81
+ failedLoadCallback(imageURL, callbackArgs);
82
+ if (finallyCallback) {
83
+ finallyCallback(imageURL, callbackArgs);
84
+ }
85
+ };
86
+ img.src = imageURL;
87
+ },
88
+ // Get blob URL from SVG code. Falls back to normal data URI.
89
+ svgToDataUrl = function (svg) {
119
90
  try {
120
- windowRef = window.open(dataURL, 'chart');
121
- if (typeof windowRef === 'undefined' || windowRef === null) {
122
- throw 1;
91
+ // Safari requires data URI since it doesn't allow navigation to blob URLs
92
+ // Firefox has an issue with Blobs and internal references, leading to gradients not working using Blobs (#4550)
93
+ if (!webKit && navigator.userAgent.toLowerCase().indexOf('firefox') < 0) {
94
+ return domurl.createObjectURL(new Blob([svg], { type: 'image/svg+xml;charset-utf-16' }));
123
95
  }
124
96
  } catch (e) {
125
- // window.open failed, trying location.href
126
- window.location.href = dataURL;
97
+ // Ignore
127
98
  }
128
- }
129
- },
130
- // Get data URL to an image of the chart and call download on it
131
- initiateDownload = function () {
132
- var svgurl,
133
- blob,
134
- svg = chart.sanitizeSVG(chartCopyContainer.innerHTML); // SVG of chart copy
99
+ return 'data:image/svg+xml;charset=UTF-8,' + encodeURIComponent(svg);
100
+ },
101
+ // Download contents by dataURL/blob
102
+ download = function (dataURL, extension) {
103
+ var a = document.createElement('a'),
104
+ filename = (options.filename || 'chart') + '.' + extension,
105
+ windowRef;
135
106
 
136
- // Initiate download depending on file type
137
- if (options && options.type === 'image/svg+xml') {
138
- // SVG download. In this case, we want to use Microsoft specific Blob if available
139
- try {
140
- if (navigator.msSaveOrOpenBlob) {
141
- blob = new MSBlobBuilder();
142
- blob.append(svg);
143
- svgurl = blob.getBlob('image/svg+xml');
144
- } else {
145
- svgurl = svgToDataUrl(svg);
146
- }
147
- download(svgurl, 'svg');
148
- } catch (e) {
149
- fallbackToExportServer();
107
+ // IE specific blob implementation
108
+ if (navigator.msSaveOrOpenBlob) {
109
+ navigator.msSaveOrOpenBlob(dataURL, filename);
110
+ return;
150
111
  }
151
- } else {
152
- // PNG download - create bitmap from SVG
153
-
154
- // First, try to get PNG by rendering on canvas
155
- svgurl = svgToDataUrl(svg);
156
- imageToDataUrl(svgurl, { /* args */ }, function (imageURL) {
157
- // Success
112
+
113
+ // Try HTML5 download attr if supported
114
+ if (a.download !== undefined) {
115
+ a.href = dataURL;
116
+ a.download = filename; // HTML5 download attribute
117
+ a.target = '_blank';
118
+ document.body.appendChild(a);
119
+ a.click();
120
+ document.body.removeChild(a);
121
+ } else {
122
+ // No download attr, just opening data URI
158
123
  try {
159
- download(imageURL, 'png');
124
+ windowRef = window.open(dataURL, 'chart');
125
+ if (windowRef === undefined || windowRef === null) {
126
+ throw 1;
127
+ }
160
128
  } catch (e) {
161
- fallbackToExportServer();
129
+ // window.open failed, trying location.href
130
+ window.location.href = dataURL;
162
131
  }
163
- }, function () {
164
- // Failed due to tainted canvas
165
- // Create new and untainted canvas
166
- var canvas = document.createElement('canvas'),
167
- ctx = canvas.getContext('2d'),
168
- imageWidth = svg.match(/^<svg[^>]*width\s*=\s*\"?(\d+)\"?[^>]*>/)[1] * scale,
169
- imageHeight = svg.match(/^<svg[^>]*height\s*=\s*\"?(\d+)\"?[^>]*>/)[1] * scale,
170
- downloadWithCanVG = function () {
171
- ctx.drawSvg(svg, 0, 0, imageWidth, imageHeight);
172
- try {
173
- download(navigator.msSaveOrOpenBlob ? canvas.msToBlob() : canvas.toDataURL('image/png'), 'png');
174
- } catch (e) {
175
- fallbackToExportServer();
176
- }
177
- };
132
+ }
133
+ },
134
+ // Get data URL to an image of the chart and call download on it
135
+ initiateDownload = function () {
136
+ var svgurl,
137
+ blob,
138
+ svg = chart.sanitizeSVG(chartCopyContainer.innerHTML); // SVG of chart copy
178
139
 
179
- canvas.width = imageWidth;
180
- canvas.height = imageHeight;
181
- if (window.canvg) {
182
- // Use preloaded canvg
183
- downloadWithCanVG();
184
- } else {
185
- // Must load canVG first
186
- chart.showLoading();
187
- HighchartsAdapter.getScript(Highcharts.getOptions().global.canvasToolsURL, function () {
188
- chart.hideLoading();
189
- downloadWithCanVG();
190
- });
191
- }
192
- },
193
- // No canvas support
194
- fallbackToExportServer,
195
- // Failed to load image
196
- fallbackToExportServer,
197
- // Finally
198
- function () {
140
+ // Initiate download depending on file type
141
+ if (options && options.type === 'image/svg+xml') {
142
+ // SVG download. In this case, we want to use Microsoft specific Blob if available
199
143
  try {
200
- domurl.revokeObjectURL(svgurl);
144
+ if (navigator.msSaveOrOpenBlob) {
145
+ blob = new MSBlobBuilder();
146
+ blob.append(svg);
147
+ svgurl = blob.getBlob('image/svg+xml');
148
+ } else {
149
+ svgurl = svgToDataUrl(svg);
150
+ }
151
+ download(svgurl, 'svg');
201
152
  } catch (e) {
202
- // Ignore
153
+ fallbackToExportServer();
203
154
  }
204
- });
205
- }
206
- };
155
+ } else {
156
+ // PNG download - create bitmap from SVG
157
+
158
+ // First, try to get PNG by rendering on canvas
159
+ svgurl = svgToDataUrl(svg);
160
+ imageToDataUrl(svgurl, { /* args */ }, function (imageURL) {
161
+ // Success
162
+ try {
163
+ download(imageURL, 'png');
164
+ } catch (e) {
165
+ fallbackToExportServer();
166
+ }
167
+ }, function () {
168
+ // Failed due to tainted canvas
169
+ // Create new and untainted canvas
170
+ var canvas = document.createElement('canvas'),
171
+ ctx = canvas.getContext('2d'),
172
+ imageWidth = svg.match(/^<svg[^>]*width\s*=\s*\"?(\d+)\"?[^>]*>/)[1] * scale,
173
+ imageHeight = svg.match(/^<svg[^>]*height\s*=\s*\"?(\d+)\"?[^>]*>/)[1] * scale,
174
+ downloadWithCanVG = function () {
175
+ ctx.drawSvg(svg, 0, 0, imageWidth, imageHeight);
176
+ try {
177
+ download(navigator.msSaveOrOpenBlob ? canvas.msToBlob() : canvas.toDataURL('image/png'), 'png');
178
+ } catch (e) {
179
+ fallbackToExportServer();
180
+ }
181
+ };
207
182
 
208
- // Hook into getSVG to get a copy of the chart copy's container
209
- Highcharts.wrap(Highcharts.Chart.prototype, 'getChartHTML', function (proceed) {
210
- chartCopyContainer = this.container.cloneNode(true);
211
- return proceed.apply(this, Array.prototype.slice.call(arguments, 1));
212
- });
183
+ canvas.width = imageWidth;
184
+ canvas.height = imageHeight;
185
+ if (window.canvg) {
186
+ // Use preloaded canvg
187
+ downloadWithCanVG();
188
+ } else {
189
+ // Must load canVG first
190
+ chart.showLoading();
191
+ Highcharts.getScript(Highcharts.getOptions().global.canvasToolsURL, function () {
192
+ chart.hideLoading();
193
+ downloadWithCanVG();
194
+ });
195
+ }
196
+ },
197
+ // No canvas support
198
+ fallbackToExportServer,
199
+ // Failed to load image
200
+ fallbackToExportServer,
201
+ // Finally
202
+ function () {
203
+ try {
204
+ domurl.revokeObjectURL(svgurl);
205
+ } catch (e) {
206
+ // Ignore
207
+ }
208
+ });
209
+ }
210
+ },
211
+ // Success handler, we converted image to base64!
212
+ embeddedSuccess = function (imageURL, callbackArgs) {
213
+ ++imagesEmbedded;
213
214
 
214
- // Trigger hook to get chart copy
215
- chart.getSVGForExport(options, chartOptions);
216
- images = chartCopyContainer.getElementsByTagName('image');
215
+ // Change image href in chart copy
216
+ callbackArgs.imageElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageURL);
217
217
 
218
- try {
219
- // If there are no images to embed, just go ahead and start the download process
220
- if (!images.length) {
221
- initiateDownload();
222
- }
218
+ // Start download when done with the last image
219
+ if (imagesEmbedded === images.length) {
220
+ initiateDownload();
221
+ }
222
+ };
223
223
 
224
- // Success handler, we converted image to base64!
225
- function embeddedSuccess(imageURL, callbackArgs) {
226
- ++imagesEmbedded;
224
+ // Hook into getSVG to get a copy of the chart copy's container
225
+ Highcharts.wrap(Highcharts.Chart.prototype, 'getChartHTML', function (proceed) {
226
+ chartCopyContainer = this.container.cloneNode(true);
227
+ return proceed.apply(this, Array.prototype.slice.call(arguments, 1));
228
+ });
227
229
 
228
- // Change image href in chart copy
229
- callbackArgs.imageElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageURL);
230
+ // Trigger hook to get chart copy
231
+ chart.getSVGForExport(options, chartOptions);
232
+ images = chartCopyContainer.getElementsByTagName('image');
230
233
 
231
- // Start download when done with the last image
232
- if (imagesEmbedded === images.length) {
234
+ try {
235
+ // If there are no images to embed, just go ahead and start the download process
236
+ if (!images.length) {
233
237
  initiateDownload();
234
238
  }
235
- }
236
239
 
237
- // Go through the images we want to embed
238
- for (i = 0, l = images.length; i < l; ++i) {
239
- el = images[i];
240
- imageToDataUrl(el.getAttributeNS('http://www.w3.org/1999/xlink', 'href'), { imageElement: el },
241
- embeddedSuccess,
242
- // Tainted canvas
243
- fallbackToExportServer,
244
- // No canvas support
245
- fallbackToExportServer,
246
- // Failed to load source
247
- fallbackToExportServer
248
- );
240
+ // Go through the images we want to embed
241
+ for (i = 0, l = images.length; i < l; ++i) {
242
+ el = images[i];
243
+ imageToDataUrl(el.getAttributeNS('http://www.w3.org/1999/xlink', 'href'), { imageElement: el },
244
+ embeddedSuccess,
245
+ // Tainted canvas
246
+ fallbackToExportServer,
247
+ // No canvas support
248
+ fallbackToExportServer,
249
+ // Failed to load source
250
+ fallbackToExportServer
251
+ );
252
+ }
253
+ } catch (e) {
254
+ fallbackToExportServer();
249
255
  }
250
- } catch (e) {
251
- fallbackToExportServer();
252
- }
253
- };
256
+ };
254
257
 
255
- // Extend the default options to use the local exporter logic
256
- Highcharts.getOptions().exporting.buttons.contextButton.menuItems = [{
257
- textKey: 'printChart',
258
- onclick: function () {
259
- this.print();
260
- }
261
- }, {
262
- separator: true
263
- }, {
264
- textKey: 'downloadPNG',
265
- onclick: function () {
266
- this.exportChartLocal();
267
- }
268
- }, {
269
- textKey: 'downloadSVG',
270
- onclick: function () {
271
- this.exportChartLocal({
272
- type: 'image/svg+xml'
273
- });
274
- }
275
- }];
258
+ // Extend the default options to use the local exporter logic
259
+ Highcharts.getOptions().exporting.buttons.contextButton.menuItems = [{
260
+ textKey: 'printChart',
261
+ onclick: function () {
262
+ this.print();
263
+ }
264
+ }, {
265
+ separator: true
266
+ }, {
267
+ textKey: 'downloadPNG',
268
+ onclick: function () {
269
+ this.exportChartLocal();
270
+ }
271
+ }, {
272
+ textKey: 'downloadSVG',
273
+ onclick: function () {
274
+ this.exportChartLocal({
275
+ type: 'image/svg+xml'
276
+ });
277
+ }
278
+ }];
276
279
 
277
- }(Highcharts));
280
+ }));