12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447 |
- /**
- * @license Highcharts JS v9.1.1 (2021-06-04)
- *
- * Exporting module
- *
- * (c) 2010-2021 Torstein Honsi
- *
- * License: www.highcharts.com/license
- */
- 'use strict';
- (function (factory) {
- if (typeof module === 'object' && module.exports) {
- factory['default'] = factory;
- module.exports = factory;
- } else if (typeof define === 'function' && define.amd) {
- define('highcharts/modules/exporting', ['highcharts'], function (Highcharts) {
- factory(Highcharts);
- factory.Highcharts = Highcharts;
- return factory;
- });
- } else {
- factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
- }
- }(function (Highcharts) {
- var _modules = Highcharts ? Highcharts._modules : {};
- function _registerModule(obj, path, args, fn) {
- if (!obj.hasOwnProperty(path)) {
- obj[path] = fn.apply(null, args);
- }
- }
- _registerModule(_modules, 'Extensions/FullScreen.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/Utilities.js']], function (Chart, H, AST, U) {
- /* *
- * (c) 2009-2021 Rafal Sebestjanski
- *
- * Full screen for Highcharts
- *
- * License: www.highcharts.com/license
- */
- var doc = H.doc;
- var addEvent = U.addEvent;
- /**
- * The module allows user to enable display chart in full screen mode.
- * Used in StockTools too.
- * Based on default solutions in browsers.
- *
- */
- /* eslint-disable no-invalid-this, valid-jsdoc */
- /**
- * Handles displaying chart's container in the fullscreen mode.
- *
- * **Note**: Fullscreen is not supported on iPhone due to iOS limitations.
- *
- * @class
- * @name Highcharts.Fullscreen
- * @hideconstructor
- * @requires modules/full-screen
- */
- var Fullscreen = /** @class */ (function () {
- /* *
- *
- * Constructors
- *
- * */
- function Fullscreen(chart) {
- /**
- * Chart managed by the fullscreen controller.
- * @name Highcharts.Fullscreen#chart
- * @type {Highcharts.Chart}
- */
- this.chart = chart;
- /**
- * The flag is set to `true` when the chart is displayed in
- * the fullscreen mode.
- *
- * @name Highcharts.Fullscreen#isOpen
- * @type {boolean|undefined}
- * @since 8.0.1
- */
- this.isOpen = false;
- var container = chart.renderTo;
- // Hold event and methods available only for a current browser.
- if (!this.browserProps) {
- if (typeof container.requestFullscreen === 'function') {
- this.browserProps = {
- fullscreenChange: 'fullscreenchange',
- requestFullscreen: 'requestFullscreen',
- exitFullscreen: 'exitFullscreen'
- };
- }
- else if (container.mozRequestFullScreen) {
- this.browserProps = {
- fullscreenChange: 'mozfullscreenchange',
- requestFullscreen: 'mozRequestFullScreen',
- exitFullscreen: 'mozCancelFullScreen'
- };
- }
- else if (container.webkitRequestFullScreen) {
- this.browserProps = {
- fullscreenChange: 'webkitfullscreenchange',
- requestFullscreen: 'webkitRequestFullScreen',
- exitFullscreen: 'webkitExitFullscreen'
- };
- }
- else if (container.msRequestFullscreen) {
- this.browserProps = {
- fullscreenChange: 'MSFullscreenChange',
- requestFullscreen: 'msRequestFullscreen',
- exitFullscreen: 'msExitFullscreen'
- };
- }
- }
- }
- /* *
- *
- * Functions
- *
- * */
- /**
- * Stops displaying the chart in fullscreen mode.
- * Exporting module required.
- *
- * @since 8.0.1
- *
- * @function Highcharts.Fullscreen#close
- * @return {void}
- * @requires modules/full-screen
- */
- Fullscreen.prototype.close = function () {
- var fullscreen = this,
- chart = fullscreen.chart,
- optionsChart = chart.options.chart;
- // Don't fire exitFullscreen() when user exited using 'Escape' button.
- if (fullscreen.isOpen &&
- fullscreen.browserProps &&
- chart.container.ownerDocument instanceof Document) {
- chart.container.ownerDocument[fullscreen.browserProps.exitFullscreen]();
- }
- // Unbind event as it's necessary only before exiting from fullscreen.
- if (fullscreen.unbindFullscreenEvent) {
- fullscreen.unbindFullscreenEvent = fullscreen.unbindFullscreenEvent();
- }
- chart.setSize(fullscreen.origWidth, fullscreen.origHeight, false);
- fullscreen.origWidth = void 0;
- fullscreen.origHeight = void 0;
- optionsChart.width = fullscreen.origWidthOption;
- optionsChart.height = fullscreen.origHeightOption;
- fullscreen.origWidthOption = void 0;
- fullscreen.origHeightOption = void 0;
- fullscreen.isOpen = false;
- fullscreen.setButtonText();
- };
- /**
- * Displays the chart in fullscreen mode.
- * When fired customly by user before exporting context button is created,
- * button's text will not be replaced - it's on the user side.
- * Exporting module required.
- *
- * @since 8.0.1
- *
- * @function Highcharts.Fullscreen#open
- * @return {void}
- * @requires modules/full-screen
- */
- Fullscreen.prototype.open = function () {
- var fullscreen = this,
- chart = fullscreen.chart,
- optionsChart = chart.options.chart;
- if (optionsChart) {
- fullscreen.origWidthOption = optionsChart.width;
- fullscreen.origHeightOption = optionsChart.height;
- }
- fullscreen.origWidth = chart.chartWidth;
- fullscreen.origHeight = chart.chartHeight;
- // Handle exitFullscreen() method when user clicks 'Escape' button.
- if (fullscreen.browserProps) {
- var unbindChange_1 = addEvent(chart.container.ownerDocument, // chart's document
- fullscreen.browserProps.fullscreenChange,
- function () {
- // Handle lack of async of browser's fullScreenChange event.
- if (fullscreen.isOpen) {
- fullscreen.isOpen = false;
- fullscreen.close();
- }
- else {
- chart.setSize(null, null, false);
- fullscreen.isOpen = true;
- fullscreen.setButtonText();
- }
- });
- var unbindDestroy_1 = addEvent(chart, 'destroy',
- unbindChange_1);
- fullscreen.unbindFullscreenEvent = function () {
- unbindChange_1();
- unbindDestroy_1();
- };
- var promise = chart.renderTo[fullscreen.browserProps.requestFullscreen]();
- if (promise) {
- // No dot notation because of IE8 compatibility
- promise['catch'](function () {
- alert(// eslint-disable-line no-alert
- 'Full screen is not supported inside a frame.');
- });
- }
- }
- };
- /**
- * Replaces the exporting context button's text when toogling the
- * fullscreen mode.
- *
- * @private
- *
- * @since 8.0.1
- *
- * @requires modules/full-screen
- * @return {void}
- */
- Fullscreen.prototype.setButtonText = function () {
- var chart = this.chart,
- exportDivElements = chart.exportDivElements,
- exportingOptions = chart.options.exporting,
- menuItems = (exportingOptions &&
- exportingOptions.buttons &&
- exportingOptions.buttons.contextButton.menuItems),
- lang = chart.options.lang;
- if (exportingOptions &&
- exportingOptions.menuItemDefinitions &&
- lang &&
- lang.exitFullscreen &&
- lang.viewFullscreen &&
- menuItems &&
- exportDivElements &&
- exportDivElements.length) {
- AST.setElementHTML(exportDivElements[menuItems.indexOf('viewFullscreen')], !this.isOpen ?
- (exportingOptions.menuItemDefinitions.viewFullscreen.text ||
- lang.viewFullscreen) : lang.exitFullscreen);
- }
- };
- /**
- * Toggles displaying the chart in fullscreen mode.
- * By default, when the exporting module is enabled, a context button with
- * a drop down menu in the upper right corner accesses this function.
- * Exporting module required.
- *
- * @since 8.0.1
- *
- * @sample highcharts/members/chart-togglefullscreen/
- * Toggle fullscreen mode from a HTML button
- *
- * @function Highcharts.Fullscreen#toggle
- * @requires modules/full-screen
- */
- Fullscreen.prototype.toggle = function () {
- var fullscreen = this;
- if (!fullscreen.isOpen) {
- fullscreen.open();
- }
- else {
- fullscreen.close();
- }
- };
- return Fullscreen;
- }());
- H.Fullscreen = Fullscreen;
- // Initialize fullscreen
- addEvent(Chart, 'beforeRender', function () {
- /**
- * @name Highcharts.Chart#fullscreen
- * @type {Highcharts.Fullscreen}
- * @requires modules/full-screen
- */
- this.fullscreen = new H.Fullscreen(this);
- });
- return H.Fullscreen;
- });
- _registerModule(_modules, 'Mixins/Navigation.js', [], function () {
- /**
- *
- * (c) 2010-2021 Paweł Fus
- *
- * License: www.highcharts.com/license
- *
- * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
- *
- * */
- var chartNavigation = {
- /**
- * Initializes `chart.navigation` object which delegates `update()` methods
- * to all other common classes (used in exporting and navigationBindings).
- *
- * @private
- * @param {Highcharts.Chart} chart
- * The chart instance.
- * @return {void}
- */
- initUpdate: function (chart) {
- if (!chart.navigation) {
- chart.navigation = {
- updates: [],
- update: function (options,
- redraw) {
- this.updates.forEach(function (updateConfig) {
- updateConfig.update.call(updateConfig.context,
- options,
- redraw);
- });
- }
- };
- }
- },
- /**
- * Registers an `update()` method in the `chart.navigation` object.
- *
- * @private
- * @param {Highcharts.ChartNavigationUpdateFunction} update
- * The `update()` method that will be called in `chart.update()`.
- * @param {Highcharts.Chart} chart
- * The chart instance. `update()` will use that as a context
- * (`this`).
- * @return {void}
- */
- addUpdate: function (update, chart) {
- if (!chart.navigation) {
- this.initUpdate(chart);
- }
- chart.navigation.updates.push({
- update: update,
- context: chart
- });
- }
- };
- return chartNavigation;
- });
- _registerModule(_modules, 'Extensions/Exporting.js', [_modules['Core/Chart/Chart.js'], _modules['Mixins/Navigation.js'], _modules['Core/Globals.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (Chart, chartNavigationMixin, H, D, palette, SVGRenderer, U) {
- /* *
- *
- * Exporting module
- *
- * (c) 2010-2021 Torstein Honsi
- *
- * License: www.highcharts.com/license
- *
- * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
- *
- * */
- var doc = H.doc,
- isTouchDevice = H.isTouchDevice,
- win = H.win;
- var defaultOptions = D.defaultOptions;
- var symbols = SVGRenderer.prototype.symbols;
- var addEvent = U.addEvent,
- css = U.css,
- createElement = U.createElement,
- discardElement = U.discardElement,
- extend = U.extend,
- find = U.find,
- fireEvent = U.fireEvent,
- isObject = U.isObject,
- merge = U.merge,
- objectEach = U.objectEach,
- pick = U.pick,
- removeEvent = U.removeEvent,
- uniqueKey = U.uniqueKey;
- // Add language
- extend(defaultOptions.lang
- /**
- * @optionparent lang
- */
- , {
- /**
- * Exporting module only. The text for the menu item to view the chart
- * in full screen.
- *
- * @since 8.0.1
- *
- * @private
- */
- viewFullscreen: 'View in full screen',
- /**
- * Exporting module only. The text for the menu item to exit the chart
- * from full screen.
- *
- * @since 8.0.1
- *
- * @private
- */
- exitFullscreen: 'Exit from full screen',
- /**
- * Exporting module only. The text for the menu item to print the chart.
- *
- * @since 3.0.1
- * @requires modules/exporting
- *
- * @private
- */
- printChart: 'Print chart',
- /**
- * Exporting module only. The text for the PNG download menu item.
- *
- * @since 2.0
- * @requires modules/exporting
- *
- * @private
- */
- downloadPNG: 'Download PNG image',
- /**
- * Exporting module only. The text for the JPEG download menu item.
- *
- * @since 2.0
- * @requires modules/exporting
- *
- * @private
- */
- downloadJPEG: 'Download JPEG image',
- /**
- * Exporting module only. The text for the PDF download menu item.
- *
- * @since 2.0
- * @requires modules/exporting
- *
- * @private
- */
- downloadPDF: 'Download PDF document',
- /**
- * Exporting module only. The text for the SVG download menu item.
- *
- * @since 2.0
- * @requires modules/exporting
- *
- * @private
- */
- downloadSVG: 'Download SVG vector image',
- /**
- * Exporting module menu. The tooltip title for the context menu holding
- * print and export menu items.
- *
- * @since 3.0
- * @requires modules/exporting
- *
- * @private
- */
- contextButtonTitle: 'Chart context menu'
- });
- if (!defaultOptions.navigation) {
- // Buttons and menus are collected in a separate config option set called
- // 'navigation'. This can be extended later to add control buttons like
- // zoom and pan right click menus.
- /**
- * A collection of options for buttons and menus appearing in the exporting
- * module.
- *
- * @requires modules/exporting
- * @optionparent navigation
- */
- defaultOptions.navigation = {};
- }
- merge(true, defaultOptions.navigation, {
- /**
- * @optionparent navigation.buttonOptions
- *
- * @private
- */
- buttonOptions: {
- theme: {},
- /**
- * Whether to enable buttons.
- *
- * @sample highcharts/navigation/buttonoptions-enabled/
- * Exporting module loaded but buttons disabled
- *
- * @type {boolean}
- * @default true
- * @since 2.0
- * @apioption navigation.buttonOptions.enabled
- */
- /**
- * The pixel size of the symbol on the button.
- *
- * @sample highcharts/navigation/buttonoptions-height/
- * Bigger buttons
- *
- * @since 2.0
- */
- symbolSize: 14,
- /**
- * The x position of the center of the symbol inside the button.
- *
- * @sample highcharts/navigation/buttonoptions-height/
- * Bigger buttons
- *
- * @since 2.0
- */
- symbolX: 12.5,
- /**
- * The y position of the center of the symbol inside the button.
- *
- * @sample highcharts/navigation/buttonoptions-height/
- * Bigger buttons
- *
- * @since 2.0
- */
- symbolY: 10.5,
- /**
- * Alignment for the buttons.
- *
- * @sample highcharts/navigation/buttonoptions-align/
- * Center aligned
- *
- * @type {Highcharts.AlignValue}
- * @since 2.0
- */
- align: 'right',
- /**
- * The pixel spacing between buttons.
- *
- * @since 2.0
- */
- buttonSpacing: 3,
- /**
- * Pixel height of the buttons.
- *
- * @sample highcharts/navigation/buttonoptions-height/
- * Bigger buttons
- *
- * @since 2.0
- */
- height: 22,
- /**
- * A text string to add to the individual button.
- *
- * @sample highcharts/exporting/buttons-text/
- * Full text button
- * @sample highcharts/exporting/buttons-text-symbol/
- * Combined symbol and text
- *
- * @type {string}
- * @default null
- * @since 3.0
- * @apioption navigation.buttonOptions.text
- */
- /**
- * The vertical offset of the button's position relative to its
- * `verticalAlign`.
- *
- * @sample highcharts/navigation/buttonoptions-verticalalign/
- * Buttons at lower right
- *
- * @type {number}
- * @default 0
- * @since 2.0
- * @apioption navigation.buttonOptions.y
- */
- /**
- * The vertical alignment of the buttons. Can be one of `"top"`,
- * `"middle"` or `"bottom"`.
- *
- * @sample highcharts/navigation/buttonoptions-verticalalign/
- * Buttons at lower right
- *
- * @type {Highcharts.VerticalAlignValue}
- * @since 2.0
- */
- verticalAlign: 'top',
- /**
- * The pixel width of the button.
- *
- * @sample highcharts/navigation/buttonoptions-height/
- * Bigger buttons
- *
- * @since 2.0
- */
- width: 24
- }
- });
- // Presentational attributes
- merge(true, defaultOptions.navigation,
- /**
- * A collection of options for buttons and menus appearing in the exporting
- * module.
- *
- * @optionparent navigation
- */
- {
- /**
- * CSS styles for the popup menu appearing by default when the export
- * icon is clicked. This menu is rendered in HTML.
- *
- * @see In styled mode, the menu is styled with the `.highcharts-menu`
- * class.
- *
- * @sample highcharts/navigation/menustyle/
- * Light gray menu background
- *
- * @type {Highcharts.CSSObject}
- * @default {"border": "1px solid #999999", "background": "#ffffff", "padding": "5px 0"}
- * @since 2.0
- *
- * @private
- */
- menuStyle: {
- /** @ignore-option */
- border: "1px solid " + palette.neutralColor40,
- /** @ignore-option */
- background: palette.backgroundColor,
- /** @ignore-option */
- padding: '5px 0'
- },
- /**
- * CSS styles for the individual items within the popup menu appearing
- * by default when the export icon is clicked. The menu items are
- * rendered in HTML. Font size defaults to `11px` on desktop and `14px`
- * on touch devices.
- *
- * @see In styled mode, the menu items are styled with the
- * `.highcharts-menu-item` class.
- *
- * @sample {highcharts} highcharts/navigation/menuitemstyle/
- * Add a grey stripe to the left
- *
- * @type {Highcharts.CSSObject}
- * @default {"padding": "0.5em 1em", "color": "#333333", "background": "none", "fontSize": "11px/14px", "transition": "background 250ms, color 250ms"}
- * @since 2.0
- *
- * @private
- */
- menuItemStyle: {
- /** @ignore-option */
- padding: '0.5em 1em',
- /** @ignore-option */
- color: palette.neutralColor80,
- /** @ignore-option */
- background: 'none',
- /** @ignore-option */
- fontSize: isTouchDevice ? '14px' : '11px',
- /** @ignore-option */
- transition: 'background 250ms, color 250ms'
- },
- /**
- * CSS styles for the hover state of the individual items within the
- * popup menu appearing by default when the export icon is clicked. The
- * menu items are rendered in HTML.
- *
- * @see In styled mode, the menu items are styled with the
- * `.highcharts-menu-item` class.
- *
- * @sample highcharts/navigation/menuitemhoverstyle/
- * Bold text on hover
- *
- * @type {Highcharts.CSSObject}
- * @default {"background": "#335cad", "color": "#ffffff"}
- * @since 2.0
- *
- * @private
- */
- menuItemHoverStyle: {
- /** @ignore-option */
- background: palette.highlightColor80,
- /** @ignore-option */
- color: palette.backgroundColor
- },
- /**
- * A collection of options for buttons appearing in the exporting
- * module.
- *
- * In styled mode, the buttons are styled with the
- * `.highcharts-contextbutton` and `.highcharts-button-symbol` classes.
- *
- * @requires modules/exporting
- *
- * @private
- */
- buttonOptions: {
- /**
- * Fill color for the symbol within the button.
- *
- * @sample highcharts/navigation/buttonoptions-symbolfill/
- * Blue symbol stroke for one of the buttons
- *
- * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
- * @since 2.0
- */
- symbolFill: palette.neutralColor60,
- /**
- * The color of the symbol's stroke or line.
- *
- * @sample highcharts/navigation/buttonoptions-symbolstroke/
- * Blue symbol stroke
- *
- * @type {Highcharts.ColorString}
- * @since 2.0
- */
- symbolStroke: palette.neutralColor60,
- /**
- * The pixel stroke width of the symbol on the button.
- *
- * @sample highcharts/navigation/buttonoptions-height/
- * Bigger buttons
- *
- * @since 2.0
- */
- symbolStrokeWidth: 3,
- /**
- * A configuration object for the button theme. The object accepts
- * SVG properties like `stroke-width`, `stroke` and `fill`.
- * Tri-state button styles are supported by the `states.hover` and
- * `states.select` objects.
- *
- * @sample highcharts/navigation/buttonoptions-theme/
- * Theming the buttons
- *
- * @requires modules/exporting
- *
- * @since 3.0
- */
- theme: {
- /**
- * The default fill exists only to capture hover events.
- *
- * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
- * @default ${palette.backgroundColor}
- * @apioption navigation.buttonOptions.theme.fill
- */
- /**
- * Default stroke for the buttons.
- * @type {Highcharts.ColorString}
- * @default none
- * @apioption navigation.buttonOptions.theme.stroke
- */
- /**
- * Padding for the button.
- */
- padding: 5
- }
- }
- });
- // Add the export related options
- /**
- * Options for the exporting module. For an overview on the matter, see
- * [the docs](https://www.highcharts.com/docs/export-module/export-module-overview).
- *
- * @requires modules/exporting
- * @optionparent exporting
- */
- defaultOptions.exporting = {
- /**
- * Experimental setting to allow HTML inside the chart (added through
- * the `useHTML` options), directly in the exported image. This allows
- * you to preserve complicated HTML structures like tables or bi-directional
- * text in exported charts.
- *
- * Disclaimer: The HTML is rendered in a `foreignObject` tag in the
- * generated SVG. The official export server is based on PhantomJS,
- * which supports this, but other SVG clients, like Batik, does not
- * support it. This also applies to downloaded SVG that you want to
- * open in a desktop client.
- *
- * @type {boolean}
- * @default false
- * @since 4.1.8
- * @apioption exporting.allowHTML
- */
- /**
- * Additional chart options to be merged into the chart before exporting to
- * an image format. This does not apply to printing the chart via the export
- * menu.
- *
- * For example, a common use case is to add data labels to improve
- * readability of the exported chart, or to add a printer-friendly color
- * scheme to exported PDFs.
- *
- * @sample {highcharts} highcharts/exporting/chartoptions-data-labels/
- * Added data labels
- * @sample {highstock} highcharts/exporting/chartoptions-data-labels/
- * Added data labels
- *
- * @type {Highcharts.Options}
- * @apioption exporting.chartOptions
- */
- /**
- * Whether to enable the exporting module. Disabling the module will
- * hide the context button, but API methods will still be available.
- *
- * @sample {highcharts} highcharts/exporting/enabled-false/
- * Exporting module is loaded but disabled
- * @sample {highstock} highcharts/exporting/enabled-false/
- * Exporting module is loaded but disabled
- *
- * @type {boolean}
- * @default true
- * @since 2.0
- * @apioption exporting.enabled
- */
- /**
- * Function to call if the offline-exporting module fails to export
- * a chart on the client side, and [fallbackToExportServer](
- * #exporting.fallbackToExportServer) is disabled. If left undefined, an
- * exception is thrown instead. Receives two parameters, the exporting
- * options, and the error from the module.
- *
- * @see [fallbackToExportServer](#exporting.fallbackToExportServer)
- *
- * @type {Highcharts.ExportingErrorCallbackFunction}
- * @since 5.0.0
- * @requires modules/exporting
- * @requires modules/offline-exporting
- * @apioption exporting.error
- */
- /**
- * Whether or not to fall back to the export server if the offline-exporting
- * module is unable to export the chart on the client side. This happens for
- * certain browsers, and certain features (e.g.
- * [allowHTML](#exporting.allowHTML)), depending on the image type exporting
- * to. For very complex charts, it is possible that export can fail in
- * browsers that don't support Blob objects, due to data URL length limits.
- * It is recommended to define the [exporting.error](#exporting.error)
- * handler if disabling fallback, in order to notify users in case export
- * fails.
- *
- * @type {boolean}
- * @default true
- * @since 4.1.8
- * @requires modules/exporting
- * @requires modules/offline-exporting
- * @apioption exporting.fallbackToExportServer
- */
- /**
- * The filename, without extension, to use for the exported chart.
- *
- * @sample {highcharts} highcharts/exporting/filename/
- * Custom file name
- * @sample {highstock} highcharts/exporting/filename/
- * Custom file name
- *
- * @type {string}
- * @default chart
- * @since 2.0
- * @apioption exporting.filename
- */
- /**
- * An object containing additional key value data for the POST form that
- * sends the SVG to the export server. For example, a `target` can be set to
- * make sure the generated image is received in another frame, or a custom
- * `enctype` or `encoding` can be set.
- *
- * @type {Highcharts.HTMLAttributes}
- * @since 3.0.8
- * @apioption exporting.formAttributes
- */
- /**
- * Path where Highcharts will look for export module dependencies to
- * load on demand if they don't already exist on `window`. Should currently
- * point to location of [CanVG](https://github.com/canvg/canvg) library,
- * [jsPDF](https://github.com/yWorks/jsPDF) and
- * [svg2pdf.js](https://github.com/yWorks/svg2pdf.js), required for client
- * side export in certain browsers.
- *
- * @type {string}
- * @default https://code.highcharts.com/{version}/lib
- * @since 5.0.0
- * @apioption exporting.libURL
- */
- /**
- * Analogous to [sourceWidth](#exporting.sourceWidth).
- *
- * @type {number}
- * @since 3.0
- * @apioption exporting.sourceHeight
- */
- /**
- * The width of the original chart when exported, unless an explicit
- * [chart.width](#chart.width) is set, or a pixel width is set on the
- * container. The width exported raster image is then multiplied by
- * [scale](#exporting.scale).
- *
- * @sample {highcharts} highcharts/exporting/sourcewidth/
- * Source size demo
- * @sample {highstock} highcharts/exporting/sourcewidth/
- * Source size demo
- * @sample {highmaps} maps/exporting/sourcewidth/
- * Source size demo
- *
- * @type {number}
- * @since 3.0
- * @apioption exporting.sourceWidth
- */
- /**
- * The pixel width of charts exported to PNG or JPG. As of Highcharts
- * 3.0, the default pixel width is a function of the [chart.width](
- * #chart.width) or [exporting.sourceWidth](#exporting.sourceWidth) and the
- * [exporting.scale](#exporting.scale).
- *
- * @sample {highcharts} highcharts/exporting/width/
- * Export to 200px wide images
- * @sample {highstock} highcharts/exporting/width/
- * Export to 200px wide images
- *
- * @type {number}
- * @since 2.0
- * @apioption exporting.width
- */
- /**
- * Default MIME type for exporting if `chart.exportChart()` is called
- * without specifying a `type` option. Possible values are `image/png`,
- * `image/jpeg`, `application/pdf` and `image/svg+xml`.
- *
- * @type {Highcharts.ExportingMimeTypeValue}
- * @since 2.0
- */
- type: 'image/png',
- /**
- * The URL for the server module converting the SVG string to an image
- * format. By default this points to Highchart's free web service.
- *
- * @since 2.0
- */
- url: 'https://export.highcharts.com/',
- /**
- * When printing the chart from the menu item in the burger menu, if
- * the on-screen chart exceeds this width, it is resized. After printing
- * or cancelled, it is restored. The default width makes the chart
- * fit into typical paper format. Note that this does not affect the
- * chart when printing the web page as a whole.
- *
- * @since 4.2.5
- */
- printMaxWidth: 780,
- /**
- * Defines the scale or zoom factor for the exported image compared
- * to the on-screen display. While for instance a 600px wide chart
- * may look good on a website, it will look bad in print. The default
- * scale of 2 makes this chart export to a 1200px PNG or JPG.
- *
- * @see [chart.width](#chart.width)
- * @see [exporting.sourceWidth](#exporting.sourceWidth)
- *
- * @sample {highcharts} highcharts/exporting/scale/
- * Scale demonstrated
- * @sample {highstock} highcharts/exporting/scale/
- * Scale demonstrated
- * @sample {highmaps} maps/exporting/scale/
- * Scale demonstrated
- *
- * @since 3.0
- */
- scale: 2,
- /**
- * Options for the export related buttons, print and export. In addition
- * to the default buttons listed here, custom buttons can be added.
- * See [navigation.buttonOptions](#navigation.buttonOptions) for general
- * options.
- *
- * @type {Highcharts.Dictionary<*>}
- * @requires modules/exporting
- */
- buttons: {
- /**
- * Options for the export button.
- *
- * In styled mode, export button styles can be applied with the
- * `.highcharts-contextbutton` class.
- *
- * @declare Highcharts.ExportingButtonsOptionsObject
- * @extends navigation.buttonOptions
- * @requires modules/exporting
- */
- contextButton: {
- /**
- * A click handler callback to use on the button directly instead of
- * the popup menu.
- *
- * @sample highcharts/exporting/buttons-contextbutton-onclick/
- * Skip the menu and export the chart directly
- *
- * @type {Function}
- * @since 2.0
- * @apioption exporting.buttons.contextButton.onclick
- */
- /**
- * See [navigation.buttonOptions.symbolFill](
- * #navigation.buttonOptions.symbolFill).
- *
- * @type {Highcharts.ColorString}
- * @default #666666
- * @since 2.0
- * @apioption exporting.buttons.contextButton.symbolFill
- */
- /**
- * The horizontal position of the button relative to the `align`
- * option.
- *
- * @type {number}
- * @default -10
- * @since 2.0
- * @apioption exporting.buttons.contextButton.x
- */
- /**
- * The class name of the context button.
- */
- className: 'highcharts-contextbutton',
- /**
- * The class name of the menu appearing from the button.
- */
- menuClassName: 'highcharts-contextmenu',
- /**
- * The symbol for the button. Points to a definition function in
- * the `Highcharts.Renderer.symbols` collection. The default
- * `menu` function is part of the exporting module. Possible
- * values are "circle", "square", "diamond", "triangle",
- * "triangle-down", "menu", "menuball" or custom shape.
- *
- * @sample highcharts/exporting/buttons-contextbutton-symbol/
- * Use a circle for symbol
- * @sample highcharts/exporting/buttons-contextbutton-symbol-custom/
- * Custom shape as symbol
- *
- * @type {Highcharts.SymbolKeyValue|"menu"|"menuball"|string}
- * @since 2.0
- */
- symbol: 'menu',
- /**
- * The key to a [lang](#lang) option setting that is used for the
- * button's title tooltip. When the key is `contextButtonTitle`, it
- * refers to [lang.contextButtonTitle](#lang.contextButtonTitle)
- * that defaults to "Chart context menu".
- *
- * @since 6.1.4
- */
- titleKey: 'contextButtonTitle',
- /**
- * This option is deprecated, use
- * [titleKey](#exporting.buttons.contextButton.titleKey) instead.
- *
- * @deprecated
- * @type {string}
- * @apioption exporting.buttons.contextButton._titleKey
- */
- /**
- * A collection of strings pointing to config options for the menu
- * items. The config options are defined in the
- * `menuItemDefinitions` option.
- *
- * By default, there is the "View in full screen" and "Print" menu
- * items, plus one menu item for each of the available export types.
- *
- * @sample {highcharts} highcharts/exporting/menuitemdefinitions/
- * Menu item definitions
- * @sample {highstock} highcharts/exporting/menuitemdefinitions/
- * Menu item definitions
- * @sample {highmaps} highcharts/exporting/menuitemdefinitions/
- * Menu item definitions
- *
- * @type {Array<string>}
- * @default ["viewFullscreen", "printChart", "separator", "downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG"]
- * @since 2.0
- */
- menuItems: [
- 'viewFullscreen',
- 'printChart',
- 'separator',
- 'downloadPNG',
- 'downloadJPEG',
- 'downloadPDF',
- 'downloadSVG'
- ]
- }
- },
- /**
- * An object consisting of definitions for the menu items in the context
- * menu. Each key value pair has a `key` that is referenced in the
- * [menuItems](#exporting.buttons.contextButton.menuItems) setting,
- * and a `value`, which is an object with the following properties:
- *
- * - **onclick:** The click handler for the menu item
- *
- * - **text:** The text for the menu item
- *
- * - **textKey:** If internationalization is required, the key to a language
- * string
- *
- * Custom text for the "exitFullScreen" can be set only in lang options
- * (it is not a separate button).
- *
- * @sample {highcharts} highcharts/exporting/menuitemdefinitions/
- * Menu item definitions
- * @sample {highstock} highcharts/exporting/menuitemdefinitions/
- * Menu item definitions
- * @sample {highmaps} highcharts/exporting/menuitemdefinitions/
- * Menu item definitions
- *
- *
- * @type {Highcharts.Dictionary<Highcharts.ExportingMenuObject>}
- * @default {"viewFullscreen": {}, "printChart": {}, "separator": {}, "downloadPNG": {}, "downloadJPEG": {}, "downloadPDF": {}, "downloadSVG": {}}
- * @since 5.0.13
- */
- menuItemDefinitions: {
- /**
- * @ignore
- */
- viewFullscreen: {
- textKey: 'viewFullscreen',
- onclick: function () {
- this.fullscreen.toggle();
- }
- },
- /**
- * @ignore
- */
- printChart: {
- textKey: 'printChart',
- onclick: function () {
- this.print();
- }
- },
- /**
- * @ignore
- */
- separator: {
- separator: true
- },
- /**
- * @ignore
- */
- downloadPNG: {
- textKey: 'downloadPNG',
- onclick: function () {
- this.exportChart();
- }
- },
- /**
- * @ignore
- */
- downloadJPEG: {
- textKey: 'downloadJPEG',
- onclick: function () {
- this.exportChart({
- type: 'image/jpeg'
- });
- }
- },
- /**
- * @ignore
- */
- downloadPDF: {
- textKey: 'downloadPDF',
- onclick: function () {
- this.exportChart({
- type: 'application/pdf'
- });
- }
- },
- /**
- * @ignore
- */
- downloadSVG: {
- textKey: 'downloadSVG',
- onclick: function () {
- this.exportChart({
- type: 'image/svg+xml'
- });
- }
- }
- }
- };
- /**
- * Fires after a chart is printed through the context menu item or the
- * `Chart.print` method.
- *
- * @sample highcharts/chart/events-beforeprint-afterprint/
- * Rescale the chart to print
- *
- * @type {Highcharts.ExportingAfterPrintCallbackFunction}
- * @since 4.1.0
- * @context Highcharts.Chart
- * @requires modules/exporting
- * @apioption chart.events.afterPrint
- */
- /**
- * Fires before a chart is printed through the context menu item or
- * the `Chart.print` method.
- *
- * @sample highcharts/chart/events-beforeprint-afterprint/
- * Rescale the chart to print
- *
- * @type {Highcharts.ExportingBeforePrintCallbackFunction}
- * @since 4.1.0
- * @context Highcharts.Chart
- * @requires modules/exporting
- * @apioption chart.events.beforePrint
- */
- /**
- * The post utility
- *
- * @private
- * @function Highcharts.post
- * @param {string} url
- * Post URL
- * @param {object} data
- * Post data
- * @param {Highcharts.Dictionary<string>} [formAttributes]
- * Additional attributes for the post request
- * @return {void}
- */
- H.post = function (url, data, formAttributes) {
- // create the form
- var form = createElement('form',
- merge({
- method: 'post',
- action: url,
- enctype: 'multipart/form-data'
- },
- formAttributes), {
- display: 'none'
- },
- doc.body);
- // add the data
- objectEach(data, function (val, name) {
- createElement('input', {
- type: 'hidden',
- name: name,
- value: val
- }, null, form);
- });
- // submit
- form.submit();
- // clean up
- discardElement(form);
- };
- if (H.isSafari) {
- H.win.matchMedia('print').addListener(function (mqlEvent) {
- if (!H.printingChart) {
- return void 0;
- }
- if (mqlEvent.matches) {
- H.printingChart.beforePrint();
- }
- else {
- H.printingChart.afterPrint();
- }
- });
- }
- extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {
- /* eslint-disable no-invalid-this, valid-jsdoc */
- /**
- * Exporting module only. A collection of fixes on the produced SVG to
- * account for expando properties, browser bugs, VML problems and other.
- * Returns a cleaned SVG.
- *
- * @private
- * @function Highcharts.Chart#sanitizeSVG
- * @param {string} svg
- * SVG code to sanitize
- * @param {Highcharts.Options} options
- * Chart options to apply
- * @return {string}
- * Sanitized SVG code
- * @requires modules/exporting
- */
- sanitizeSVG: function (svg, options) {
- var split = svg.indexOf('</svg>') + 6,
- html = svg.substr(split);
- // Remove any HTML added to the container after the SVG (#894, #9087)
- svg = svg.substr(0, split);
- // Move HTML into a foreignObject
- if (options && options.exporting && options.exporting.allowHTML) {
- if (html) {
- html = '<foreignObject x="0" y="0" ' +
- 'width="' + options.chart.width + '" ' +
- 'height="' + options.chart.height + '">' +
- '<body xmlns="http://www.w3.org/1999/xhtml">' +
- // Some tags needs to be closed in xhtml (#13726)
- html.replace(/(<(?:img|br).*?(?=\>))>/g, '$1 />') +
- '</body>' +
- '</foreignObject>';
- svg = svg.replace('</svg>', html + '</svg>');
- }
- }
- svg = svg
- .replace(/zIndex="[^"]+"/g, '')
- .replace(/symbolName="[^"]+"/g, '')
- .replace(/jQuery[0-9]+="[^"]+"/g, '')
- .replace(/url\(("|")(.*?)("|")\;?\)/g, 'url($2)')
- .replace(/url\([^#]+#/g, 'url(#')
- .replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ')
- .replace(/ (|NS[0-9]+\:)href=/g, ' xlink:href=') // #3567
- .replace(/\n/, ' ')
- // Batik doesn't support rgba fills and strokes (#3095)
- .replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g, // eslint-disable-line max-len
- '$1="rgb($2)" $1-opacity="$3"')
- // Replace HTML entities, issue #347
- .replace(/ /g, '\u00A0') // no-break space
- .replace(/­/g, '\u00AD'); // soft hyphen
- // Further sanitize for oldIE
- if (this.ieSanitizeSVG) {
- svg = this.ieSanitizeSVG(svg);
- }
- return svg;
- },
- /**
- * Return the unfiltered innerHTML of the chart container. Used as hook for
- * plugins. In styled mode, it also takes care of inlining CSS style rules.
- *
- * @see Chart#getSVG
- *
- * @function Highcharts.Chart#getChartHTML
- *
- * @returns {string}
- * The unfiltered SVG of the chart.
- *
- * @requires modules/exporting
- */
- getChartHTML: function () {
- if (this.styledMode) {
- this.inlineStyles();
- }
- return this.container.innerHTML;
- },
- /**
- * Return an SVG representation of the chart.
- *
- * @sample highcharts/members/chart-getsvg/
- * View the SVG from a button
- *
- * @function Highcharts.Chart#getSVG
- *
- * @param {Highcharts.Options} [chartOptions]
- * Additional chart options for the generated SVG representation. For
- * collections like `xAxis`, `yAxis` or `series`, the additional
- * options is either merged in to the original item of the same
- * `id`, or to the first item if a common id is not found.
- *
- * @return {string}
- * The SVG representation of the rendered chart.
- *
- * @fires Highcharts.Chart#event:getSVG
- *
- * @requires modules/exporting
- */
- getSVG: function (chartOptions) {
- var chart = this,
- chartCopy,
- sandbox,
- svg,
- seriesOptions,
- sourceWidth,
- sourceHeight,
- cssWidth,
- cssHeight,
- // Copy the options and add extra options
- options = merge(chart.options,
- chartOptions);
- // Use userOptions to make the options chain in series right (#3881)
- options.plotOptions = merge(chart.userOptions.plotOptions, chartOptions && chartOptions.plotOptions);
- // ... and likewise with time, avoid that undefined time properties are
- // merged over legacy global time options
- options.time = merge(chart.userOptions.time, chartOptions && chartOptions.time);
- // create a sandbox where a new chart will be generated
- sandbox = createElement('div', null, {
- position: 'absolute',
- top: '-9999em',
- width: chart.chartWidth + 'px',
- height: chart.chartHeight + 'px'
- }, doc.body);
- // get the source size
- cssWidth = chart.renderTo.style.width;
- cssHeight = chart.renderTo.style.height;
- sourceWidth = options.exporting.sourceWidth ||
- options.chart.width ||
- (/px$/.test(cssWidth) && parseInt(cssWidth, 10)) ||
- (options.isGantt ? 800 : 600);
- sourceHeight = options.exporting.sourceHeight ||
- options.chart.height ||
- (/px$/.test(cssHeight) && parseInt(cssHeight, 10)) ||
- 400;
- // override some options
- extend(options.chart, {
- animation: false,
- renderTo: sandbox,
- forExport: true,
- renderer: 'SVGRenderer',
- width: sourceWidth,
- height: sourceHeight
- });
- options.exporting.enabled = false; // hide buttons in print
- delete options.data; // #3004
- // prepare for replicating the chart
- options.series = [];
- chart.series.forEach(function (serie) {
- seriesOptions = merge(serie.userOptions, {
- animation: false,
- enableMouseTracking: false,
- showCheckbox: false,
- visible: serie.visible
- });
- // Used for the navigator series that has its own option set
- if (!seriesOptions.isInternal) {
- options.series.push(seriesOptions);
- }
- });
- var colls = {};
- chart.axes.forEach(function (axis) {
- // Assign an internal key to ensure a one-to-one mapping (#5924)
- if (!axis.userOptions.internalKey) { // #6444
- axis.userOptions.internalKey = uniqueKey();
- }
- if (!axis.options.isInternal) {
- if (!colls[axis.coll]) {
- colls[axis.coll] = true;
- options[axis.coll] = [];
- }
- options[axis.coll].push(merge(axis.userOptions, {
- visible: axis.visible
- }));
- }
- });
- // generate the chart copy
- chartCopy = new Chart(options, chart.callback);
- // Axis options and series options (#2022, #3900, #5982)
- if (chartOptions) {
- ['xAxis', 'yAxis', 'series'].forEach(function (coll) {
- var collOptions = {};
- if (chartOptions[coll]) {
- collOptions[coll] = chartOptions[coll];
- chartCopy.update(collOptions);
- }
- });
- }
- // Reflect axis extremes in the export (#5924)
- chart.axes.forEach(function (axis) {
- var axisCopy = find(chartCopy.axes,
- function (copy) {
- return copy.options.internalKey ===
- axis.userOptions.internalKey;
- }), extremes = axis.getExtremes(), userMin = extremes.userMin, userMax = extremes.userMax;
- if (axisCopy &&
- ((typeof userMin !== 'undefined' &&
- userMin !== axisCopy.min) || (typeof userMax !== 'undefined' &&
- userMax !== axisCopy.max))) {
- axisCopy.setExtremes(userMin, userMax, true, false);
- }
- });
- // Get the SVG from the container's innerHTML
- svg = chartCopy.getChartHTML();
- fireEvent(this, 'getSVG', { chartCopy: chartCopy });
- svg = chart.sanitizeSVG(svg, options);
- // free up memory
- options = null;
- chartCopy.destroy();
- discardElement(sandbox);
- return svg;
- },
- /**
- * @private
- * @function Highcharts.Chart#getSVGForExport
- * @param {Highcharts.ExportingOptions} options
- * @param {Highcharts.Options} chartOptions
- * @return {string}
- * @requires modules/exporting
- */
- getSVGForExport: function (options, chartOptions) {
- var chartExportingOptions = this.options.exporting;
- return this.getSVG(merge({ chart: { borderRadius: 0 } }, chartExportingOptions.chartOptions, chartOptions, {
- exporting: {
- sourceWidth: ((options && options.sourceWidth) ||
- chartExportingOptions.sourceWidth),
- sourceHeight: ((options && options.sourceHeight) ||
- chartExportingOptions.sourceHeight)
- }
- }));
- },
- /**
- * Get the default file name used for exported charts. By default it creates
- * a file name based on the chart title.
- *
- * @function Highcharts.Chart#getFilename
- *
- * @return {string} A file name without extension.
- *
- * @requires modules/exporting
- */
- getFilename: function () {
- var s = this.userOptions.title && this.userOptions.title.text,
- filename = this.options.exporting.filename;
- if (filename) {
- return filename.replace(/\//g, '-');
- }
- if (typeof s === 'string') {
- filename = s
- .toLowerCase()
- .replace(/<\/?[^>]+(>|$)/g, '') // strip HTML tags
- .replace(/[\s_]+/g, '-')
- .replace(/[^a-z0-9\-]/g, '') // preserve only latin
- .replace(/^[\-]+/g, '') // dashes in the start
- .replace(/[\-]+/g, '-') // dashes in a row
- .substr(0, 24)
- .replace(/[\-]+$/g, ''); // dashes in the end;
- }
- if (!filename || filename.length < 5) {
- filename = 'chart';
- }
- return filename;
- },
- /**
- * Exporting module required. Submit an SVG version of the chart to a server
- * along with some parameters for conversion.
- *
- * @sample highcharts/members/chart-exportchart/
- * Export with no options
- * @sample highcharts/members/chart-exportchart-filename/
- * PDF type and custom filename
- * @sample highcharts/members/chart-exportchart-custom-background/
- * Different chart background in export
- * @sample stock/members/chart-exportchart/
- * Export with Highcharts Stock
- *
- * @function Highcharts.Chart#exportChart
- *
- * @param {Highcharts.ExportingOptions} exportingOptions
- * Exporting options in addition to those defined in
- * [exporting](https://api.highcharts.com/highcharts/exporting).
- *
- * @param {Highcharts.Options} chartOptions
- * Additional chart options for the exported chart. For example a
- * different background color can be added here, or `dataLabels` for
- * export only.
- *
- * @return {void}
- *
- * @requires modules/exporting
- */
- exportChart: function (exportingOptions, chartOptions) {
- var svg = this.getSVGForExport(exportingOptions,
- chartOptions);
- // merge the options
- exportingOptions = merge(this.options.exporting, exportingOptions);
- // do the post
- H.post(exportingOptions.url, {
- filename: exportingOptions.filename ? exportingOptions.filename.replace(/\//g, '-') : this.getFilename(),
- type: exportingOptions.type,
- // IE8 fails to post undefined correctly, so use 0
- width: exportingOptions.width || 0,
- scale: exportingOptions.scale,
- svg: svg
- }, exportingOptions.formAttributes);
- },
- /**
- * Move the chart container(s) to another div.
- *
- * @function Highcharts#moveContainers
- *
- * @private
- *
- * @param {Highcharts.HTMLDOMElement} moveTo
- * Move target
- * @return {void}
- */
- moveContainers: function (moveTo) {
- var chart = this;
- (chart.fixedDiv ? // When scrollablePlotArea is active (#9533)
- [chart.fixedDiv, chart.scrollingContainer] :
- [chart.container]).forEach(function (div) {
- moveTo.appendChild(div);
- });
- },
- /**
- * Prepare chart and document before printing a chart.
- *
- * @function Highcharts#beforePrint
- *
- * @private
- *
- * @return {void}
- *
- * @fires Highcharts.Chart#event:beforePrint
- */
- beforePrint: function () {
- var chart = this,
- body = doc.body,
- printMaxWidth = chart.options.exporting.printMaxWidth,
- printReverseInfo = {
- childNodes: body.childNodes,
- origDisplay: [],
- resetParams: void 0
- };
- var handleMaxWidth;
- chart.isPrinting = true;
- chart.pointer.reset(null, 0);
- fireEvent(chart, 'beforePrint');
- // Handle printMaxWidth
- handleMaxWidth = printMaxWidth && chart.chartWidth > printMaxWidth;
- if (handleMaxWidth) {
- printReverseInfo.resetParams = [
- chart.options.chart.width,
- void 0,
- false
- ];
- chart.setSize(printMaxWidth, void 0, false);
- }
- // hide all body content
- [].forEach.call(printReverseInfo.childNodes, function (node, i) {
- if (node.nodeType === 1) {
- printReverseInfo.origDisplay[i] = node.style.display;
- node.style.display = 'none';
- }
- });
- // pull out the chart
- chart.moveContainers(body);
- // Storage details for undo action after printing
- chart.printReverseInfo = printReverseInfo;
- },
- /**
- * Clena up after printing a chart.
- *
- * @function Highcharts#afterPrint
- *
- * @private
- *
- * @param {Highcharts.Chart} chart
- * Chart that was (or suppose to be) printed
- * @return {void}
- *
- * @fires Highcharts.Chart#event:afterPrint
- */
- afterPrint: function () {
- var chart = this;
- if (!chart.printReverseInfo) {
- return void 0;
- }
- var childNodes = chart.printReverseInfo.childNodes,
- origDisplay = chart.printReverseInfo.origDisplay,
- resetParams = chart.printReverseInfo.resetParams;
- // put the chart back in
- chart.moveContainers(chart.renderTo);
- // restore all body content
- [].forEach.call(childNodes, function (node, i) {
- if (node.nodeType === 1) {
- node.style.display = (origDisplay[i] || '');
- }
- });
- chart.isPrinting = false;
- // Reset printMaxWidth
- if (resetParams) {
- chart.setSize.apply(chart, resetParams);
- }
- delete chart.printReverseInfo;
- delete H.printingChart;
- fireEvent(chart, 'afterPrint');
- },
- /**
- * Exporting module required. Clears away other elements in the page and
- * prints the chart as it is displayed. By default, when the exporting
- * module is enabled, a context button with a drop down menu in the upper
- * right corner accesses this function.
- *
- * @sample highcharts/members/chart-print/
- * Print from a HTML button
- *
- * @function Highcharts.Chart#print
- *
- * @return {void}
- *
- * @fires Highcharts.Chart#event:beforePrint
- * @fires Highcharts.Chart#event:afterPrint
- *
- * @requires modules/exporting
- */
- print: function () {
- var chart = this;
- if (chart.isPrinting) { // block the button while in printing mode
- return;
- }
- H.printingChart = chart;
- if (!H.isSafari) {
- chart.beforePrint();
- }
- // Give the browser time to draw WebGL content, an issue that randomly
- // appears (at least) in Chrome ~67 on the Mac (#8708).
- setTimeout(function () {
- win.focus(); // #1510
- win.print();
- // allow the browser to prepare before reverting
- if (!H.isSafari) {
- setTimeout(function () {
- chart.afterPrint();
- }, 1000);
- }
- }, 1);
- },
- /**
- * Display a popup menu for choosing the export type.
- *
- * @private
- * @function Highcharts.Chart#contextMenu
- * @param {string} className
- * An identifier for the menu.
- * @param {Array<string|Highcharts.ExportingMenuObject>} items
- * A collection with text and onclicks for the items.
- * @param {number} x
- * The x position of the opener button
- * @param {number} y
- * The y position of the opener button
- * @param {number} width
- * The width of the opener button
- * @param {number} height
- * The height of the opener button
- * @return {void}
- * @requires modules/exporting
- */
- contextMenu: function (className, items, x, y, width, height, button) {
- var chart = this,
- navOptions = chart.options.navigation,
- chartWidth = chart.chartWidth,
- chartHeight = chart.chartHeight,
- cacheName = 'cache-' + className,
- menu = chart[cacheName],
- menuPadding = Math.max(width,
- height), // for mouse leave detection
- innerMenu,
- menuStyle;
- // create the menu only the first time
- if (!menu) {
- // create a HTML element above the SVG
- chart.exportContextMenu = chart[cacheName] = menu =
- createElement('div', {
- className: className
- }, {
- position: 'absolute',
- zIndex: 1000,
- padding: menuPadding + 'px',
- pointerEvents: 'auto'
- }, chart.fixedDiv || chart.container);
- innerMenu = createElement('ul', { className: 'highcharts-menu' }, {
- listStyle: 'none',
- margin: 0,
- padding: 0
- }, menu);
- // Presentational CSS
- if (!chart.styledMode) {
- css(innerMenu, extend({
- MozBoxShadow: '3px 3px 10px #888',
- WebkitBoxShadow: '3px 3px 10px #888',
- boxShadow: '3px 3px 10px #888'
- }, navOptions.menuStyle));
- }
- // hide on mouse out
- menu.hideMenu = function () {
- css(menu, { display: 'none' });
- if (button) {
- button.setState(0);
- }
- chart.openMenu = false;
- // #10361, #9998
- css(chart.renderTo, { overflow: 'hidden' });
- css(chart.container, { overflow: 'hidden' });
- U.clearTimeout(menu.hideTimer);
- fireEvent(chart, 'exportMenuHidden');
- };
- // Hide the menu some time after mouse leave (#1357)
- chart.exportEvents.push(addEvent(menu, 'mouseleave', function () {
- menu.hideTimer = win.setTimeout(menu.hideMenu, 500);
- }), addEvent(menu, 'mouseenter', function () {
- U.clearTimeout(menu.hideTimer);
- }),
- // Hide it on clicking or touching outside the menu (#2258,
- // #2335, #2407)
- addEvent(doc, 'mouseup', function (e) {
- if (!chart.pointer.inClass(e.target, className)) {
- menu.hideMenu();
- }
- }), addEvent(menu, 'click', function () {
- if (chart.openMenu) {
- menu.hideMenu();
- }
- }));
- // create the items
- items.forEach(function (item) {
- if (typeof item === 'string') {
- item = chart.options.exporting
- .menuItemDefinitions[item];
- }
- if (isObject(item, true)) {
- var element = void 0;
- if (item.separator) {
- element = createElement('hr', null, null, innerMenu);
- }
- else {
- // When chart initialized with the table,
- // wrong button text displayed, #14352.
- if (item.textKey === 'viewData' && chart.isDataTableVisible) {
- item.textKey = 'hideData';
- }
- element = createElement('li', {
- className: 'highcharts-menu-item',
- onclick: function (e) {
- if (e) { // IE7
- e.stopPropagation();
- }
- menu.hideMenu();
- if (item.onclick) {
- item.onclick
- .apply(chart, arguments);
- }
- }
- }, null, innerMenu);
- element.appendChild(doc.createTextNode(item.text ||
- chart.options.lang[item.textKey]));
- if (!chart.styledMode) {
- element.onmouseover = function () {
- css(this, navOptions.menuItemHoverStyle);
- };
- element.onmouseout = function () {
- css(this, navOptions.menuItemStyle);
- };
- css(element, extend({
- cursor: 'pointer'
- }, navOptions.menuItemStyle));
- }
- }
- // Keep references to menu divs to be able to destroy them
- chart.exportDivElements.push(element);
- }
- });
- // Keep references to menu and innerMenu div to be able to destroy
- // them
- chart.exportDivElements.push(innerMenu, menu);
- chart.exportMenuWidth = menu.offsetWidth;
- chart.exportMenuHeight = menu.offsetHeight;
- }
- menuStyle = { display: 'block' };
- // if outside right, right align it
- if (x + chart.exportMenuWidth > chartWidth) {
- menuStyle.right = (chartWidth - x - width - menuPadding) + 'px';
- }
- else {
- menuStyle.left = (x - menuPadding) + 'px';
- }
- // if outside bottom, bottom align it
- if (y + height + chart.exportMenuHeight > chartHeight &&
- button.alignOptions.verticalAlign !== 'top') {
- menuStyle.bottom = (chartHeight - y - menuPadding) + 'px';
- }
- else {
- menuStyle.top = (y + height - menuPadding) + 'px';
- }
- css(menu, menuStyle);
- // #10361, #9998
- css(chart.renderTo, { overflow: '' });
- css(chart.container, { overflow: '' });
- chart.openMenu = true;
- fireEvent(chart, 'exportMenuShown');
- },
- /**
- * Add the export button to the chart, with options.
- *
- * @private
- * @function Highcharts.Chart#addButton
- * @param {Highcharts.NavigationButtonOptions} options
- * @return {void}
- * @requires modules/exporting
- */
- addButton: function (options) {
- var chart = this,
- renderer = chart.renderer,
- btnOptions = merge(chart.options.navigation.buttonOptions,
- options),
- onclick = btnOptions.onclick,
- menuItems = btnOptions.menuItems,
- symbol,
- button,
- symbolSize = btnOptions.symbolSize || 12;
- if (!chart.btnCount) {
- chart.btnCount = 0;
- }
- // Keeps references to the button elements
- if (!chart.exportDivElements) {
- chart.exportDivElements = [];
- chart.exportSVGElements = [];
- }
- if (btnOptions.enabled === false || !btnOptions.theme) {
- return;
- }
- var attr = btnOptions.theme,
- states = attr.states,
- hover = states && states.hover,
- select = states && states.select,
- callback;
- if (!chart.styledMode) {
- attr.fill = pick(attr.fill, palette.backgroundColor);
- attr.stroke = pick(attr.stroke, 'none');
- }
- delete attr.states;
- if (onclick) {
- callback = function (e) {
- if (e) {
- e.stopPropagation();
- }
- onclick.call(chart, e);
- };
- }
- else if (menuItems) {
- callback = function (e) {
- // consistent with onclick call (#3495)
- if (e) {
- e.stopPropagation();
- }
- chart.contextMenu(button.menuClassName, menuItems, button.translateX, button.translateY, button.width, button.height, button);
- button.setState(2);
- };
- }
- if (btnOptions.text && btnOptions.symbol) {
- attr.paddingLeft = pick(attr.paddingLeft, 30);
- }
- else if (!btnOptions.text) {
- extend(attr, {
- width: btnOptions.width,
- height: btnOptions.height,
- padding: 0
- });
- }
- if (!chart.styledMode) {
- attr['stroke-linecap'] = 'round';
- attr.fill = pick(attr.fill, palette.backgroundColor);
- attr.stroke = pick(attr.stroke, 'none');
- }
- button = renderer
- .button(btnOptions.text, 0, 0, callback, attr, hover, select)
- .addClass(options.className)
- .attr({
- title: pick(chart.options.lang[btnOptions._titleKey || btnOptions.titleKey], '')
- });
- button.menuClassName = (options.menuClassName ||
- 'highcharts-menu-' + chart.btnCount++);
- if (btnOptions.symbol) {
- symbol = renderer
- .symbol(btnOptions.symbol, btnOptions.symbolX - (symbolSize / 2), btnOptions.symbolY - (symbolSize / 2), symbolSize, symbolSize
- // If symbol is an image, scale it (#7957)
- , {
- width: symbolSize,
- height: symbolSize
- })
- .addClass('highcharts-button-symbol')
- .attr({
- zIndex: 1
- })
- .add(button);
- if (!chart.styledMode) {
- symbol.attr({
- stroke: btnOptions.symbolStroke,
- fill: btnOptions.symbolFill,
- 'stroke-width': btnOptions.symbolStrokeWidth || 1
- });
- }
- }
- button
- .add(chart.exportingGroup)
- .align(extend(btnOptions, {
- width: button.width,
- x: pick(btnOptions.x, chart.buttonOffset) // #1654
- }), true, 'spacingBox');
- chart.buttonOffset += ((button.width + btnOptions.buttonSpacing) *
- (btnOptions.align === 'right' ? -1 : 1));
- chart.exportSVGElements.push(button, symbol);
- },
- /**
- * Destroy the export buttons.
- * @private
- * @function Highcharts.Chart#destroyExport
- * @param {global.Event} [e]
- * @return {void}
- * @requires modules/exporting
- */
- destroyExport: function (e) {
- var chart = e ? e.target : this,
- exportSVGElements = chart.exportSVGElements,
- exportDivElements = chart.exportDivElements,
- exportEvents = chart.exportEvents,
- cacheName;
- // Destroy the extra buttons added
- if (exportSVGElements) {
- exportSVGElements.forEach(function (elem, i) {
- // Destroy and null the svg elements
- if (elem) { // #1822
- elem.onclick = elem.ontouchstart = null;
- cacheName = 'cache-' + elem.menuClassName;
- if (chart[cacheName]) {
- delete chart[cacheName];
- }
- chart.exportSVGElements[i] = elem.destroy();
- }
- });
- exportSVGElements.length = 0;
- }
- // Destroy the exporting group
- if (chart.exportingGroup) {
- chart.exportingGroup.destroy();
- delete chart.exportingGroup;
- }
- // Destroy the divs for the menu
- if (exportDivElements) {
- exportDivElements.forEach(function (elem, i) {
- // Remove the event handler
- U.clearTimeout(elem.hideTimer); // #5427
- removeEvent(elem, 'mouseleave');
- // Remove inline events
- chart.exportDivElements[i] =
- elem.onmouseout =
- elem.onmouseover =
- elem.ontouchstart =
- elem.onclick = null;
- // Destroy the div by moving to garbage bin
- discardElement(elem);
- });
- exportDivElements.length = 0;
- }
- if (exportEvents) {
- exportEvents.forEach(function (unbind) {
- unbind();
- });
- exportEvents.length = 0;
- }
- }
- /* eslint-enable no-invalid-this, valid-jsdoc */
- });
- // These ones are translated to attributes rather than styles
- SVGRenderer.prototype.inlineToAttributes = [
- 'fill',
- 'stroke',
- 'strokeLinecap',
- 'strokeLinejoin',
- 'strokeWidth',
- 'textAnchor',
- 'x',
- 'y'
- ];
- // These CSS properties are not inlined. Remember camelCase.
- SVGRenderer.prototype.inlineBlacklist = [
- /-/,
- /^(clipPath|cssText|d|height|width)$/,
- /^font$/,
- /[lL]ogical(Width|Height)$/,
- /perspective/,
- /TapHighlightColor/,
- /^transition/,
- /^length$/ // #7700
- // /^text (border|color|cursor|height|webkitBorder)/
- ];
- SVGRenderer.prototype.unstyledElements = [
- 'clipPath',
- 'defs',
- 'desc'
- ];
- /**
- * Analyze inherited styles from stylesheets and add them inline
- *
- * @private
- * @function Highcharts.Chart#inlineStyles
- * @return {void}
- *
- * @todo: What are the border styles for text about? In general, text has a lot
- * of properties.
- * @todo: Make it work with IE9 and IE10.
- *
- * @requires modules/exporting
- */
- Chart.prototype.inlineStyles = function () {
- var renderer = this.renderer,
- inlineToAttributes = renderer.inlineToAttributes,
- blacklist = renderer.inlineBlacklist,
- whitelist = renderer.inlineWhitelist, // For IE
- unstyledElements = renderer.unstyledElements,
- defaultStyles = {},
- dummySVG,
- iframe,
- iframeDoc;
- // Create an iframe where we read default styles without pollution from this
- // body
- iframe = doc.createElement('iframe');
- css(iframe, {
- width: '1px',
- height: '1px',
- visibility: 'hidden'
- });
- doc.body.appendChild(iframe);
- iframeDoc = iframe.contentWindow.document;
- iframeDoc.open();
- iframeDoc.write('<svg xmlns="http://www.w3.org/2000/svg"></svg>');
- iframeDoc.close();
- /**
- * Make hyphenated property names out of camelCase
- * @private
- * @param {string} prop
- * Property name in camelCase
- * @return {string}
- * Hyphenated property name
- */
- function hyphenate(prop) {
- return prop.replace(/([A-Z])/g, function (a, b) {
- return '-' + b.toLowerCase();
- });
- }
- /**
- * Call this on all elements and recurse to children
- * @private
- * @param {Highcharts.HTMLDOMElement} node
- * Element child
- * @return {void}
- */
- function recurse(node) {
- var styles,
- parentStyles,
- cssText = '',
- dummy,
- styleAttr,
- blacklisted,
- whitelisted,
- i;
- /**
- * Check computed styles and whether they are in the white/blacklist for
- * styles or atttributes.
- * @private
- * @param {string} val
- * Style value
- * @param {string} prop
- * Style property name
- * @return {void}
- */
- function filterStyles(val, prop) {
- // Check against whitelist & blacklist
- blacklisted = whitelisted = false;
- if (whitelist) {
- // Styled mode in IE has a whitelist instead.
- // Exclude all props not in this list.
- i = whitelist.length;
- while (i-- && !whitelisted) {
- whitelisted = whitelist[i].test(prop);
- }
- blacklisted = !whitelisted;
- }
- // Explicitly remove empty transforms
- if (prop === 'transform' && val === 'none') {
- blacklisted = true;
- }
- i = blacklist.length;
- while (i-- && !blacklisted) {
- blacklisted = (blacklist[i].test(prop) ||
- typeof val === 'function');
- }
- if (!blacklisted) {
- // If parent node has the same style, it gets inherited, no need
- // to inline it. Top-level props should be diffed against parent
- // (#7687).
- if ((parentStyles[prop] !== val ||
- node.nodeName === 'svg') &&
- defaultStyles[node.nodeName][prop] !== val) {
- // Attributes
- if (!inlineToAttributes ||
- inlineToAttributes.indexOf(prop) !== -1) {
- if (val) {
- node.setAttribute(hyphenate(prop), val);
- }
- // Styles
- }
- else {
- cssText += hyphenate(prop) + ':' + val + ';';
- }
- }
- }
- }
- if (node.nodeType === 1 &&
- unstyledElements.indexOf(node.nodeName) === -1) {
- styles = win.getComputedStyle(node, null);
- parentStyles = node.nodeName === 'svg' ?
- {} :
- win.getComputedStyle(node.parentNode, null);
- // Get default styles from the browser so that we don't have to add
- // these
- if (!defaultStyles[node.nodeName]) {
- /*
- if (!dummySVG) {
- dummySVG = doc.createElementNS(H.SVG_NS, 'svg');
- dummySVG.setAttribute('version', '1.1');
- doc.body.appendChild(dummySVG);
- }
- */
- dummySVG = iframeDoc.getElementsByTagName('svg')[0];
- dummy = iframeDoc.createElementNS(node.namespaceURI, node.nodeName);
- dummySVG.appendChild(dummy);
- // Copy, so we can remove the node
- defaultStyles[node.nodeName] = merge(win.getComputedStyle(dummy, null));
- // Remove default fill, otherwise text disappears when exported
- if (node.nodeName === 'text') {
- delete defaultStyles.text.fill;
- }
- dummySVG.removeChild(dummy);
- }
- // Loop through all styles and add them inline if they are ok
- if (H.isFirefox || H.isMS) {
- // Some browsers put lots of styles on the prototype
- for (var p in styles) { // eslint-disable-line guard-for-in
- filterStyles(styles[p], p);
- }
- }
- else {
- objectEach(styles, filterStyles);
- }
- // Apply styles
- if (cssText) {
- styleAttr = node.getAttribute('style');
- node.setAttribute('style', (styleAttr ? styleAttr + ';' : '') + cssText);
- }
- // Set default stroke width (needed at least for IE)
- if (node.nodeName === 'svg') {
- node.setAttribute('stroke-width', '1px');
- }
- if (node.nodeName === 'text') {
- return;
- }
- // Recurse
- [].forEach.call(node.children || node.childNodes, recurse);
- }
- }
- /**
- * Remove the dummy objects used to get defaults
- * @private
- * @return {void}
- */
- function tearDown() {
- dummySVG.parentNode.removeChild(dummySVG);
- // Remove trash from DOM that stayed after each exporting
- iframe.parentNode.removeChild(iframe);
- }
- recurse(this.container.querySelector('svg'));
- tearDown();
- };
- symbols.menu = function (x, y, width, height) {
- var arr = [
- ['M',
- x,
- y + 2.5],
- ['L',
- x + width,
- y + 2.5],
- ['M',
- x,
- y + height / 2 + 0.5],
- ['L',
- x + width,
- y + height / 2 + 0.5],
- ['M',
- x,
- y + height - 1.5],
- ['L',
- x + width,
- y + height - 1.5]
- ];
- return arr;
- };
- symbols.menuball = function (x, y, width, height) {
- var path = [],
- h = (height / 3) - 2;
- path = path.concat(symbols.circle(width - h, y, h, h), symbols.circle(width - h, y + h + 4, h, h), symbols.circle(width - h, y + 2 * (h + 4), h, h));
- return path;
- };
- /**
- * Add the buttons on chart load
- * @private
- * @function Highcharts.Chart#renderExporting
- * @return {void}
- * @requires modules/exporting
- */
- Chart.prototype.renderExporting = function () {
- var chart = this,
- exportingOptions = chart.options.exporting,
- buttons = exportingOptions.buttons,
- isDirty = chart.isDirtyExporting || !chart.exportSVGElements;
- chart.buttonOffset = 0;
- if (chart.isDirtyExporting) {
- chart.destroyExport();
- }
- if (isDirty && exportingOptions.enabled !== false) {
- chart.exportEvents = [];
- chart.exportingGroup = chart.exportingGroup ||
- chart.renderer.g('exporting-group').attr({
- zIndex: 3 // #4955, // #8392
- }).add();
- objectEach(buttons, function (button) {
- chart.addButton(button);
- });
- chart.isDirtyExporting = false;
- }
- };
- /* eslint-disable no-invalid-this */
- // Add update methods to handle chart.update and chart.exporting.update and
- // chart.navigation.update. These must be added to the chart instance rather
- // than the Chart prototype in order to use the chart instance inside the update
- // function.
- addEvent(Chart, 'init', function () {
- var chart = this;
- /**
- * @private
- * @param {"exporting"|"navigation"} prop
- * Property name in option root
- * @param {Highcharts.ExportingOptions|Highcharts.NavigationOptions} options
- * Options to update
- * @param {boolean} [redraw=true]
- * Whether to redraw
- * @return {void}
- */
- function update(prop, options, redraw) {
- chart.isDirtyExporting = true;
- merge(true, chart.options[prop], options);
- if (pick(redraw, true)) {
- chart.redraw();
- }
- }
- chart.exporting = {
- update: function (options, redraw) {
- update('exporting', options, redraw);
- }
- };
- // Register update() method for navigation. Can not be set the same way as
- // for exporting, because navigation options are shared with bindings which
- // has separate update() logic.
- chartNavigationMixin.addUpdate(function (options, redraw) {
- update('navigation', options, redraw);
- }, chart);
- });
- /* eslint-enable no-invalid-this */
- Chart.prototype.callbacks.push(function (chart) {
- chart.renderExporting();
- addEvent(chart, 'redraw', chart.renderExporting);
- // Destroy the export elements at chart destroy
- addEvent(chart, 'destroy', chart.destroyExport);
- // Uncomment this to see a button directly below the chart, for quick
- // testing of export
- /*
- let button, viewImage, viewSource;
- if (!chart.renderer.forExport) {
- viewImage = function () {
- let div = doc.createElement('div');
- div.innerHTML = chart.getSVGForExport();
- chart.renderTo.parentNode.appendChild(div);
- };
- viewSource = function () {
- let pre = doc.createElement('pre');
- pre.innerHTML = chart.getSVGForExport()
- .replace(/</g, '\n<')
- .replace(/>/g, '>');
- chart.renderTo.parentNode.appendChild(pre);
- };
- viewImage();
- // View SVG Image
- button = doc.createElement('button');
- button.innerHTML = 'View SVG Image';
- chart.renderTo.parentNode.appendChild(button);
- button.onclick = viewImage;
- // View SVG Source
- button = doc.createElement('button');
- button.innerHTML = 'View SVG Source';
- chart.renderTo.parentNode.appendChild(button);
- button.onclick = viewSource;
- }
- //*/
- });
- /* *
- *
- * API Declarations
- *
- * */
- /**
- * Gets fired after a chart is printed through the context menu item or the
- * Chart.print method.
- *
- * @callback Highcharts.ExportingAfterPrintCallbackFunction
- *
- * @param {Highcharts.Chart} chart
- * The chart on which the event occured.
- *
- * @param {global.Event} event
- * The event that occured.
- */
- /**
- * Gets fired before a chart is printed through the context menu item or the
- * Chart.print method.
- *
- * @callback Highcharts.ExportingBeforePrintCallbackFunction
- *
- * @param {Highcharts.Chart} chart
- * The chart on which the event occured.
- *
- * @param {global.Event} event
- * The event that occured.
- */
- /**
- * Function to call if the offline-exporting module fails to export a chart on
- * the client side.
- *
- * @callback Highcharts.ExportingErrorCallbackFunction
- *
- * @param {Highcharts.ExportingOptions} options
- * The exporting options.
- *
- * @param {global.Error} err
- * The error from the module.
- */
- /**
- * Definition for a menu item in the context menu.
- *
- * @interface Highcharts.ExportingMenuObject
- */ /**
- * The text for the menu item.
- *
- * @name Highcharts.ExportingMenuObject#text
- * @type {string|undefined}
- */ /**
- * If internationalization is required, the key to a language string.
- *
- * @name Highcharts.ExportingMenuObject#textKey
- * @type {string|undefined}
- */ /**
- * The click handler for the menu item.
- *
- * @name Highcharts.ExportingMenuObject#onclick
- * @type {Highcharts.EventCallbackFunction<Highcharts.Chart>|undefined}
- */ /**
- * Indicates a separator line instead of an item.
- *
- * @name Highcharts.ExportingMenuObject#separator
- * @type {boolean|undefined}
- */
- /**
- * Possible MIME types for exporting.
- *
- * @typedef {"image/png"|"image/jpeg"|"application/pdf"|"image/svg+xml"} Highcharts.ExportingMimeTypeValue
- */
- (''); // keeps doclets above in transpiled file
- });
- _registerModule(_modules, 'masters/modules/exporting.src.js', [], function () {
- });
- }));
|