drilldown.src.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. /**
  2. * @license Highcharts JS v9.1.1 (2021-06-04)
  3. *
  4. * Highcharts Drilldown module
  5. *
  6. * Author: Torstein Honsi
  7. * License: www.highcharts.com/license
  8. *
  9. */
  10. 'use strict';
  11. (function (factory) {
  12. if (typeof module === 'object' && module.exports) {
  13. factory['default'] = factory;
  14. module.exports = factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/modules/drilldown', ['highcharts'], function (Highcharts) {
  17. factory(Highcharts);
  18. factory.Highcharts = Highcharts;
  19. return factory;
  20. });
  21. } else {
  22. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  23. }
  24. }(function (Highcharts) {
  25. var _modules = Highcharts ? Highcharts._modules : {};
  26. function _registerModule(obj, path, args, fn) {
  27. if (!obj.hasOwnProperty(path)) {
  28. obj[path] = fn.apply(null, args);
  29. }
  30. }
  31. _registerModule(_modules, 'Extensions/Drilldown.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Color/Color.js'], _modules['Series/Column/ColumnSeries.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Point.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js']], function (A, Axis, Chart, Color, ColumnSeries, F, H, D, palette, Point, Series, SeriesRegistry, SVGRenderer, Tick, U) {
  32. /* *
  33. *
  34. * Highcharts Drilldown module
  35. *
  36. * Author: Torstein Honsi
  37. *
  38. * License: www.highcharts.com/license
  39. *
  40. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41. *
  42. * */
  43. var animObject = A.animObject;
  44. var format = F.format;
  45. var noop = H.noop;
  46. var defaultOptions = D.defaultOptions;
  47. var seriesTypes = SeriesRegistry.seriesTypes;
  48. var addEvent = U.addEvent,
  49. removeEvent = U.removeEvent,
  50. extend = U.extend,
  51. fireEvent = U.fireEvent,
  52. merge = U.merge,
  53. objectEach = U.objectEach,
  54. pick = U.pick,
  55. syncTimeout = U.syncTimeout;
  56. /**
  57. * Gets fired when a drilldown point is clicked, before the new series is added.
  58. * Note that when clicking a category label to trigger multiple series
  59. * drilldown, one `drilldown` event is triggered per point in the category.
  60. *
  61. * @callback Highcharts.DrilldownCallbackFunction
  62. *
  63. * @param {Highcharts.Chart} this
  64. * The chart where the event occurs.
  65. *
  66. * @param {Highcharts.DrilldownEventObject} e
  67. * The drilldown event.
  68. */
  69. /**
  70. * The event arguments when a drilldown point is clicked.
  71. *
  72. * @interface Highcharts.DrilldownEventObject
  73. */ /**
  74. * If a category label was clicked, which index.
  75. * @name Highcharts.DrilldownEventObject#category
  76. * @type {number|undefined}
  77. */ /**
  78. * The original browser event (usually click) that triggered the drilldown.
  79. * @name Highcharts.DrilldownEventObject#originalEvent
  80. * @type {global.Event|undefined}
  81. */ /**
  82. * Prevents the default behaviour of the event.
  83. * @name Highcharts.DrilldownEventObject#preventDefault
  84. * @type {Function}
  85. */ /**
  86. * The originating point.
  87. * @name Highcharts.DrilldownEventObject#point
  88. * @type {Highcharts.Point}
  89. */ /**
  90. * If a category label was clicked, this array holds all points corresponding to
  91. * the category. Otherwise it is set to false.
  92. * @name Highcharts.DrilldownEventObject#points
  93. * @type {boolean|Array<Highcharts.Point>|undefined}
  94. */ /**
  95. * Options for the new series. If the event is utilized for async drilldown, the
  96. * seriesOptions are not added, but rather loaded async.
  97. * @name Highcharts.DrilldownEventObject#seriesOptions
  98. * @type {Highcharts.SeriesOptionsType|undefined}
  99. */ /**
  100. * The event target.
  101. * @name Highcharts.DrilldownEventObject#target
  102. * @type {Highcharts.Chart}
  103. */ /**
  104. * The event type.
  105. * @name Highcharts.DrilldownEventObject#type
  106. * @type {"drilldown"}
  107. */
  108. /**
  109. * This gets fired after all the series have been drilled up. This is especially
  110. * usefull in a chart with multiple drilldown series.
  111. *
  112. * @callback Highcharts.DrillupAllCallbackFunction
  113. *
  114. * @param {Highcharts.Chart} this
  115. * The chart where the event occurs.
  116. *
  117. * @param {Highcharts.DrillupAllEventObject} e
  118. * The final drillup event.
  119. */
  120. /**
  121. * The event arguments when all the series have been drilled up.
  122. *
  123. * @interface Highcharts.DrillupAllEventObject
  124. */ /**
  125. * Prevents the default behaviour of the event.
  126. * @name Highcharts.DrillupAllEventObject#preventDefault
  127. * @type {Function}
  128. */ /**
  129. * The event target.
  130. * @name Highcharts.DrillupAllEventObject#target
  131. * @type {Highcharts.Chart}
  132. */ /**
  133. * The event type.
  134. * @name Highcharts.DrillupAllEventObject#type
  135. * @type {"drillupall"}
  136. */
  137. /**
  138. * Gets fired when drilling up from a drilldown series.
  139. *
  140. * @callback Highcharts.DrillupCallbackFunction
  141. *
  142. * @param {Highcharts.Chart} this
  143. * The chart where the event occurs.
  144. *
  145. * @param {Highcharts.DrillupEventObject} e
  146. * The drillup event.
  147. */
  148. /**
  149. * The event arguments when drilling up from a drilldown series.
  150. *
  151. * @interface Highcharts.DrillupEventObject
  152. */ /**
  153. * Prevents the default behaviour of the event.
  154. * @name Highcharts.DrillupEventObject#preventDefault
  155. * @type {Function}
  156. */ /**
  157. * Options for the new series.
  158. * @name Highcharts.DrillupEventObject#seriesOptions
  159. * @type {Highcharts.SeriesOptionsType|undefined}
  160. */ /**
  161. * The event target.
  162. * @name Highcharts.DrillupEventObject#target
  163. * @type {Highcharts.Chart}
  164. */ /**
  165. * The event type.
  166. * @name Highcharts.DrillupEventObject#type
  167. * @type {"drillup"}
  168. */
  169. var PieSeries = seriesTypes.pie,
  170. ddSeriesId = 1;
  171. // Add language
  172. extend(defaultOptions.lang,
  173. /**
  174. * @optionparent lang
  175. */
  176. {
  177. /**
  178. * The text for the button that appears when drilling down, linking back
  179. * to the parent series. The parent series' name is inserted for
  180. * `{series.name}`.
  181. *
  182. * @since 3.0.8
  183. * @product highcharts highmaps
  184. * @requires modules/drilldown
  185. *
  186. * @private
  187. */
  188. drillUpText: '◁ Back to {series.name}'
  189. });
  190. /**
  191. * Options for drill down, the concept of inspecting increasingly high
  192. * resolution data through clicking on chart items like columns or pie slices.
  193. *
  194. * The drilldown feature requires the drilldown.js file to be loaded,
  195. * found in the modules directory of the download package, or online at
  196. * [code.highcharts.com/modules/drilldown.js
  197. * ](https://code.highcharts.com/modules/drilldown.js).
  198. *
  199. * @product highcharts highmaps
  200. * @requires modules/drilldown
  201. * @optionparent drilldown
  202. * @sample {highcharts} highcharts/series-organization/drilldown
  203. * Organization chart drilldown
  204. */
  205. defaultOptions.drilldown = {
  206. /**
  207. * When this option is false, clicking a single point will drill down
  208. * all points in the same category, equivalent to clicking the X axis
  209. * label.
  210. *
  211. * @sample {highcharts} highcharts/drilldown/allowpointdrilldown-false/
  212. * Don't allow point drilldown
  213. *
  214. * @type {boolean}
  215. * @default true
  216. * @since 4.1.7
  217. * @product highcharts
  218. * @apioption drilldown.allowPointDrilldown
  219. */
  220. /**
  221. * An array of series configurations for the drill down. Each series
  222. * configuration uses the same syntax as the [series](#series) option set.
  223. * These drilldown series are hidden by default. The drilldown series is
  224. * linked to the parent series' point by its `id`.
  225. *
  226. * @type {Array<Highcharts.SeriesOptionsType>}
  227. * @since 3.0.8
  228. * @product highcharts highmaps
  229. * @apioption drilldown.series
  230. */
  231. /**
  232. * Additional styles to apply to the X axis label for a point that
  233. * has drilldown data. By default it is underlined and blue to invite
  234. * to interaction.
  235. *
  236. * In styled mode, active label styles can be set with the
  237. * `.highcharts-drilldown-axis-label` class.
  238. *
  239. * @sample {highcharts} highcharts/drilldown/labels/
  240. * Label styles
  241. *
  242. * @type {Highcharts.CSSObject}
  243. * @default { "cursor": "pointer", "color": "#003399", "fontWeight": "bold", "textDecoration": "underline" }
  244. * @since 3.0.8
  245. * @product highcharts highmaps
  246. */
  247. activeAxisLabelStyle: {
  248. /** @ignore-option */
  249. cursor: 'pointer',
  250. /** @ignore-option */
  251. color: palette.highlightColor100,
  252. /** @ignore-option */
  253. fontWeight: 'bold',
  254. /** @ignore-option */
  255. textDecoration: 'underline'
  256. },
  257. /**
  258. * Additional styles to apply to the data label of a point that has
  259. * drilldown data. By default it is underlined and blue to invite to
  260. * interaction.
  261. *
  262. * In styled mode, active data label styles can be applied with the
  263. * `.highcharts-drilldown-data-label` class.
  264. *
  265. * @sample {highcharts} highcharts/drilldown/labels/
  266. * Label styles
  267. *
  268. * @type {Highcharts.CSSObject}
  269. * @default { "cursor": "pointer", "color": "#003399", "fontWeight": "bold", "textDecoration": "underline" }
  270. * @since 3.0.8
  271. * @product highcharts highmaps
  272. */
  273. activeDataLabelStyle: {
  274. cursor: 'pointer',
  275. color: palette.highlightColor100,
  276. fontWeight: 'bold',
  277. textDecoration: 'underline'
  278. },
  279. /**
  280. * Set the animation for all drilldown animations. Animation of a drilldown
  281. * occurs when drilling between a column point and a column series,
  282. * or a pie slice and a full pie series. Drilldown can still be used
  283. * between series and points of different types, but animation will
  284. * not occur.
  285. *
  286. * The animation can either be set as a boolean or a configuration
  287. * object. If `true`, it will use the 'swing' jQuery easing and a duration
  288. * of 500 ms. If used as a configuration object, the following properties
  289. * are supported:
  290. *
  291. * - `duration`: The duration of the animation in milliseconds.
  292. *
  293. * - `easing`: A string reference to an easing function set on the `Math`
  294. * object. See
  295. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  296. *
  297. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  298. * @since 3.0.8
  299. * @product highcharts highmaps
  300. */
  301. animation: {
  302. /** @internal */
  303. duration: 500
  304. },
  305. /**
  306. * Options for the drill up button that appears when drilling down on a
  307. * series. The text for the button is defined in
  308. * [lang.drillUpText](#lang.drillUpText).
  309. *
  310. * @sample {highcharts} highcharts/drilldown/drillupbutton/
  311. * Drill up button
  312. * @sample {highmaps} highcharts/drilldown/drillupbutton/
  313. * Drill up button
  314. *
  315. * @since 3.0.8
  316. * @product highcharts highmaps
  317. */
  318. drillUpButton: {
  319. /**
  320. * What box to align the button to. Can be either `plotBox` or
  321. * `spacingBox`.
  322. *
  323. * @type {Highcharts.ButtonRelativeToValue}
  324. * @default plotBox
  325. * @since 3.0.8
  326. * @product highcharts highmaps
  327. * @apioption drilldown.drillUpButton.relativeTo
  328. */
  329. /**
  330. * A collection of attributes for the button. The object takes SVG
  331. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the border
  332. * radius. The theme also supports `style`, a collection of CSS
  333. * properties for the text. Equivalent attributes for the hover state
  334. * are given in `theme.states.hover`.
  335. *
  336. * In styled mode, drill-up button styles can be applied with the
  337. * `.highcharts-drillup-button` class.
  338. *
  339. * @sample {highcharts} highcharts/drilldown/drillupbutton/
  340. * Button theming
  341. * @sample {highmaps} highcharts/drilldown/drillupbutton/
  342. * Button theming
  343. *
  344. * @type {object}
  345. * @since 3.0.8
  346. * @product highcharts highmaps
  347. * @apioption drilldown.drillUpButton.theme
  348. */
  349. /**
  350. * Positioning options for the button within the `relativeTo` box.
  351. * Available properties are `x`, `y`, `align` and `verticalAlign`.
  352. *
  353. * @type {Highcharts.AlignObject}
  354. * @since 3.0.8
  355. * @product highcharts highmaps
  356. */
  357. position: {
  358. /**
  359. * Vertical alignment of the button.
  360. *
  361. * @type {Highcharts.VerticalAlignValue}
  362. * @default top
  363. * @product highcharts highmaps
  364. * @apioption drilldown.drillUpButton.position.verticalAlign
  365. */
  366. /**
  367. * Horizontal alignment.
  368. *
  369. * @type {Highcharts.AlignValue}
  370. */
  371. align: 'right',
  372. /**
  373. * The X offset of the button.
  374. */
  375. x: -10,
  376. /**
  377. * The Y offset of the button.
  378. */
  379. y: 10
  380. }
  381. }
  382. };
  383. /**
  384. * Fires when a drilldown point is clicked, before the new series is added. This
  385. * event is also utilized for async drilldown, where the seriesOptions are not
  386. * added by option, but rather loaded async. Note that when clicking a category
  387. * label to trigger multiple series drilldown, one `drilldown` event is
  388. * triggered per point in the category.
  389. *
  390. * Event arguments:
  391. *
  392. * - `category`: If a category label was clicked, which index.
  393. *
  394. * - `originalEvent`: The original browser event (usually click) that triggered
  395. * the drilldown.
  396. *
  397. * - `point`: The originating point.
  398. *
  399. * - `points`: If a category label was clicked, this array holds all points
  400. * corresponding to the category.
  401. *
  402. * - `seriesOptions`: Options for the new series.
  403. *
  404. * @sample {highcharts} highcharts/drilldown/async/
  405. * Async drilldown
  406. *
  407. * @type {Highcharts.DrilldownCallbackFunction}
  408. * @since 3.0.8
  409. * @product highcharts highmaps
  410. * @context Highcharts.Chart
  411. * @requires modules/drilldown
  412. * @apioption chart.events.drilldown
  413. */
  414. /**
  415. * Fires when drilling up from a drilldown series.
  416. *
  417. * @type {Highcharts.DrillupCallbackFunction}
  418. * @since 3.0.8
  419. * @product highcharts highmaps
  420. * @context Highcharts.Chart
  421. * @requires modules/drilldown
  422. * @apioption chart.events.drillup
  423. */
  424. /**
  425. * In a chart with multiple drilldown series, this event fires after all the
  426. * series have been drilled up.
  427. *
  428. * @type {Highcharts.DrillupAllCallbackFunction}
  429. * @since 4.2.4
  430. * @product highcharts highmaps
  431. * @context Highcharts.Chart
  432. * @requires modules/drilldown
  433. * @apioption chart.events.drillupall
  434. */
  435. /**
  436. * The `id` of a series in the [drilldown.series](#drilldown.series) array to
  437. * use for a drilldown for this point.
  438. *
  439. * @sample {highcharts} highcharts/drilldown/basic/
  440. * Basic drilldown
  441. *
  442. * @type {string}
  443. * @since 3.0.8
  444. * @product highcharts
  445. * @requires modules/drilldown
  446. * @apioption series.line.data.drilldown
  447. */
  448. /**
  449. * A general fadeIn method.
  450. *
  451. * @requires module:modules/drilldown
  452. *
  453. * @function Highcharts.SVGElement#fadeIn
  454. *
  455. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  456. * The animation options for the element fade.
  457. */
  458. SVGRenderer.prototype.Element.prototype.fadeIn = function (animation) {
  459. this
  460. .attr({
  461. opacity: 0.1,
  462. visibility: 'inherit'
  463. })
  464. .animate({
  465. opacity: pick(this.newOpacity, 1) // newOpacity used in maps
  466. }, animation || {
  467. duration: 250
  468. });
  469. };
  470. /**
  471. * Add a series to the chart as drilldown from a specific point in the parent
  472. * series. This method is used for async drilldown, when clicking a point in a
  473. * series should result in loading and displaying a more high-resolution series.
  474. * When not async, the setup is simpler using the
  475. * [drilldown.series](https://api.highcharts.com/highcharts/drilldown.series)
  476. * options structure.
  477. *
  478. * @sample highcharts/drilldown/async/
  479. * Async drilldown
  480. *
  481. * @function Highcharts.Chart#addSeriesAsDrilldown
  482. *
  483. * @param {Highcharts.Point} point
  484. * The point from which the drilldown will start.
  485. *
  486. * @param {Highcharts.SeriesOptionsType} options
  487. * The series options for the new, detailed series.
  488. */
  489. Chart.prototype.addSeriesAsDrilldown = function (point, options) {
  490. this.addSingleSeriesAsDrilldown(point, options);
  491. this.applyDrilldown();
  492. };
  493. Chart.prototype.addSingleSeriesAsDrilldown = function (point, ddOptions) {
  494. var oldSeries = point.series,
  495. xAxis = oldSeries.xAxis,
  496. yAxis = oldSeries.yAxis,
  497. newSeries,
  498. pointIndex,
  499. levelSeries = [],
  500. levelSeriesOptions = [],
  501. level,
  502. levelNumber,
  503. last,
  504. colorProp;
  505. colorProp = this.styledMode ?
  506. { colorIndex: pick(point.colorIndex, oldSeries.colorIndex) } :
  507. { color: point.color || oldSeries.color };
  508. if (!this.drilldownLevels) {
  509. this.drilldownLevels = [];
  510. }
  511. levelNumber = oldSeries.options._levelNumber || 0;
  512. // See if we can reuse the registered series from last run
  513. last = this.drilldownLevels[this.drilldownLevels.length - 1];
  514. if (last && last.levelNumber !== levelNumber) {
  515. last = void 0;
  516. }
  517. ddOptions = extend(extend({
  518. _ddSeriesId: ddSeriesId++
  519. }, colorProp), ddOptions);
  520. pointIndex = oldSeries.points.indexOf(point);
  521. // Record options for all current series
  522. oldSeries.chart.series.forEach(function (series) {
  523. if (series.xAxis === xAxis && !series.isDrilling) {
  524. series.options._ddSeriesId =
  525. series.options._ddSeriesId || ddSeriesId++;
  526. series.options._colorIndex = series.userOptions._colorIndex;
  527. series.options._levelNumber =
  528. series.options._levelNumber || levelNumber; // #3182
  529. if (last) {
  530. levelSeries = last.levelSeries;
  531. levelSeriesOptions = last.levelSeriesOptions;
  532. }
  533. else {
  534. levelSeries.push(series);
  535. // (#10597)
  536. series.purgedOptions = merge({
  537. _ddSeriesId: series.options._ddSeriesId,
  538. _levelNumber: series.options._levelNumber,
  539. selected: series.options.selected
  540. }, series.userOptions);
  541. levelSeriesOptions.push(series.purgedOptions);
  542. }
  543. }
  544. });
  545. // Add a record of properties for each drilldown level
  546. level = extend({
  547. levelNumber: levelNumber,
  548. seriesOptions: oldSeries.options,
  549. seriesPurgedOptions: oldSeries.purgedOptions,
  550. levelSeriesOptions: levelSeriesOptions,
  551. levelSeries: levelSeries,
  552. shapeArgs: point.shapeArgs,
  553. // no graphic in line series with markers disabled
  554. bBox: point.graphic ? point.graphic.getBBox() : {},
  555. color: point.isNull ?
  556. new Color(colorProp.color).setOpacity(0).get() :
  557. colorProp.color,
  558. lowerSeriesOptions: ddOptions,
  559. pointOptions: oldSeries.options.data[pointIndex],
  560. pointIndex: pointIndex,
  561. oldExtremes: {
  562. xMin: xAxis && xAxis.userMin,
  563. xMax: xAxis && xAxis.userMax,
  564. yMin: yAxis && yAxis.userMin,
  565. yMax: yAxis && yAxis.userMax
  566. },
  567. resetZoomButton: this.resetZoomButton
  568. }, colorProp);
  569. // Push it to the lookup array
  570. this.drilldownLevels.push(level);
  571. // Reset names to prevent extending (#6704)
  572. if (xAxis && xAxis.names) {
  573. xAxis.names.length = 0;
  574. }
  575. newSeries = level.lowerSeries = this.addSeries(ddOptions, false);
  576. newSeries.options._levelNumber = levelNumber + 1;
  577. if (xAxis) {
  578. xAxis.oldPos = xAxis.pos;
  579. xAxis.userMin = xAxis.userMax = null;
  580. yAxis.userMin = yAxis.userMax = null;
  581. }
  582. // Run fancy cross-animation on supported and equal types
  583. if (oldSeries.type === newSeries.type) {
  584. newSeries.animate = (newSeries.animateDrilldown || noop);
  585. newSeries.options.animation = true;
  586. }
  587. };
  588. Chart.prototype.applyDrilldown = function () {
  589. var drilldownLevels = this.drilldownLevels,
  590. levelToRemove;
  591. if (drilldownLevels && drilldownLevels.length > 0) { // #3352, async loading
  592. levelToRemove = drilldownLevels[drilldownLevels.length - 1].levelNumber;
  593. this.drilldownLevels.forEach(function (level) {
  594. if (level.levelNumber === levelToRemove) {
  595. level.levelSeries.forEach(function (series) {
  596. // Not removed, not added as part of a multi-series
  597. // drilldown
  598. if (series.options &&
  599. series.options._levelNumber === levelToRemove) {
  600. series.remove(false);
  601. }
  602. });
  603. }
  604. });
  605. }
  606. // We have a reset zoom button. Hide it and detatch it from the chart. It
  607. // is preserved to the layer config above.
  608. if (this.resetZoomButton) {
  609. this.resetZoomButton.hide();
  610. delete this.resetZoomButton;
  611. }
  612. this.pointer.reset();
  613. this.redraw();
  614. this.showDrillUpButton();
  615. fireEvent(this, 'afterDrilldown');
  616. };
  617. Chart.prototype.getDrilldownBackText = function () {
  618. var drilldownLevels = this.drilldownLevels,
  619. lastLevel;
  620. if (drilldownLevels && drilldownLevels.length > 0) { // #3352, async loading
  621. lastLevel = drilldownLevels[drilldownLevels.length - 1];
  622. lastLevel.series = lastLevel.seriesOptions;
  623. return format(this.options.lang.drillUpText, lastLevel);
  624. }
  625. };
  626. Chart.prototype.showDrillUpButton = function () {
  627. var chart = this,
  628. backText = this.getDrilldownBackText(),
  629. buttonOptions = chart.options.drilldown.drillUpButton,
  630. attr,
  631. states,
  632. alignTo = (buttonOptions.relativeTo === 'chart' ||
  633. buttonOptions.relativeTo === 'spacingBox' ?
  634. null :
  635. 'scrollablePlotBox');
  636. if (!this.drillUpButton) {
  637. attr = buttonOptions.theme;
  638. states = attr && attr.states;
  639. this.drillUpButton = this.renderer
  640. .button(backText, null, null, function () {
  641. chart.drillUp();
  642. }, attr, states && states.hover, states && states.select)
  643. .addClass('highcharts-drillup-button')
  644. .attr({
  645. align: buttonOptions.position.align,
  646. zIndex: 7
  647. })
  648. .add()
  649. .align(buttonOptions.position, false, alignTo);
  650. }
  651. else {
  652. this.drillUpButton.attr({
  653. text: backText
  654. })
  655. .align();
  656. }
  657. };
  658. /**
  659. * When the chart is drilled down to a child series, calling `chart.drillUp()`
  660. * will drill up to the parent series.
  661. *
  662. * @requires modules/drilldown
  663. *
  664. * @function Highcharts.Chart#drillUp
  665. */
  666. Chart.prototype.drillUp = function () {
  667. if (!this.drilldownLevels || this.drilldownLevels.length === 0) {
  668. return;
  669. }
  670. var chart = this,
  671. drilldownLevels = chart.drilldownLevels,
  672. levelNumber = drilldownLevels[drilldownLevels.length - 1].levelNumber,
  673. i = drilldownLevels.length,
  674. chartSeries = chart.series,
  675. seriesI,
  676. level,
  677. oldSeries,
  678. newSeries,
  679. oldExtremes,
  680. addSeries = function (seriesOptions) {
  681. var addedSeries;
  682. chartSeries.forEach(function (series) {
  683. if (series.options._ddSeriesId === seriesOptions._ddSeriesId) {
  684. addedSeries = series;
  685. }
  686. });
  687. addedSeries = addedSeries || chart.addSeries(seriesOptions, false);
  688. if (addedSeries.type === oldSeries.type &&
  689. addedSeries.animateDrillupTo) {
  690. addedSeries.animate = addedSeries.animateDrillupTo;
  691. }
  692. if (seriesOptions === level.seriesPurgedOptions) {
  693. newSeries = addedSeries;
  694. }
  695. };
  696. while (i--) {
  697. level = drilldownLevels[i];
  698. if (level.levelNumber === levelNumber) {
  699. drilldownLevels.pop();
  700. // Get the lower series by reference or id
  701. oldSeries = level.lowerSeries;
  702. if (!oldSeries.chart) { // #2786
  703. seriesI = chartSeries.length; // #2919
  704. while (seriesI--) {
  705. if (chartSeries[seriesI].options.id ===
  706. level.lowerSeriesOptions.id &&
  707. chartSeries[seriesI].options._levelNumber ===
  708. levelNumber + 1) { // #3867
  709. oldSeries = chartSeries[seriesI];
  710. break;
  711. }
  712. }
  713. }
  714. oldSeries.xData = []; // Overcome problems with minRange (#2898)
  715. level.levelSeriesOptions.forEach(addSeries);
  716. fireEvent(chart, 'drillup', {
  717. seriesOptions: level.seriesPurgedOptions ||
  718. level.seriesOptions
  719. });
  720. this.resetZoomButton && this.resetZoomButton.destroy(); // #8095
  721. if (newSeries.type === oldSeries.type) {
  722. newSeries.drilldownLevel = level;
  723. newSeries.options.animation =
  724. chart.options.drilldown.animation;
  725. if (oldSeries.animateDrillupFrom && oldSeries.chart) { // #2919
  726. oldSeries.animateDrillupFrom(level);
  727. }
  728. }
  729. newSeries.options._levelNumber = levelNumber;
  730. oldSeries.remove(false);
  731. // Reset the zoom level of the upper series
  732. if (newSeries.xAxis) {
  733. oldExtremes = level.oldExtremes;
  734. newSeries.xAxis.setExtremes(oldExtremes.xMin, oldExtremes.xMax, false);
  735. newSeries.yAxis.setExtremes(oldExtremes.yMin, oldExtremes.yMax, false);
  736. }
  737. // We have a resetZoomButton tucked away for this level. Attatch
  738. // it to the chart and show it.
  739. if (level.resetZoomButton) {
  740. chart.resetZoomButton = level.resetZoomButton;
  741. chart.resetZoomButton.show();
  742. }
  743. }
  744. }
  745. this.redraw();
  746. if (this.drilldownLevels.length === 0) {
  747. this.drillUpButton = this.drillUpButton.destroy();
  748. }
  749. else {
  750. this.drillUpButton.attr({
  751. text: this.getDrilldownBackText()
  752. })
  753. .align();
  754. }
  755. this.ddDupes.length = []; // #3315
  756. // Fire a once-off event after all series have been drilled up (#5158)
  757. fireEvent(chart, 'drillupall');
  758. };
  759. /* eslint-disable no-invalid-this */
  760. // Add update function to be called internally from Chart.update
  761. // (#7600, #12855)
  762. addEvent(Chart, 'afterInit', function () {
  763. var chart = this;
  764. chart.drilldown = {
  765. update: function (options, redraw) {
  766. merge(true, chart.options.drilldown, options);
  767. if (pick(redraw, true)) {
  768. chart.redraw();
  769. }
  770. }
  771. };
  772. });
  773. // Shift the drillUpButton to make the space for resetZoomButton, #8095.
  774. addEvent(Chart, 'afterShowResetZoom', function () {
  775. var chart = this,
  776. bbox = chart.resetZoomButton && chart.resetZoomButton.getBBox(),
  777. buttonOptions = chart.options.drilldown && chart.options.drilldown.drillUpButton;
  778. if (this.drillUpButton && bbox && buttonOptions && buttonOptions.position && buttonOptions.position.x) {
  779. this.drillUpButton.align({
  780. x: buttonOptions.position.x - bbox.width - 10,
  781. y: buttonOptions.position.y,
  782. align: buttonOptions.position.align
  783. }, false, buttonOptions.relativeTo || 'plotBox');
  784. }
  785. });
  786. addEvent(Chart, 'render', function () {
  787. (this.xAxis || []).forEach(function (axis) {
  788. axis.ddPoints = {};
  789. axis.series.forEach(function (series) {
  790. var i,
  791. xData = series.xData || [],
  792. points = series.points,
  793. p;
  794. for (i = 0; i < xData.length; i++) {
  795. p = series.options.data[i];
  796. // The `drilldown` property can only be set on an array or an
  797. // object
  798. if (typeof p !== 'number') {
  799. // Convert array to object (#8008)
  800. p = series.pointClass.prototype.optionsToObject
  801. .call({ series: series }, p);
  802. if (p.drilldown) {
  803. if (!axis.ddPoints[xData[i]]) {
  804. axis.ddPoints[xData[i]] = [];
  805. }
  806. var index = i - (series.cropStart || 0);
  807. axis.ddPoints[xData[i]].push((points && index >= 0 && index < points.length) ?
  808. points[index] :
  809. true);
  810. }
  811. }
  812. }
  813. });
  814. // Add drillability to ticks, and always keep it drillability updated
  815. // (#3951)
  816. objectEach(axis.ticks, Tick.prototype.drillable);
  817. });
  818. });
  819. /**
  820. * When drilling up, keep the upper series invisible until the lower series has
  821. * moved into place.
  822. *
  823. * @private
  824. * @function Highcharts.ColumnSeries#animateDrillupTo
  825. * @param {boolean} [init=false]
  826. * Whether to initialize animation
  827. */
  828. ColumnSeries.prototype.animateDrillupTo = function (init) {
  829. if (!init) {
  830. var newSeries_1 = this,
  831. level_1 = newSeries_1.drilldownLevel;
  832. // First hide all items before animating in again
  833. this.points.forEach(function (point) {
  834. var dataLabel = point.dataLabel;
  835. if (point.graphic) { // #3407
  836. point.graphic.hide();
  837. }
  838. if (dataLabel) {
  839. // The data label is initially hidden, make sure it is not faded
  840. // in (#6127)
  841. dataLabel.hidden = dataLabel.attr('visibility') === 'hidden';
  842. if (!dataLabel.hidden) {
  843. dataLabel.hide();
  844. if (point.connector) {
  845. point.connector.hide();
  846. }
  847. }
  848. }
  849. });
  850. // Do dummy animation on first point to get to complete
  851. syncTimeout(function () {
  852. if (newSeries_1.points) { // May be destroyed in the meantime, #3389
  853. // Unable to drillup with nodes, #13711
  854. var pointsWithNodes_1 = [];
  855. newSeries_1.data.forEach(function (el) {
  856. pointsWithNodes_1.push(el);
  857. });
  858. if (newSeries_1.nodes) {
  859. pointsWithNodes_1 = pointsWithNodes_1.concat(newSeries_1.nodes);
  860. }
  861. pointsWithNodes_1.forEach(function (point, i) {
  862. // Fade in other points
  863. var verb = i === (level_1 && level_1.pointIndex) ? 'show' : 'fadeIn', inherit = verb === 'show' ? true : void 0, dataLabel = point.dataLabel;
  864. if (point.graphic) { // #3407
  865. point.graphic[verb](inherit);
  866. }
  867. if (dataLabel && !dataLabel.hidden) { // #6127
  868. dataLabel.fadeIn(); // #7384
  869. if (point.connector) {
  870. point.connector.fadeIn();
  871. }
  872. }
  873. });
  874. }
  875. }, Math.max(this.chart.options.drilldown.animation.duration - 50, 0));
  876. // Reset to prototype
  877. delete this.animate;
  878. }
  879. };
  880. ColumnSeries.prototype.animateDrilldown = function (init) {
  881. var series = this,
  882. chart = this.chart,
  883. drilldownLevels = chart.drilldownLevels,
  884. animateFrom,
  885. animationOptions = animObject(chart.options.drilldown.animation),
  886. xAxis = this.xAxis,
  887. styledMode = chart.styledMode;
  888. if (!init) {
  889. drilldownLevels.forEach(function (level) {
  890. if (series.options._ddSeriesId ===
  891. level.lowerSeriesOptions._ddSeriesId) {
  892. animateFrom = level.shapeArgs;
  893. if (!styledMode) {
  894. // Add the point colors to animate from
  895. animateFrom.fill = level.color;
  896. }
  897. }
  898. });
  899. animateFrom.x += pick(xAxis.oldPos, xAxis.pos) - xAxis.pos;
  900. this.points.forEach(function (point) {
  901. var animateTo = point.shapeArgs;
  902. if (!styledMode) {
  903. // Add the point colors to animate to
  904. animateTo.fill = point.color;
  905. }
  906. if (point.graphic) {
  907. point.graphic
  908. .attr(animateFrom)
  909. .animate(extend(point.shapeArgs, { fill: point.color || series.color }), animationOptions);
  910. }
  911. if (point.dataLabel) {
  912. point.dataLabel.fadeIn(animationOptions);
  913. }
  914. });
  915. // Reset to prototype
  916. delete this.animate;
  917. }
  918. };
  919. /**
  920. * When drilling up, pull out the individual point graphics from the lower
  921. * series and animate them into the origin point in the upper series.
  922. *
  923. * @private
  924. * @function Highcharts.ColumnSeries#animateDrillupFrom
  925. * @param {Highcharts.DrilldownLevelObject} level
  926. * Level container
  927. * @return {void}
  928. */
  929. ColumnSeries.prototype.animateDrillupFrom = function (level) {
  930. var animationOptions = animObject(this.chart.options.drilldown.animation),
  931. group = this.group,
  932. // For 3d column series all columns are added to one group
  933. // so we should not delete the whole group. #5297
  934. removeGroup = group !== this.chart.columnGroup,
  935. series = this;
  936. // Cancel mouse events on the series group (#2787)
  937. series.trackerGroups.forEach(function (key) {
  938. if (series[key]) { // we don't always have dataLabelsGroup
  939. series[key].on('mouseover');
  940. }
  941. });
  942. if (removeGroup) {
  943. delete this.group;
  944. }
  945. this.points.forEach(function (point) {
  946. var graphic = point.graphic,
  947. animateTo = level.shapeArgs,
  948. complete = function () {
  949. graphic.destroy();
  950. if (group && removeGroup) {
  951. group = group.destroy();
  952. }
  953. };
  954. if (graphic && animateTo) {
  955. delete point.graphic;
  956. if (!series.chart.styledMode) {
  957. animateTo.fill = level.color;
  958. }
  959. if (animationOptions.duration) {
  960. graphic.animate(animateTo, merge(animationOptions, { complete: complete }));
  961. }
  962. else {
  963. graphic.attr(animateTo);
  964. complete();
  965. }
  966. }
  967. });
  968. };
  969. if (PieSeries) {
  970. extend(PieSeries.prototype, {
  971. animateDrillupTo: ColumnSeries.prototype.animateDrillupTo,
  972. animateDrillupFrom: ColumnSeries.prototype.animateDrillupFrom,
  973. animateDrilldown: function (init) {
  974. var level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1],
  975. animationOptions = this.chart.options.drilldown.animation;
  976. if (this.is('item')) {
  977. animationOptions.duration = 0;
  978. }
  979. // Unable to drill down in the horizontal item series #13372
  980. if (this.center) {
  981. var animateFrom_1 = level.shapeArgs,
  982. start_1 = animateFrom_1.start,
  983. angle = animateFrom_1.end - start_1,
  984. startAngle_1 = angle / this.points.length,
  985. styledMode_1 = this.chart.styledMode;
  986. if (!init) {
  987. this.points.forEach(function (point, i) {
  988. var animateTo = point.shapeArgs;
  989. if (!styledMode_1) {
  990. animateFrom_1.fill = level.color;
  991. animateTo.fill = point.color;
  992. }
  993. if (point.graphic) {
  994. point.graphic
  995. .attr(merge(animateFrom_1, {
  996. start: start_1 + i * startAngle_1,
  997. end: start_1 + (i + 1) * startAngle_1
  998. }))[animationOptions ? 'animate' : 'attr'](animateTo, animationOptions);
  999. }
  1000. });
  1001. // Reset to prototype
  1002. delete this.animate;
  1003. }
  1004. }
  1005. }
  1006. });
  1007. }
  1008. Point.prototype.doDrilldown = function (_holdRedraw, category, originalEvent) {
  1009. var series = this.series,
  1010. chart = series.chart,
  1011. drilldown = chart.options.drilldown,
  1012. i = (drilldown.series || []).length,
  1013. seriesOptions;
  1014. if (!chart.ddDupes) {
  1015. chart.ddDupes = [];
  1016. }
  1017. while (i-- && !seriesOptions) {
  1018. if (drilldown.series[i].id === this.drilldown &&
  1019. chart.ddDupes.indexOf(this.drilldown) === -1) {
  1020. seriesOptions = drilldown.series[i];
  1021. chart.ddDupes.push(this.drilldown);
  1022. }
  1023. }
  1024. // Fire the event. If seriesOptions is undefined, the implementer can check
  1025. // for seriesOptions, and call addSeriesAsDrilldown async if necessary.
  1026. fireEvent(chart, 'drilldown', {
  1027. point: this,
  1028. seriesOptions: seriesOptions,
  1029. category: category,
  1030. originalEvent: originalEvent,
  1031. points: (typeof category !== 'undefined' &&
  1032. this.series.xAxis.getDDPoints(category).slice(0))
  1033. }, function (e) {
  1034. var chart = e.point.series && e.point.series.chart,
  1035. seriesOptions = e.seriesOptions;
  1036. if (chart && seriesOptions) {
  1037. if (_holdRedraw) {
  1038. chart.addSingleSeriesAsDrilldown(e.point, seriesOptions);
  1039. }
  1040. else {
  1041. chart.addSeriesAsDrilldown(e.point, seriesOptions);
  1042. }
  1043. }
  1044. });
  1045. };
  1046. /**
  1047. * Drill down to a given category. This is the same as clicking on an axis
  1048. * label.
  1049. *
  1050. * @private
  1051. * @function Highcharts.Axis#drilldownCategory
  1052. * @param {number} x
  1053. * Tick position
  1054. * @param {global.MouseEvent} e
  1055. * Click event
  1056. */
  1057. Axis.prototype.drilldownCategory = function (x, e) {
  1058. this.getDDPoints(x).forEach(function (point) {
  1059. if (point &&
  1060. point.series &&
  1061. point.series.visible &&
  1062. point.doDrilldown) { // #3197
  1063. point.doDrilldown(true, x, e);
  1064. }
  1065. });
  1066. this.chart.applyDrilldown();
  1067. };
  1068. /**
  1069. * Return drillable points for this specific X value.
  1070. *
  1071. * @private
  1072. * @function Highcharts.Axis#getDDPoints
  1073. * @param {number} x
  1074. * Tick position
  1075. * @return {Array<(false|Highcharts.Point)>}
  1076. * Drillable points
  1077. */
  1078. Axis.prototype.getDDPoints = function (x) {
  1079. return (this.ddPoints && this.ddPoints[x] || []);
  1080. };
  1081. /**
  1082. * Make a tick label drillable, or remove drilling on update.
  1083. *
  1084. * @private
  1085. * @function Highcharts.Axis#drillable
  1086. */
  1087. Tick.prototype.drillable = function () {
  1088. var pos = this.pos,
  1089. label = this.label,
  1090. axis = this.axis,
  1091. isDrillable = axis.coll === 'xAxis' && axis.getDDPoints,
  1092. ddPointsX = isDrillable && axis.getDDPoints(pos),
  1093. styledMode = axis.chart.styledMode;
  1094. if (isDrillable) {
  1095. if (label && ddPointsX && ddPointsX.length) {
  1096. label.drillable = true;
  1097. if (!label.basicStyles && !styledMode) {
  1098. label.basicStyles = merge(label.styles);
  1099. }
  1100. label.addClass('highcharts-drilldown-axis-label');
  1101. // #12656 - avoid duplicate of attach event
  1102. if (label.removeOnDrillableClick) {
  1103. removeEvent(label.element, 'click');
  1104. }
  1105. label.removeOnDrillableClick = addEvent(label.element, 'click', function (e) {
  1106. e.preventDefault();
  1107. axis.drilldownCategory(pos, e);
  1108. });
  1109. if (!styledMode) {
  1110. label.css(axis.chart.options.drilldown.activeAxisLabelStyle);
  1111. }
  1112. }
  1113. else if (label && label.drillable && label.removeOnDrillableClick) {
  1114. if (!styledMode) {
  1115. label.styles = {}; // reset for full overwrite of styles
  1116. label.css(label.basicStyles);
  1117. }
  1118. label.removeOnDrillableClick(); // #3806
  1119. label.removeClass('highcharts-drilldown-axis-label');
  1120. }
  1121. }
  1122. };
  1123. // On initialization of each point, identify its label and make it clickable.
  1124. // Also, provide a list of points associated to that label.
  1125. addEvent(Point, 'afterInit', function () {
  1126. var point = this;
  1127. if (point.drilldown && !point.unbindDrilldownClick) {
  1128. // Add the click event to the point
  1129. point.unbindDrilldownClick = addEvent(point, 'click', handlePointClick);
  1130. }
  1131. return point;
  1132. });
  1133. addEvent(Point, 'update', function (e) {
  1134. var point = this,
  1135. options = e.options || {};
  1136. if (options.drilldown && !point.unbindDrilldownClick) {
  1137. // Add the click event to the point
  1138. point.unbindDrilldownClick = addEvent(point, 'click', handlePointClick);
  1139. }
  1140. else if (!options.drilldown &&
  1141. options.drilldown !== void 0 &&
  1142. point.unbindDrilldownClick) {
  1143. point.unbindDrilldownClick = point.unbindDrilldownClick();
  1144. }
  1145. });
  1146. var handlePointClick = function (e) {
  1147. var point = this,
  1148. series = point.series;
  1149. if (series.xAxis &&
  1150. series.chart.options.drilldown.allowPointDrilldown ===
  1151. false) {
  1152. // #5822, x changed
  1153. series.xAxis.drilldownCategory(point.x, e);
  1154. }
  1155. else {
  1156. point.doDrilldown(void 0, void 0, e);
  1157. }
  1158. };
  1159. addEvent(Series, 'afterDrawDataLabels', function () {
  1160. var css = this.chart.options.drilldown.activeDataLabelStyle,
  1161. renderer = this.chart.renderer,
  1162. styledMode = this.chart.styledMode;
  1163. this.points.forEach(function (point) {
  1164. var dataLabelsOptions = point.options.dataLabels,
  1165. pointCSS = pick(point.dlOptions,
  1166. dataLabelsOptions && dataLabelsOptions.style, {});
  1167. if (point.drilldown && point.dataLabel) {
  1168. if (css.color === 'contrast' && !styledMode) {
  1169. pointCSS.color = renderer.getContrast(point.color || this.color);
  1170. }
  1171. if (dataLabelsOptions && dataLabelsOptions.color) {
  1172. pointCSS.color = dataLabelsOptions.color;
  1173. }
  1174. point.dataLabel
  1175. .addClass('highcharts-drilldown-data-label');
  1176. if (!styledMode) {
  1177. point.dataLabel
  1178. .css(css)
  1179. .css(pointCSS);
  1180. }
  1181. }
  1182. }, this);
  1183. });
  1184. var applyCursorCSS = function (element,
  1185. cursor,
  1186. addClass,
  1187. styledMode) {
  1188. element[addClass ? 'addClass' : 'removeClass']('highcharts-drilldown-point');
  1189. if (!styledMode) {
  1190. element.css({ cursor: cursor });
  1191. }
  1192. };
  1193. // Mark the trackers with a pointer
  1194. addEvent(Series, 'afterDrawTracker', function () {
  1195. var styledMode = this.chart.styledMode;
  1196. this.points.forEach(function (point) {
  1197. if (point.drilldown && point.graphic) {
  1198. applyCursorCSS(point.graphic, 'pointer', true, styledMode);
  1199. }
  1200. });
  1201. });
  1202. addEvent(Point, 'afterSetState', function () {
  1203. var styledMode = this.series.chart.styledMode;
  1204. if (this.drilldown && this.series.halo && this.state === 'hover') {
  1205. applyCursorCSS(this.series.halo, 'pointer', true, styledMode);
  1206. }
  1207. else if (this.series.halo) {
  1208. applyCursorCSS(this.series.halo, 'auto', false, styledMode);
  1209. }
  1210. });
  1211. // After zooming out, shift the drillUpButton to the previous position, #8095.
  1212. addEvent(Chart, 'selection', function (event) {
  1213. if (event.resetSelection === true && this.drillUpButton) {
  1214. var buttonOptions = this.options.drilldown && this.options.drilldown.drillUpButton;
  1215. if (buttonOptions && buttonOptions.position) {
  1216. this.drillUpButton.align({
  1217. x: buttonOptions.position.x,
  1218. y: buttonOptions.position.y,
  1219. align: buttonOptions.position.align
  1220. }, false, buttonOptions.relativeTo || 'plotBox');
  1221. }
  1222. }
  1223. });
  1224. addEvent(Chart, 'drillup', function () {
  1225. if (this.resetZoomButton) {
  1226. this.resetZoomButton = this.resetZoomButton.destroy();
  1227. }
  1228. });
  1229. });
  1230. _registerModule(_modules, 'masters/modules/drilldown.src.js', [], function () {
  1231. });
  1232. }));