highstock-rails 1.3.10 → 2.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/images/highstock/meteogram-symbols-30px.png +0 -0
  4. data/app/assets/javascripts/highstock.js +418 -369
  5. data/app/assets/javascripts/highstock/adapters/standalone-framework.js +12 -12
  6. data/app/assets/javascripts/highstock/adapters/standalone-framework.src.js +635 -0
  7. data/app/assets/javascripts/highstock/highcharts-3d.js +48 -0
  8. data/app/assets/javascripts/highstock/highcharts-3d.src.js +1711 -0
  9. data/app/assets/javascripts/highstock/highcharts-more.js +49 -45
  10. data/app/assets/javascripts/highstock/highstock-all.js +637 -0
  11. data/app/assets/javascripts/highstock/modules/boost.js +12 -0
  12. data/app/assets/javascripts/highstock/modules/boost.src.js +591 -0
  13. data/app/assets/javascripts/highstock/modules/canvas-tools.js +9 -9
  14. data/app/assets/javascripts/highstock/modules/canvas-tools.src.js +3114 -0
  15. data/app/assets/javascripts/highstock/modules/data.js +20 -10
  16. data/app/assets/javascripts/highstock/modules/data.src.js +957 -0
  17. data/app/assets/javascripts/highstock/modules/drilldown.js +17 -14
  18. data/app/assets/javascripts/highstock/modules/drilldown.src.js +717 -0
  19. data/app/assets/javascripts/highstock/modules/exporting.js +17 -15
  20. data/app/assets/javascripts/highstock/modules/exporting.src.js +780 -0
  21. data/app/assets/javascripts/highstock/modules/funnel.js +5 -5
  22. data/app/assets/javascripts/highstock/modules/funnel.src.js +322 -0
  23. data/app/assets/javascripts/highstock/modules/heatmap.js +23 -2
  24. data/app/assets/javascripts/highstock/modules/heatmap.src.js +711 -0
  25. data/app/assets/javascripts/highstock/modules/no-data-to-display.js +4 -4
  26. data/app/assets/javascripts/highstock/modules/no-data-to-display.src.js +143 -0
  27. data/app/assets/javascripts/highstock/modules/offline-exporting.js +14 -0
  28. data/app/assets/javascripts/highstock/modules/offline-exporting.src.js +280 -0
  29. data/app/assets/javascripts/highstock/modules/solid-gauge.js +14 -0
  30. data/app/assets/javascripts/highstock/modules/solid-gauge.src.js +273 -0
  31. data/app/assets/javascripts/highstock/modules/treemap.js +30 -0
  32. data/app/assets/javascripts/highstock/modules/treemap.src.js +868 -0
  33. data/app/assets/javascripts/highstock/themes/dark-blue.js +1 -1
  34. data/app/assets/javascripts/highstock/themes/dark-green.js +1 -1
  35. data/app/assets/javascripts/highstock/themes/dark-unica.js +213 -0
  36. data/app/assets/javascripts/highstock/themes/gray.js +1 -1
  37. data/app/assets/javascripts/highstock/themes/grid-light.js +74 -0
  38. data/app/assets/javascripts/highstock/themes/sand-signika.js +104 -0
  39. data/lib/highstock/rails/version.rb +1 -1
  40. metadata +26 -7
  41. data/app/assets/javascripts/highstock/adapters/mootools-adapter.js +0 -13
  42. data/app/assets/javascripts/highstock/adapters/prototype-adapter.js +0 -15
  43. data/app/assets/javascripts/highstock/modules/annotations.js +0 -7
  44. data/app/assets/javascripts/highstock/modules/map.js +0 -41
@@ -1,5 +1,5 @@
1
1
  /*
2
- Highstock JS v1.3.10 (2014-03-10)
2
+ Highstock JS v2.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
@@ -7,6 +7,6 @@
7
7
 
8
8
  License: www.highcharts.com/license
9
9
  */
