003d8af830619b5bf937383d79487f308534702b.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /**
  2. * @license Highcharts JS v4.1.7 (2015-06-26)
  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(/<(\/?)TITLE>/g, '<$1title>')
  204. .replace(/height=([^" ]+)/g, 'height="$1"')
  205. .replace(/width=([^" ]+)/g, 'width="$1"')
  206. .replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>')
  207. .replace(/ id=([^" >]+)/g, ' id="$1"') // #4003
  208. .replace(/class=([^" >]+)/g, 'class="$1"')
  209. .replace(/ transform /g, ' ')
  210. .replace(/:(path|rect)/g, '$1')
  211. .replace(/style="([^"]+)"/g, function (s) {
  212. return s.toLowerCase();
  213. });
  214. },
  215. /**
  216. * Return an SVG representation of the chart
  217. *
  218. * @param additionalOptions {Object} Additional chart options for the generated SVG representation
  219. */
  220. getSVG: function (additionalOptions) {
  221. var chart = this,
  222. chartCopy,
  223. sandbox,
  224. svg,
  225. seriesOptions,
  226. sourceWidth,
  227. sourceHeight,
  228. cssWidth,
  229. cssHeight,
  230. options = merge(chart.options, additionalOptions); // copy the options and add extra options
  231. // IE compatibility hack for generating SVG content that it doesn't really understand
  232. if (!doc.createElementNS) {
  233. /*jslint unparam: true*//* allow unused parameter ns in function below */
  234. doc.createElementNS = function (ns, tagName) {
  235. return doc.createElement(tagName);
  236. };
  237. /*jslint unparam: false*/
  238. }
  239. // create a sandbox where a new chart will be generated
  240. sandbox = createElement(DIV, null, {
  241. position: ABSOLUTE,
  242. top: '-9999em',
  243. width: chart.chartWidth + PX,
  244. height: chart.chartHeight + PX
  245. }, doc.body);
  246. // get the source size
  247. cssWidth = chart.renderTo.style.width;
  248. cssHeight = chart.renderTo.style.height;
  249. sourceWidth = options.exporting.sourceWidth ||
  250. options.chart.width ||
  251. (/px$/.test(cssWidth) && parseInt(cssWidth, 10)) ||
  252. 600;
  253. sourceHeight = options.exporting.sourceHeight ||
  254. options.chart.height ||
  255. (/px$/.test(cssHeight) && parseInt(cssHeight, 10)) ||
  256. 400;
  257. // override some options
  258. extend(options.chart, {
  259. animation: false,
  260. renderTo: sandbox,
  261. forExport: true,
  262. width: sourceWidth,
  263. height: sourceHeight
  264. });
  265. options.exporting.enabled = false; // hide buttons in print
  266. delete options.data; // #3004
  267. // prepare for replicating the chart
  268. options.series = [];
  269. each(chart.series, function (serie) {
  270. seriesOptions = merge(serie.options, {
  271. animation: false, // turn off animation
  272. enableMouseTracking: false,
  273. showCheckbox: false,
  274. visible: serie.visible
  275. });
  276. if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set
  277. options.series.push(seriesOptions);
  278. }
  279. });
  280. // Axis options must be merged in one by one, since it may be an array or an object (#2022, #3900)
  281. if (additionalOptions) {
  282. each(['xAxis', 'yAxis'], function (axisType) {
  283. each(splat(additionalOptions[axisType]), function (axisOptions, i) {
  284. options[axisType][i] = merge(options[axisType][i], axisOptions);
  285. });
  286. });
  287. }
  288. // generate the chart copy
  289. chartCopy = new Highcharts.Chart(options, chart.callback);
  290. // reflect axis extremes in the export
  291. each(['xAxis', 'yAxis'], function (axisType) {
  292. each(chart[axisType], function (axis, i) {
  293. var axisCopy = chartCopy[axisType][i],
  294. extremes = axis.getExtremes(),
  295. userMin = extremes.userMin,
  296. userMax = extremes.userMax;
  297. if (axisCopy && (userMin !== UNDEFINED || userMax !== UNDEFINED)) {
  298. axisCopy.setExtremes(userMin, userMax, true, false);
  299. }
  300. });
  301. });
  302. // get the SVG from the container's innerHTML
  303. svg = chartCopy.container.innerHTML;
  304. // free up memory
  305. options = null;
  306. chartCopy.destroy();
  307. discardElement(sandbox);
  308. // sanitize
  309. svg = this.sanitizeSVG(svg);
  310. // IE9 beta bugs with innerHTML. Test again with final IE9.
  311. svg = svg.replace(/(url\(#highcharts-[0-9]+)&quot;/g, '$1')
  312. .replace(/&quot;/g, "'");
  313. return svg;
  314. },
  315. getSVGForExport: function (options, chartOptions) {
  316. var chartExportingOptions = this.options.exporting;
  317. return this.getSVG(merge(
  318. { chart: { borderRadius: 0 } },
  319. chartExportingOptions.chartOptions,
  320. chartOptions,
  321. {
  322. exporting: {
  323. sourceWidth: (options && options.sourceWidth) || chartExportingOptions.sourceWidth,
  324. sourceHeight: (options && options.sourceHeight) || chartExportingOptions.sourceHeight
  325. }
  326. }
  327. ));
  328. },
  329. /**
  330. * Submit the SVG representation of the chart to the server
  331. * @param {Object} options Exporting options. Possible members are url, type, width and formAttributes.
  332. * @param {Object} chartOptions Additional chart options for the SVG representation of the chart
  333. */
  334. exportChart: function (options, chartOptions) {
  335. var svg = this.getSVGForExport(options, chartOptions);
  336. // merge the options
  337. options = merge(this.options.exporting, options);
  338. // do the post
  339. Highcharts.post(options.url, {
  340. filename: options.filename || 'chart',
  341. type: options.type,
  342. width: options.width || 0, // IE8 fails to post undefined correctly, so use 0
  343. scale: options.scale || 2,
  344. svg: svg
  345. }, options.formAttributes);
  346. },
  347. /**
  348. * Print the chart
  349. */
  350. print: function () {
  351. var chart = this,
  352. container = chart.container,
  353. origDisplay = [],
  354. origParent = container.parentNode,
  355. body = doc.body,
  356. childNodes = body.childNodes;
  357. if (chart.isPrinting) { // block the button while in printing mode
  358. return;
  359. }
  360. chart.isPrinting = true;
  361. fireEvent(chart, 'beforePrint');
  362. // hide all body content
  363. each(childNodes, function (node, i) {
  364. if (node.nodeType === 1) {
  365. origDisplay[i] = node.style.display;
  366. node.style.display = NONE;
  367. }
  368. });
  369. // pull out the chart
  370. body.appendChild(container);
  371. // print
  372. win.focus(); // #1510
  373. win.print();
  374. // allow the browser to prepare before reverting
  375. setTimeout(function () {
  376. // put the chart back in
  377. origParent.appendChild(container);
  378. // restore all body content
  379. each(childNodes, function (node, i) {
  380. if (node.nodeType === 1) {
  381. node.style.display = origDisplay[i];
  382. }
  383. });
  384. chart.isPrinting = false;
  385. fireEvent(chart, 'afterPrint');
  386. }, 1000);
  387. },
  388. /**
  389. * Display a popup menu for choosing the export type
  390. *
  391. * @param {String} className An identifier for the menu
  392. * @param {Array} items A collection with text and onclicks for the items
  393. * @param {Number} x The x position of the opener button
  394. * @param {Number} y The y position of the opener button
  395. * @param {Number} width The width of the opener button
  396. * @param {Number} height The height of the opener button
  397. */
  398. contextMenu: function (className, items, x, y, width, height, button) {
  399. var chart = this,
  400. navOptions = chart.options.navigation,
  401. menuItemStyle = navOptions.menuItemStyle,
  402. chartWidth = chart.chartWidth,
  403. chartHeight = chart.chartHeight,
  404. cacheName = 'cache-' + className,
  405. menu = chart[cacheName],
  406. menuPadding = mathMax(width, height), // for mouse leave detection
  407. boxShadow = '3px 3px 10px #888',
  408. innerMenu,
  409. hide,
  410. hideTimer,
  411. menuStyle,
  412. docMouseUpHandler = function (e) {
  413. if (!chart.pointer.inClass(e.target, className)) {
  414. hide();
  415. }
  416. };
  417. // create the menu only the first time
  418. if (!menu) {
  419. // create a HTML element above the SVG
  420. chart[cacheName] = menu = createElement(DIV, {
  421. className: className
  422. }, {
  423. position: ABSOLUTE,
  424. zIndex: 1000,
  425. padding: menuPadding + PX
  426. }, chart.container);
  427. innerMenu = createElement(DIV, null,
  428. extend({
  429. MozBoxShadow: boxShadow,
  430. WebkitBoxShadow: boxShadow,
  431. boxShadow: boxShadow
  432. }, navOptions.menuStyle), menu);
  433. // hide on mouse out
  434. hide = function () {
  435. css(menu, { display: NONE });
  436. if (button) {
  437. button.setState(0);
  438. }
  439. chart.openMenu = false;
  440. };
  441. // Hide the menu some time after mouse leave (#1357)
  442. addEvent(menu, 'mouseleave', function () {
  443. hideTimer = setTimeout(hide, 500);
  444. });
  445. addEvent(menu, 'mouseenter', function () {
  446. clearTimeout(hideTimer);
  447. });
  448. // Hide it on clicking or touching outside the menu (#2258, #2335, #2407)
  449. addEvent(document, 'mouseup', docMouseUpHandler);
  450. addEvent(chart, 'destroy', function () {
  451. removeEvent(document, 'mouseup', docMouseUpHandler);
  452. });
  453. // create the items
  454. each(items, function (item) {
  455. if (item) {
  456. var element = item.separator ?
  457. createElement('hr', null, null, innerMenu) :
  458. createElement(DIV, {
  459. onmouseover: function () {
  460. css(this, navOptions.menuItemHoverStyle);
  461. },
  462. onmouseout: function () {
  463. css(this, menuItemStyle);
  464. },
  465. onclick: function () {
  466. hide();
  467. if (item.onclick) {
  468. item.onclick.apply(chart, arguments);
  469. }
  470. },
  471. innerHTML: item.text || chart.options.lang[item.textKey]
  472. }, extend({
  473. cursor: 'pointer'
  474. }, menuItemStyle), innerMenu);
  475. // Keep references to menu divs to be able to destroy them
  476. chart.exportDivElements.push(element);
  477. }
  478. });
  479. // Keep references to menu and innerMenu div to be able to destroy them
  480. chart.exportDivElements.push(innerMenu, menu);
  481. chart.exportMenuWidth = menu.offsetWidth;
  482. chart.exportMenuHeight = menu.offsetHeight;
  483. }
  484. menuStyle = { display: 'block' };
  485. // if outside right, right align it
  486. if (x + chart.exportMenuWidth > chartWidth) {
  487. menuStyle.right = (chartWidth - x - width - menuPadding) + PX;
  488. } else {
  489. menuStyle.left = (x - menuPadding) + PX;
  490. }
  491. // if outside bottom, bottom align it
  492. if (y + height + chart.exportMenuHeight > chartHeight && button.alignOptions.verticalAlign !== 'top') {
  493. menuStyle.bottom = (chartHeight - y - menuPadding) + PX;
  494. } else {
  495. menuStyle.top = (y + height - menuPadding) + PX;
  496. }
  497. css(menu, menuStyle);
  498. chart.openMenu = true;
  499. },
  500. /**
  501. * Add the export button to the chart
  502. */
  503. addButton: function (options) {
  504. var chart = this,
  505. renderer = chart.renderer,
  506. btnOptions = merge(chart.options.navigation.buttonOptions, options),
  507. onclick = btnOptions.onclick,
  508. menuItems = btnOptions.menuItems,
  509. symbol,
  510. button,
  511. symbolAttr = {
  512. stroke: btnOptions.symbolStroke,
  513. fill: btnOptions.symbolFill
  514. },
  515. symbolSize = btnOptions.symbolSize || 12;
  516. if (!chart.btnCount) {
  517. chart.btnCount = 0;
  518. }
  519. // Keeps references to the button elements
  520. if (!chart.exportDivElements) {
  521. chart.exportDivElements = [];
  522. chart.exportSVGElements = [];
  523. }
  524. if (btnOptions.enabled === false) {
  525. return;
  526. }
  527. var attr = btnOptions.theme,
  528. states = attr.states,
  529. hover = states && states.hover,
  530. select = states && states.select,
  531. callback;
  532. delete attr.states;
  533. if (onclick) {
  534. callback = function () {
  535. onclick.apply(chart, arguments);
  536. };
  537. } else if (menuItems) {
  538. callback = function () {
  539. chart.contextMenu(
  540. button.menuClassName,
  541. menuItems,
  542. button.translateX,
  543. button.translateY,
  544. button.width,
  545. button.height,
  546. button
  547. );
  548. button.setState(2);
  549. };
  550. }
  551. if (btnOptions.text && btnOptions.symbol) {
  552. attr.paddingLeft = Highcharts.pick(attr.paddingLeft, 25);
  553. } else if (!btnOptions.text) {
  554. extend(attr, {
  555. width: btnOptions.width,
  556. height: btnOptions.height,
  557. padding: 0
  558. });
  559. }
  560. button = renderer.button(btnOptions.text, 0, 0, callback, attr, hover, select)
  561. .attr({
  562. title: chart.options.lang[btnOptions._titleKey],
  563. 'stroke-linecap': 'round'
  564. });
  565. button.menuClassName = options.menuClassName || PREFIX + 'menu-' + chart.btnCount++;
  566. if (btnOptions.symbol) {
  567. symbol = renderer.symbol(
  568. btnOptions.symbol,
  569. btnOptions.symbolX - (symbolSize / 2),
  570. btnOptions.symbolY - (symbolSize / 2),
  571. symbolSize,
  572. symbolSize
  573. )
  574. .attr(extend(symbolAttr, {
  575. 'stroke-width': btnOptions.symbolStrokeWidth || 1,
  576. zIndex: 1
  577. })).add(button);
  578. }
  579. button.add()
  580. .align(extend(btnOptions, {
  581. width: button.width,
  582. x: Highcharts.pick(btnOptions.x, buttonOffset) // #1654
  583. }), true, 'spacingBox');
  584. buttonOffset += (button.width + btnOptions.buttonSpacing) * (btnOptions.align === 'right' ? -1 : 1);
  585. chart.exportSVGElements.push(button, symbol);
  586. },
  587. /**
  588. * Destroy the buttons.
  589. */
  590. destroyExport: function (e) {
  591. var chart = e.target,
  592. i,
  593. elem;
  594. // Destroy the extra buttons added
  595. for (i = 0; i < chart.exportSVGElements.length; i++) {
  596. elem = chart.exportSVGElements[i];
  597. // Destroy and null the svg/vml elements
  598. if (elem) { // #1822
  599. elem.onclick = elem.ontouchstart = null;
  600. chart.exportSVGElements[i] = elem.destroy();
  601. }
  602. }
  603. // Destroy the divs for the menu
  604. for (i = 0; i < chart.exportDivElements.length; i++) {
  605. elem = chart.exportDivElements[i];
  606. // Remove the event handler
  607. removeEvent(elem, 'mouseleave');
  608. // Remove inline events
  609. chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null;
  610. // Destroy the div by moving to garbage bin
  611. discardElement(elem);
  612. }
  613. }
  614. });
  615. symbols.menu = function (x, y, width, height) {
  616. var arr = [
  617. M, x, y + 2.5,
  618. L, x + width, y + 2.5,
  619. M, x, y + height / 2 + 0.5,
  620. L, x + width, y + height / 2 + 0.5,
  621. M, x, y + height - 1.5,
  622. L, x + width, y + height - 1.5
  623. ];
  624. return arr;
  625. };
  626. // Add the buttons on chart load
  627. Chart.prototype.callbacks.push(function (chart) {
  628. var n,
  629. exportingOptions = chart.options.exporting,
  630. buttons = exportingOptions.buttons;
  631. buttonOffset = 0;
  632. if (exportingOptions.enabled !== false) {
  633. for (n in buttons) {
  634. chart.addButton(buttons[n]);
  635. }
  636. // Destroy the export elements at chart destroy
  637. addEvent(chart, 'destroy', chart.destroyExport);
  638. }
  639. });
  640. }(Highcharts));