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.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +55 -0
- data/app/assets/images/highcharts/search.png +0 -0
- data/app/assets/javascripts/highcharts.js +18962 -18796
- data/app/assets/javascripts/highcharts/adapters/standalone-framework.js +152 -131
- data/app/assets/javascripts/highcharts/highcharts-3d.js +1702 -1561
- data/app/assets/javascripts/highcharts/highcharts-more.js +2655 -2639
- data/app/assets/javascripts/highcharts/modules/boost.js +72 -35
- data/app/assets/javascripts/highcharts/modules/broken-axis.js +45 -32
- data/app/assets/javascripts/highcharts/modules/canvas-tools.js +8 -7
- data/app/assets/javascripts/highcharts/modules/data.js +646 -642
- data/app/assets/javascripts/highcharts/modules/drilldown.js +15 -11
- data/app/assets/javascripts/highcharts/modules/exporting.js +17 -12
- data/app/assets/javascripts/highcharts/modules/funnel.js +19 -12
- data/app/assets/javascripts/highcharts/modules/heatmap.js +702 -696
- data/app/assets/javascripts/highcharts/modules/no-data-to-display.js +10 -4
- data/app/assets/javascripts/highcharts/modules/offline-exporting.js +241 -238
- data/app/assets/javascripts/highcharts/modules/solid-gauge.js +12 -9
- data/app/assets/javascripts/highcharts/modules/treemap.js +67 -86
- data/app/assets/javascripts/highcharts/themes/grid-light.js +1 -1
- data/app/assets/javascripts/highcharts/themes/sand-signika.js +1 -1
- data/lib/highcharts/version.rb +1 -1
- metadata +3 -2
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            /**
         | 
| 2 | 
            -
             * @license Highcharts JS v4.1. | 
| 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 ( | 
| 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 | 
| 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 | 
            -
            } | 
| 143 | 
            +
            }));
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            /**
         | 
| 2 | 
            -
             * @license Highcharts JS v4.1. | 
| 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 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 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 | 
            -
             | 
| 53 | 
            -
             | 
| 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 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 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 | 
            -
            			 | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
            			 | 
| 87 | 
            -
            				 | 
| 88 | 
            -
            				 | 
| 89 | 
            -
             | 
| 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 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 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 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 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 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 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 | 
            -
            					 | 
| 121 | 
            -
            					 | 
| 122 | 
            -
             | 
| 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 | 
            -
            					//  | 
| 126 | 
            -
            					window.location.href = dataURL;
         | 
| 97 | 
            +
            					// Ignore
         | 
| 127 98 | 
             
            				}
         | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 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 | 
            -
             | 
| 137 | 
            -
             | 
| 138 | 
            -
             | 
| 139 | 
            -
             | 
| 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 | 
            -
             | 
| 152 | 
            -
            				//  | 
| 153 | 
            -
            				
         | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
            					 | 
| 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 | 
            -
            						 | 
| 124 | 
            +
            						windowRef = window.open(dataURL, 'chart');
         | 
| 125 | 
            +
            						if (windowRef === undefined || windowRef === null) {
         | 
| 126 | 
            +
            							throw 1;
         | 
| 127 | 
            +
            						}
         | 
| 160 128 | 
             
            					} catch (e) {
         | 
| 161 | 
            -
            						 | 
| 129 | 
            +
            						// window.open failed, trying location.href
         | 
| 130 | 
            +
            						window.location.href = dataURL;
         | 
| 162 131 | 
             
            					}
         | 
| 163 | 
            -
            				} | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
             | 
| 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 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
            					 | 
| 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 | 
            -
            						 | 
| 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 | 
            -
            						 | 
| 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 | 
            -
             | 
| 209 | 
            -
             | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 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 | 
            -
             | 
| 215 | 
            -
             | 
| 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 | 
            -
             | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 218 | 
            +
            				// Start download when done with the last image
         | 
| 219 | 
            +
            				if (imagesEmbedded === images.length) {
         | 
| 220 | 
            +
            					initiateDownload();
         | 
| 221 | 
            +
            				}
         | 
| 222 | 
            +
            			};
         | 
| 223 223 |  | 
| 224 | 
            -
            		//  | 
| 225 | 
            -
            		function  | 
| 226 | 
            -
            			 | 
| 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 | 
            -
             | 
| 229 | 
            -
             | 
| 230 | 
            +
            		// Trigger hook to get chart copy
         | 
| 231 | 
            +
            		chart.getSVGForExport(options, chartOptions);
         | 
| 232 | 
            +
            		images = chartCopyContainer.getElementsByTagName('image');
         | 
| 230 233 |  | 
| 231 | 
            -
             | 
| 232 | 
            -
            			 | 
| 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 | 
            -
             | 
| 238 | 
            -
             | 
| 239 | 
            -
             | 
| 240 | 
            -
             | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 243 | 
            -
             | 
| 244 | 
            -
             | 
| 245 | 
            -
             | 
| 246 | 
            -
             | 
| 247 | 
            -
             | 
| 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 | 
            -
            	} | 
| 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 | 
            -
             | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 260 | 
            -
             | 
| 261 | 
            -
            }, {
         | 
| 262 | 
            -
             | 
| 263 | 
            -
            }, {
         | 
| 264 | 
            -
             | 
| 265 | 
            -
             | 
| 266 | 
            -
             | 
| 267 | 
            -
             | 
| 268 | 
            -
            }, {
         | 
| 269 | 
            -
             | 
| 270 | 
            -
             | 
| 271 | 
            -
             | 
| 272 | 
            -
             | 
| 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 | 
            -
            } | 
| 280 | 
            +
            }));
         |