10
- (function(c){function f(){return!!this.points.length}function g(){this.hasData()?this.hideNoData():this.showNoData()}var d=c.seriesTypes,e=c.Chart.prototype,h=c.getOptions(),i=c.extend;i(h.lang,{noData:"No data to display"});h.noData={position:{x:0,y:0,align:"center",verticalAlign:"middle"},attr:{},style:{fontWeight:"bold",fontSize:"12px",color:"#60606a"}};if(d.pie)d.pie.prototype.hasData=f;if(d.gauge)d.gauge.prototype.hasData=f;if(d.waterfall)d.waterfall.prototype.hasData=f;c.Series.prototype.hasData=
11
- function(){return this.dataMax!==void 0&&this.dataMin!==void 0};e.showNoData=function(a){var b=this.options,a=a||b.lang.noData,b=b.noData;if(!this.noDataLabel)this.noDataLabel=this.renderer.label(a,0,0,null,null,null,null,null,"no-data").attr(b.attr).css(b.style).add(),this.noDataLabel.align(i(this.noDataLabel.getBBox(),b.position),!1,"plotBox")};e.hideNoData=function(){if(this.noDataLabel)this.noDataLabel=this.noDataLabel.destroy()};e.hasData=function(){for(var a=this.series,b=a.length;b--;)if(a[b].hasData()&&
12
- !a[b].options.isInternal)return!0;return!1};e.callbacks.push(function(a){c.addEvent(a,"load",g);c.addEvent(a,"redraw",g)})})(Highcharts);
10
+ (function(a){typeof module==="object"&&module.exports?module.exports=a:a(Highcharts)})(function(a){function h(){return!!this.points.length}function d(){this.hasData()?this.hideNoData():this.showNoData()}var e=a.seriesTypes,c=a.Chart.prototype,f=a.getOptions(),g=a.extend,i=a.each;g(f.lang,{noData:"No data to display"});f.noData={position:{x:0,y:0,align:"center",verticalAlign:"middle"},attr:{},style:{fontWeight:"bold",fontSize:"12px",color:"#60606a"}};i(["pie","gauge","waterfall","bubble"],function(b){if(e[b])e[b].prototype.hasData=
11
+ h});a.Series.prototype.hasData=function(){return this.visible&&this.dataMax!==void 0&&this.dataMin!==void 0};c.showNoData=function(b){var a=this.options,b=b||a.lang.noData,a=a.noData;if(!this.noDataLabel)this.noDataLabel=this.renderer.label(b,0,0,null,null,null,a.useHTML,null,"no-data").attr(a.attr).css(a.style).add(),this.noDataLabel.align(g(this.noDataLabel.getBBox(),a.position),!1,"plotBox")};c.hideNoData=function(){if(this.noDataLabel)this.noDataLabel=this.noDataLabel.destroy()};c.hasData=function(){for(var a=
12
+ this.series,c=a.length;c--;)if(a[c].hasData()&&!a[c].options.isInternal)return!0;return!1};c.callbacks.push(function(b){a.addEvent(b,"load",d);a.addEvent(b,"redraw",d)})});
@@ -0,0 +1,143 @@
1
+ /**
2
+ * @license Highstock JS v2.1.10 (2015-12-07)
3
+ * Plugin for displaying a message when there is no data visible in chart.
4
+ *
5
+ * (c) 2010-2014 Highsoft AS
6
+ * Author: Oystein Moseng
7
+ *
8
+ * License: www.highcharts.com/license
9
+ */
10
+
11
+ (function (factory) {
12
+ if (typeof module === 'object' && module.exports) {
13
+ module.exports = factory;
14
+ } else {
15
+ factory(Highcharts);
16
+ }
17
+ }(function (H) {
18
+
19
+ var seriesTypes = H.seriesTypes,
20
+ chartPrototype = H.Chart.prototype,
21
+ defaultOptions = H.getOptions(),
22
+ extend = H.extend,
23
+ each = H.each;
24
+
25
+ // Add language option
26
+ extend(defaultOptions.lang, {
27
+ noData: 'No data to display'
28
+ });
29
+
30
+ // Add default display options for message
31
+ defaultOptions.noData = {
32
+ position: {
33
+ x: 0,
34
+ y: 0,
35
+ align: 'center',
36
+ verticalAlign: 'middle'
37
+ },
38
+ attr: {
39
+ },
40
+ style: {
41
+ fontWeight: 'bold',
42
+ fontSize: '12px',
43
+ color: '#60606a'
44
+ }
45
+ // useHTML: false
46
+ };
47
+
48
+ /**
49
+ * Define hasData functions for series. These return true if there are data points on this series within the plot area
50
+ */
51
+ function hasDataPie() {
52
+ return !!this.points.length; /* != 0 */
53
+ }
54
+
55
+ each(['pie', 'gauge', 'waterfall', 'bubble'], function (type) {
56
+ if (seriesTypes[type]) {
57
+ seriesTypes[type].prototype.hasData = hasDataPie;
58
+ }
59
+ });
60
+
61
+ H.Series.prototype.hasData = function () {
62
+ return this.visible && this.dataMax !== undefined && this.dataMin !== undefined; // #3703
63
+ };
64
+
65
+ /**
66
+ * Display a no-data message.
67
+ *
68
+ * @param {String} str An optional message to show in place of the default one
69
+ */
70
+ chartPrototype.showNoData = function (str) {
71
+ var chart = this,
72
+ options = chart.options,
73
+ text = str || options.lang.noData,
74
+ noDataOptions = options.noData;
75
+
76
+ if (!chart.noDataLabel) {
77
+ chart.noDataLabel = chart.renderer
78
+ .label(
79
+ text,
80
+ 0,
81
+ 0,
82
+ null,
83
+ null,
84
+ null,
85
+ noDataOptions.useHTML,
86
+ null,
87
+ 'no-data'
88
+ )
89
+ .attr(noDataOptions.attr)
90
+ .css(noDataOptions.style)
91
+ .add();
92
+ chart.noDataLabel.align(extend(chart.noDataLabel.getBBox(), noDataOptions.position), false, 'plotBox');
93
+ }
94
+ };
95
+
96
+ /**
97
+ * Hide no-data message
98
+ */
99
+ chartPrototype.hideNoData = function () {
100
+ var chart = this;
101
+ if (chart.noDataLabel) {
102
+ chart.noDataLabel = chart.noDataLabel.destroy();
103
+ }
104
+ };
105
+
106
+ /**
107
+ * Returns true if there are data points within the plot area now
108
+ */
109
+ chartPrototype.hasData = function () {
110
+ var chart = this,
111
+ series = chart.series,
112
+ i = series.length;
113
+
114
+ while (i--) {
115
+ if (series[i].hasData() && !series[i].options.isInternal) {
116
+ return true;
117
+ }
118
+ }
119
+
120
+ return false;
121
+ };
122
+
123
+ /**
124
+ * Show no-data message if there is no data in sight. Otherwise, hide it.
125
+ */
126
+ function handleNoData() {
127
+ var chart = this;
128
+ if (chart.hasData()) {
129
+ chart.hideNoData();
130
+ } else {
131
+ chart.showNoData();
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Add event listener to handle automatic display of no-data message
137
+ */
138
+ chartPrototype.callbacks.push(function (chart) {
139
+ H.addEvent(chart, 'load', handleNoData);
140
+ H.addEvent(chart, 'redraw', handleNoData);
141
+ });
142
+
143
+ }));
@@ -0,0 +1,14 @@
1
+ /*
2
+ Highstock JS v2.1.10 (2015-12-07)
3
+ Client side exporting module
4
+
5
+ (c) 2015 Torstein Honsi / Oystein Moseng
6
+
7
+ License: www.highcharts.com/license
8
+ */
9
+ (function(c){typeof module==="object"&&module.exports?module.exports=c:c(Highcharts)})(function(c){c.CanVGRenderer={};c.Chart.prototype.exportChartLocal=function(w,x){var i=this,e=c.merge(i.options.exporting,w),p=navigator.userAgent.indexOf("WebKit")>-1&&navigator.userAgent.indexOf("Chrome")<0,l=e.scale||2,m,q=window.URL||window.webkitURL||window,h,r=0,n,f,s,b=function(){if(e.fallbackToExportServer===!1)throw"Fallback to export server disabled";i.exportChart(e)},t=function(a,g,d,c,k,b,e){var j=new Image;
10
+ if(!p)j.crossOrigin="Anonymous";j.onload=function(){var b=document.createElement("canvas"),i=b.getContext&&b.getContext("2d"),h;if(i){b.height=j.height*l;b.width=j.width*l;i.drawImage(j,0,0,b.width,b.height);try{h=b.toDataURL(),d(h,g)}catch(f){if(f.name==="SecurityError"||f.name==="SECURITY_ERR"||f.message==="SecurityError")c(a,g);else throw f;}}else k(a,g);e&&e(a,g)};j.onerror=function(){b(a,g);e&&e(a,g)};j.src=a},u=function(a){try{if(!p&&navigator.userAgent.toLowerCase().indexOf("firefox")<0)return q.createObjectURL(new Blob([a],
11
+ {type:"image/svg+xml;charset-utf-16"}))}catch(b){}return"data:image/svg+xml;charset=UTF-8,"+encodeURIComponent(a)},o=function(a,b){var d=document.createElement("a"),c=(e.filename||"chart")+"."+b,k;if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(a,c);else if(d.download!==void 0)d.href=a,d.download=c,d.target="_blank",document.body.appendChild(d),d.click(),document.body.removeChild(d);else try{if(k=window.open(a,"chart"),k===void 0||k===null)throw 1;}catch(i){window.location.href=a}},v=function(){var a,
12
+ g,d=i.sanitizeSVG(m.innerHTML);if(e&&e.type==="image/svg+xml")try{navigator.msSaveOrOpenBlob?(g=new MSBlobBuilder,g.append(d),a=g.getBlob("image/svg+xml")):a=u(d),o(a,"svg")}catch(f){b()}else a=u(d),t(a,{},function(a){try{o(a,"png")}catch(c){b()}},function(){var a=document.createElement("canvas"),e=a.getContext("2d"),g=d.match(/^<svg[^>]*width\s*=\s*\"?(\d+)\"?[^>]*>/)[1]*l,f=d.match(/^<svg[^>]*height\s*=\s*\"?(\d+)\"?[^>]*>/)[1]*l,h=function(){e.drawSvg(d,0,0,g,f);try{o(navigator.msSaveOrOpenBlob?
13
+ a.msToBlob():a.toDataURL("image/png"),"png")}catch(c){b()}};a.width=g;a.height=f;window.canvg?h():(i.showLoading(),c.getScript(c.getOptions().global.canvasToolsURL,function(){i.hideLoading();h()}))},b,b,function(){try{q.revokeObjectURL(a)}catch(b){}})},y=function(a,b){++r;b.imageElement.setAttributeNS("http://www.w3.org/1999/xlink","href",a);r===h.length&&v()};c.wrap(c.Chart.prototype,"getChartHTML",function(a){m=this.container.cloneNode(!0);return a.apply(this,Array.prototype.slice.call(arguments,
14
+ 1))});i.getSVGForExport(e,x);h=m.getElementsByTagName("image");try{h.length||v();for(f=0,s=h.length;f<s;++f)n=h[f],t(n.getAttributeNS("http://www.w3.org/1999/xlink","href"),{imageElement:n},y,b,b,b)}catch(z){b()}};c.getOptions().exporting.buttons.contextButton.menuItems=[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChartLocal()}},{textKey:"downloadSVG",onclick:function(){this.exportChartLocal({type:"image/svg+xml"})}}]});
@@ -0,0 +1,280 @@
1
+ /**
2
+ * @license Highstock JS v2.1.10 (2015-12-07)
3
+ * Client side exporting module
4
+ *
5
+ * (c) 2015 Torstein Honsi / Oystein Moseng
6
+ *
7
+ * License: www.highcharts.com/license
8
+ */
9
+
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) {
18
+
19
+ // Dummy object so we can reuse our canvas-tools.js without errors
20
+ Highcharts.CanVGRenderer = {};
21
+
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';
40
+ }
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
50
+ }
51
+ img.onload = function () {
52
+ var canvas = document.createElement('canvas'),
53
+ ctx = canvas.getContext && canvas.getContext('2d'),
54
+ dataURL;
55
+
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);
62
+
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) {
90
+ try {
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' }));
95
+ }
96
+ } catch (e) {
97
+ // Ignore
98
+ }
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;
106
+
107
+ // IE specific blob implementation
108
+ if (navigator.msSaveOrOpenBlob) {
109
+ navigator.msSaveOrOpenBlob(dataURL, filename);
110
+ return;
111
+ }
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
123
+ try {
124
+ windowRef = window.open(dataURL, 'chart');
125
+ if (windowRef === undefined || windowRef === null) {
126
+ throw 1;
127
+ }
128
+ } catch (e) {
129
+ // window.open failed, trying location.href
130
+ window.location.href = dataURL;
131
+ }
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
139
+
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
143
+ try {
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');
152
+ } catch (e) {
153
+ fallbackToExportServer();
154
+ }
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
+ };
182
+
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;
214
+
215
+ // Change image href in chart copy
216
+ callbackArgs.imageElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageURL);
217
+
218
+ // Start download when done with the last image
219
+ if (imagesEmbedded === images.length) {
220
+ initiateDownload();
221
+ }
222
+ };
223
+
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
+ });
229
+
230
+ // Trigger hook to get chart copy
231
+ chart.getSVGForExport(options, chartOptions);
232
+ images = chartCopyContainer.getElementsByTagName('image');
233
+
234
+ try {
235
+ // If there are no images to embed, just go ahead and start the download process
236
+ if (!images.length) {
237
+ initiateDownload();
238
+ }
239
+
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();
255
+ }
256
+ };
257
+
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
+ }];
279
+
280
+ }));