exporting.src.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /**
  2. * @license Highcharts JS v4.1.5 (2015-04-13)
  3. * Exporting module
  4. *
  5. * (c) 2010-2014 Torstein Honsi
  6. *
  7. * License: www.highcharts.com/license
  8. */
  9. // JSLint options:
  10. /*global Highcharts, HighchartsAdapter, document, window, Math, setTimeout */
  11. (function (Highcharts) { // encapsulate
  12. // create shortcuts
  13. var Chart = Highcharts.Chart,
  14. addEvent = Highcharts.addEvent,
  15. removeEvent = Highcharts.removeEvent,
  16. fireEvent = HighchartsAdapter.fireEvent,
  17. createElement = Highcharts.createElement,
  18. discardElement = Highcharts.discardElement,
  19. css = Highcharts.css,
  20. merge = Highcharts.merge,
  21. each = Highcharts.each,
  22. extend = Highcharts.extend,
  23. splat = Highcharts.splat,
  24. math = Math,
  25. mathMax = math.max,
  26. doc = document,
  27. win = window,
  28. isTouchDevice = Highcharts.isTouchDevice,
  29. M = 'M',
  30. L = 'L',
  31. DIV = 'div',
  32. HIDDEN = 'hidden',
  33. NONE = 'none',
  34. PREFIX = 'highcharts-',
  35. ABSOLUTE = 'absolute',
  36. PX = 'px',
  37. UNDEFINED,
  38. symbols = Highcharts.Renderer.prototype.symbols,
  39. defaultOptions = Highcharts.getOptions(),
  40. buttonOffset;
  41. // Add language
  42. extend(defaultOptions.lang, {
  43. printChart: 'Print chart',
  44. downloadPNG: 'Download PNG image',
  45. downloadJPEG: 'Download JPEG image',
  46. downloadPDF: 'Download PDF document',
  47. downloadSVG: 'Download SVG vector image',
  48. contextButtonTitle: 'Chart context menu'
  49. });
  50. // Buttons and menus are collected in a separate config option set called 'navigation'.
  51. // This can be extended later to add control buttons like zoom and pan right click menus.
  52. defaultOptions.navigation = {
  53. menuStyle: {
  54. border: '1px solid #A0A0A0',
  55. background: '#FFFFFF',
  56. padding: '5px 0'
  57. },
  58. menuItemStyle: {
  59. padding: '0 10px',
  60. background: NONE,
  61. color: '#303030',
  62. fontSize: isTouchDevice ? '14px' : '11px'
  63. },
  64. menuItemHoverStyle: {
  65. background: '#4572A5',
  66. color: '#FFFFFF'
  67. },
  68. buttonOptions: {
  69. symbolFill: '#E0E0E0',
  70. symbolSize: 14,
  71. symbolStroke: '#666',
  72. symbolStrokeWidth: 3,
  73. symbolX: 12.5,
  74. symbolY: 10.5,
  75. align: 'right',
  76. buttonSpacing: 3,
  77. height: 22,
  78. // text: null,
  79. theme: {
  80. fill: 'white', // capture hover
  81. stroke: 'none'
  82. },
  83. verticalAlign: 'top',
  84. width: 24
  85. }
  86. };
  87. // Add the export related options
  88. defaultOptions.exporting = {
  89. //enabled: true,
  90. //filename: 'chart',
  91. type: 'image/png',
  92. url: 'http://export.highcharts.com/',
  93. //width: undefined,
  94. //scale: 2
  95. buttons: {
  96. contextButton: {
  97. menuClassName: PREFIX + 'contextmenu',
  98. //x: -10,
  99. symbol: 'menu',
  100. _titleKey: 'contextButtonTitle',
  101. menuItems: [{
  102. textKey: 'printChart',
  103. onclick: function () {
  104. this.print();
  105. }
  106. }, {
  107. separator: true
  108. }, {
  109. textKey: 'downloadPNG',
  110. onclick: function () {
  111. this.exportChart();
  112. }
  113. }, {
  114. textKey: 'downloadJPEG',
  115. onclick: function () {
  116. this.exportChart({
  117. type: 'image/jpeg'
  118. });
  119. }
  120. }, {
  121. textKey: 'downloadPDF',
  122. onclick: function () {
  123. this.exportChart({
  124. type: 'application/pdf'
  125. });
  126. }
  127. }, {
  128. textKey: 'downloadSVG',
  129. onclick: function () {
  130. this.exportChart({
  131. type: 'image/svg+xml'
  132. });
  133. }
  134. }
  135. // Enable this block to add "View SVG" to the dropdown menu
  136. /*
  137. ,{
  138. text: 'View SVG',
  139. onclick: function () {
  140. var svg = this.getSVG()
  141. .replace(/</g, '\n&lt;')
  142. .replace(/>/g, '&gt;');
  143. doc.body.innerHTML = '<pre>' + svg + '</pre>';
  144. }
  145. } // */
  146. ]
  147. }
  148. }
  149. };
  150. // Add the Highcharts.post utility
  151. Highcharts.post = function (url, data, formAttributes) {
  152. var name,
  153. form;
  154. // create the form
  155. form = createElement('form', merge({
  156. method: 'post',
  157. action: url,
  158. enctype: 'multipart/form-data'
  159. }, formAttributes), {
  160. display: NONE
  161. }, doc.body);
  162. // add the data
  163. for (name in data) {
  164. createElement('input', {
  165. type: HIDDEN,
  166. name: name,
  167. value: data[name]
  168. }, null, form);
  169. }
  170. // submit
  171. form.submit();
  172. // clean up
  173. discardElement(form);
  174. };
  175. extend(Chart.prototype, {
  176. /**
  177. * A collection of regex fixes on the produces SVG to account for expando properties,
  178. * browser bugs, VML problems and other. Returns a cleaned SVG.
  179. */
  180. sanitizeSVG: function (svg) {
  181. return svg
  182. .replace(/zIndex="[^"]+"/g, '')
  183. .replace(/isShadow="[^"]+"/g, '')
  184. .replace(/symbolName="[^"]+"/g, '')
  185. .replace(/jQuery[0-9]+="[^"]+"/g, '')
  186. .replace(/url\([^#]+#/g, 'url(#')
  187. .replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ')
  188. .replace(/ (NS[0-9]+\:)?href=/g, ' xlink:href=') // #3567
  189. .replace(/\n/, ' ')
  190. // Any HTML added to the container after the SVG (#894)
  191. .replace(/<\/svg>.*?$/, '</svg>')
  192. // Batik doesn't support rgba fills and strokes (#3095)
  193. .replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g, '$1="rgb($2)" $1-opacity="$3"')
  194. /* This fails in IE < 8
  195. .replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight
  196. return s2 +'.'+ s3[0];
  197. })*/
  198. // Replace HTML entities, issue #347
  199. .replace(/&nbsp;/g, '\u00A0') // no-break space
  200. .replace(/&shy;/g, '\u00AD') // soft hyphen
  201. // IE specific
  202. .replace(/<IMG /g, '<image ')
  203. .replace(/height=([^" ]+)/g, 'height="$1"')
  204. .replace(/width=([^" ]+)/g, 'width="$1"')
  205. .replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>')
  206. .replace(/ id=([^" >]+)/g, 'id="$1"') // #4003
  207. .replace(/class=([^" >]+)/g, 'class="$1"')
  208. .replace(/ transform /g, ' ')
  209. .replace(/:(path|rect)/g, '$1')
  210. .replace(/style="([^"]+)"/g, function (s) {
  211. return s.toLowerCase();
  212. });
  213. },
  214. /**
  215. * Return an SVG representation of the chart
  216. *
  217. * @param additionalOptions {Object} Additional chart options for the generated SVG representation
  218. */
  219. getSVG: function (additionalOptions) {
  220. var chart = this,
  221. chartCopy,
  222. sandbox,
  223. svg,
  224. seriesOptions,
  225. sourceWidth,
  226. sourceHeight,
  227. cssWidth,
  228. cssHeight,
  229. options = merge(chart.options, additionalOptions); // copy the options and add extra options
  230. // IE compatibility hack for generating SVG content that it doesn't really understand
  231. if (!doc.createElementNS) {
  232. /*jslint unparam: true*//* allow unused parameter ns in function below */
  233. doc.createElementNS = function (ns, tagName) {
  234. return doc.createElement(tagName);
  235. };
  236. /*jslint unparam: false*/
  237. }
  238. // create a sandbox where a new chart will be generated
  239. sandbox = createElement(DIV, null, {
  240. position: ABSOLUTE,
  241. top: '-9999em',
  242. width: chart.chartWidth + PX,
  243. height: chart.chartHeight + PX
  244. }, doc.body);
  245. // get the source size
  246. cssWidth = chart.renderTo.style.width;
  247. cssHeight = chart.renderTo.style.height;
  248. sourceWidth = options.exporting.sourceWidth ||
  249. options.chart.width ||
  250. (/px$/.test(cssWidth) && parseInt(cssWidth, 10)) ||
  251. 600;
  252. sourceHeight = options.exporting.sourceHeight ||
  253. options.chart.height ||
  254. (/px$/.test(cssHeight) && parseInt(cssHeight, 10)) ||
  255. 400;
  256. // override some options
  257. extend(options.chart, {
  258. animation: false,
  259. renderTo: sandbox,
  260. forExport: true,
  261. width: sourceWidth,
  262. height: sourceHeight
  263. });
  264. options.exporting.enabled = false; // hide buttons in print
  265. delete options.data; // #3004
  266. // prepare for replicating the chart
  267. options.series = [];
  268. each(chart.series, function (serie) {
  269. seriesOptions = merge(serie.options, {
  270. animation: false, // turn off animation
  271. enableMouseTracking: false,
  272. showCheckbox: false,
  273. visible: serie.visible
  274. });
  275. if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set
  276. options.series.push(seriesOptions);
  277. }
  278. });
  279. // Axis options must be merged in one by one, since it may be an array or an object (#2022, #3900)
  280. if (additionalOptions) {
  281. each(['xAxis', 'yAxis'], function (axisType) {
  282. each(splat(additionalOptions[axisType]), function (axisOptions, i) {
  283. options[axisType][i] = merge(options[axisType][i], axisOptions);
  284. });
  285. });
  286. }
  287. // generate the chart copy
  288. chartCopy = new Highcharts.Chart(options, chart.callback);
  289. // reflect axis extremes in the export
  290. each(['xAxis', 'yAxis'], function (axisType) {
  291. each(chart[axisType], function (axis, i) {
  292. var axisCopy = chartCopy[axisType][i],
  293. extremes = axis.getExtremes(),
  294. userMin = extremes.userMin,
  295. userMax = extremes.userMax;
  296. if (axisCopy && (userMin !== UNDEFINED || userMax !== UNDEFINED)) {
  297. axisCopy.setExtremes(userMin, userMax, true, false);
  298. }
  299. });
  300. });
  301. // get the SVG from the container's innerHTML
  302. svg = chartCopy.container.innerHTML;
  303. // free up memory
  304. options = null;
  305. chartCopy.destroy();
  306. discardElement(sandbox);
  307. // sanitize
  308. svg = this.sanitizeSVG(svg);
  309. // IE9 beta bugs with innerHTML. Test again with final IE9.
  310. svg = svg.replace(/(url\(#highcharts-[0-9]+)&quot;/g, '$1')
  311. .replace(/&quot;/g, "'");
  312. return svg;
  313. },
  314. getSVGForExport: function (options, chartOptions) {
  315. var chartExportingOptions = this.options.exporting;
  316. return this.getSVG(merge(
  317. { chart: { borderRadius: 0 } },
  318. chartExportingOptions.chartOptions,
  319. chartOptions,
  320. {
  321. exporting: {
  322. sourceWidth: (options && options.sourceWidth) || chartExportingOptions.sourceWidth,
  323. sourceHeight: (options && options.sourceHeight) || chartExportingOptions.sourceHeight
  324. }
  325. }
  326. ));
  327. },
  328. /**
  329. * Submit the SVG representation of the chart to the server
  330. * @param {Object} options Exporting options. Possible members are url, type, width and formAttributes.
  331. * @param {Object} chartOptions Additional chart options for the SVG representation of the chart
  332. */
  333. exportChart: function (options, chartOptions) {
  334. var svg = this.getSVGForExport(options, chartOptions);
  335. // merge the options
  336. options = merge(this.options.exporting, options);
  337. // do the post
  338. Highcharts.post(options.url, {
  339. filename: options.filename || 'chart',
  340. type: options.type,
  341. width: options.width || 0, // IE8 fails to post undefined correctly, so use 0
  342. scale: options.scale || 2,
  343. svg: svg
  344. }, options.formAttributes);
  345. },
  346. /**
  347. * Print the chart
  348. */
  349. print: function () {
  350. var chart = this,
  351. container = chart.container,
  352. origDisplay = [],
  353. origParent = container.parentNode,
  354. body = doc.body,
  355. childNodes = body.childNodes;
  356. if (chart.isPrinting) { // block the button while in printing mode
  357. return;
  358. }
  359. chart.isPrinting = true;
  360. fireEvent(chart, 'beforePrint');
  361. // hide all body content
  362. each(childNodes, function (node, i) {
  363. if (node.nodeType === 1) {
  364. origDisplay[i] = node.style.display;
  365. node.style.display = NONE;
  366. }
  367. });
  368. // pull out the chart
  369. body.appendChild(container);
  370. // print
  371. win.focus(); // #1510
  372. win.print();
  373. // allow the browser to prepare before reverting
  374. setTimeout(function () {
  375. // put the chart back in
  376. origParent.appendChild(container);
  377. // restore all body content
  378. each(childNodes, function (node, i) {
  379. if (node.nodeType === 1) {
  380. node.style.display = origDisplay[i];
  381. }
  382. });
  383. chart.isPrinting = false;
  384. fireEvent(chart, 'afterPrint');
  385. }, 1000);
  386. },
  387. /**
  388. * Display a popup menu for choosing the export type
  389. *
  390. * @param {String} className An identifier for the menu
  391. * @param {Array} items A collection with text and onclicks for the items
  392. * @param {Number} x The x position of the opener button
  393. * @param {Number} y The y position of the opener button
  394. * @param {Number} width The width of the opener button
  395. * @param {Number} height The height of the opener button
  396. */
  397. contextMenu: function (className, items, x, y, width, height, button) {
  398. var chart = this,
  399. navOptions = chart.options.navigation,
  400. menuItemStyle = navOptions.menuItemStyle,
  401. chartWidth = chart.chartWidth,
  402. chartHeight = chart.chartHeight,
  403. cacheName = 'cache-' + className,
  404. menu = chart[cacheName],
  405. menuPadding = mathMax(width, height), // for mouse leave detection
  406. boxShadow = '3px 3px 10px #888',
  407. innerMenu,
  408. hide,
  409. hideTimer,
  410. menuStyle,
  411. docMouseUpHandler = function (e) {
  412. if (!chart.pointer.inClass(e.target, className)) {
  413. hide();
  414. }
  415. };
  416. // create the menu only the first time
  417. if (!menu) {
  418. // create a HTML element above the SVG
  419. chart[cacheName] = menu = createElement(DIV, {
  420. className: className
  421. }, {
  422. position: ABSOLUTE,
  423. zIndex: 1000,
  424. padding: menuPadding + PX
  425. }, chart.container);
  426. innerMenu = createElement(DIV, null,
  427. extend({
  428. MozBoxShadow: boxShadow,
  429. WebkitBoxShadow: boxShadow,
  430. boxShadow: boxShadow
  431. }, navOptions.menuStyle), menu);
  432. // hide on mouse out
  433. hide = function () {
  434. css(menu, { display: NONE });
  435. if (button) {
  436. button.setState(0);
  437. }
  438. chart.openMenu = false;
  439. };
  440. // Hide the menu some time after mouse leave (#1357)
  441. addEvent(menu, 'mouseleave', function () {
  442. hideTimer = setTimeout(hide, 500);
  443. });
  444. addEvent(menu, 'mouseenter', function () {
  445. clearTimeout(hideTimer);
  446. });
  447. // Hide it on clicking or touching outside the menu (#2258, #2335, #2407)
  448. addEvent(document, 'mouseup', docMouseUpHandler);
  449. addEvent(chart, 'destroy', function () {
  450. removeEvent(document, 'mouseup', docMouseUpHandler);
  451. });
  452. // create the items
  453. each(items, function (item) {
  454. if (item) {
  455. var element = item.separator ?
  456. createElement('hr', null, null, innerMenu) :
  457. createElement(DIV, {
  458. onmouseover: function () {
  459. css(this, navOptions.menuItemHoverStyle);
  460. },
  461. onmouseout: function () {
  462. css(this, menuItemStyle);
  463. },
  464. onclick: function () {
  465. hide();
  466. if (item.onclick) {
  467. item.onclick.apply(chart, arguments);
  468. }
  469. },
  470. innerHTML: item.text || chart.options.lang[item.textKey]
  471. }, extend({
  472. cursor: 'pointer'
  473. }, menuItemStyle), innerMenu);
  474. // Keep references to menu divs to be able to destroy them
  475. chart.exportDivElements.push(element);
  476. }
  477. });
  478. // Keep references to menu and innerMenu div to be able to destroy them
  479. chart.exportDivElements.push(innerMenu, menu);
  480. chart.exportMenuWidth = menu.offsetWidth;
  481. chart.exportMenuHeight = menu.offsetHeight;
  482. }
  483. menuStyle = { display: 'block' };
  484. // if outside right, right align it
  485. if (x + chart.exportMenuWidth > chartWidth) {
  486. menuStyle.right = (chartWidth - x - width - menuPadding) + PX;
  487. } else {
  488. menuStyle.left = (x - menuPadding) + PX;
  489. }
  490. // if outside bottom, bottom align it
  491. if (y + height + chart.exportMenuHeight > chartHeight && button.alignOptions.verticalAlign !== 'top') {
  492. menuStyle.bottom = (chartHeight - y - menuPadding) + PX;
  493. } else {
  494. menuStyle.top = (y + height - menuPadding) + PX;
  495. }
  496. css(menu, menuStyle);
  497. chart.openMenu = true;
  498. },
  499. /**
  500. * Add the export button to the chart
  501. */
  502. addButton: function (options) {
  503. var chart = this,
  504. renderer = chart.renderer,
  505. btnOptions = merge(chart.options.navigation.buttonOptions, options),
  506. onclick = btnOptions.onclick,
  507. menuItems = btnOptions.menuItems,
  508. symbol,
  509. button,
  510. symbolAttr = {
  511. stroke: btnOptions.symbolStroke,
  512. fill: btnOptions.symbolFill
  513. },
  514. symbolSize = btnOptions.symbolSize || 12;
  515. if (!chart.btnCount) {
  516. chart.btnCount = 0;
  517. }
  518. // Keeps references to the button elements
  519. if (!chart.exportDivElements) {
  520. chart.exportDivElements = [];
  521. chart.exportSVGElements = [];
  522. }
  523. if (btnOptions.enabled === false) {
  524. return;
  525. }
  526. var attr = btnOptions.theme,
  527. states = attr.states,
  528. hover = states && states.hover,
  529. select = states && states.select,
  530. callback;
  531. delete attr.states;
  532. if (onclick) {
  533. callback = function () {
  534. onclick.apply(chart, arguments);
  535. };
  536. } else if (menuItems) {
  537. callback = function () {
  538. chart.contextMenu(
  539. button.menuClassName,
  540. menuItems,
  541. button.translateX,
  542. button.translateY,
  543. button.width,
  544. button.height,
  545. button
  546. );
  547. button.setState(2);
  548. };
  549. }
  550. if (btnOptions.text && btnOptions.symbol) {
  551. attr.paddingLeft = Highcharts.pick(attr.paddingLeft, 25);
  552. } else if (!btnOptions.text) {
  553. extend(attr, {
  554. width: btnOptions.width,
  555. height: btnOptions.height,
  556. padding: 0
  557. });
  558. }
  559. button = renderer.button(btnOptions.text, 0, 0, callback, attr, hover, select)
  560. .attr({
  561. title: chart.options.lang[btnOptions._titleKey],
  562. 'stroke-linecap': 'round'
  563. });
  564. button.menuClassName = options.menuClassName || PREFIX + 'menu-' + chart.btnCount++;
  565. if (btnOptions.symbol) {
  566. symbol = renderer.symbol(
  567. btnOptions.symbol,
  568. btnOptions.symbolX - (symbolSize / 2),
  569. btnOptions.symbolY - (symbolSize / 2),
  570. symbolSize,
  571. symbolSize
  572. )
  573. .attr(extend(symbolAttr, {
  574. 'stroke-width': btnOptions.symbolStrokeWidth || 1,
  575. zIndex: 1
  576. })).add(button);
  577. }
  578. button.add()
  579. .align(extend(btnOptions, {
  580. width: button.width,
  581. x: Highcharts.pick(btnOptions.x, buttonOffset) // #1654
  582. }), true, 'spacingBox');
  583. buttonOffset += (button.width + btnOptions.buttonSpacing) * (btnOptions.align === 'right' ? -1 : 1);
  584. chart.exportSVGElements.push(button, symbol);
  585. },
  586. /**
  587. * Destroy the buttons.
  588. */
  589. destroyExport: function (e) {
  590. var chart = e.target,
  591. i,
  592. elem;
  593. // Destroy the extra buttons added
  594. for (i = 0; i < chart.exportSVGElements.length; i++) {
  595. elem = chart.exportSVGElements[i];
  596. // Destroy and null the svg/vml elements
  597. if (elem) { // #1822
  598. elem.onclick = elem.ontouchstart = null;
  599. chart.exportSVGElements[i] = elem.destroy();
  600. }
  601. }
  602. // Destroy the divs for the menu
  603. for (i = 0; i < chart.exportDivElements.length; i++) {
  604. elem = chart.exportDivElements[i];
  605. // Remove the event handler
  606. removeEvent(elem, 'mouseleave');
  607. // Remove inline events
  608. chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null;
  609. // Destroy the div by moving to garbage bin
  610. discardElement(elem);
  611. }
  612. }
  613. });
  614. symbols.menu = function (x, y, width, height) {
  615. var arr = [
  616. M, x, y + 2.5,
  617. L, x + width, y + 2.5,
  618. M, x, y + height / 2 + 0.5,
  619. L, x + width, y + height / 2 + 0.5,
  620. M, x, y + height - 1.5,
  621. L, x + width, y + height - 1.5
  622. ];
  623. return arr;
  624. };
  625. // Add the buttons on chart load
  626. Chart.prototype.callbacks.push(function (chart) {
  627. var n,
  628. exportingOptions = chart.options.exporting,
  629. buttons = exportingOptions.buttons;
  630. buttonOffset = 0;
  631. if (exportingOptions.enabled !== false) {
  632. for (n in buttons) {
  633. chart.addButton(buttons[n]);
  634. }
  635. // Destroy the export elements at chart destroy
  636. addEvent(chart, 'destroy', chart.destroyExport);
  637. }
  638. });
  639. }(Highcharts));