treemap.src.js 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048
  1. /**
  2. * @license Highcharts JS v8.2.0 (2020-08-20)
  3. *
  4. * (c) 2014-2019 Highsoft AS
  5. * Authors: Jon Arild Nygard / Oystein Moseng
  6. *
  7. * License: www.highcharts.com/license
  8. */
  9. 'use strict';
  10. (function (factory) {
  11. if (typeof module === 'object' && module.exports) {
  12. factory['default'] = factory;
  13. module.exports = factory;
  14. } else if (typeof define === 'function' && define.amd) {
  15. define('highcharts/modules/treemap', ['highcharts'], function (Highcharts) {
  16. factory(Highcharts);
  17. factory.Highcharts = Highcharts;
  18. return factory;
  19. });
  20. } else {
  21. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  22. }
  23. }(function (Highcharts) {
  24. var _modules = Highcharts ? Highcharts._modules : {};
  25. function _registerModule(obj, path, args, fn) {
  26. if (!obj.hasOwnProperty(path)) {
  27. obj[path] = fn.apply(null, args);
  28. }
  29. }
  30. _registerModule(_modules, 'Mixins/TreeSeries.js', [_modules['Core/Color.js'], _modules['Core/Utilities.js']], function (Color, U) {
  31. /* *
  32. *
  33. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  34. *
  35. * */
  36. var extend = U.extend,
  37. isArray = U.isArray,
  38. isNumber = U.isNumber,
  39. isObject = U.isObject,
  40. merge = U.merge,
  41. pick = U.pick;
  42. var isBoolean = function (x) {
  43. return typeof x === 'boolean';
  44. }, isFn = function (x) {
  45. return typeof x === 'function';
  46. };
  47. /* eslint-disable valid-jsdoc */
  48. /**
  49. * @todo Combine buildTree and buildNode with setTreeValues
  50. * @todo Remove logic from Treemap and make it utilize this mixin.
  51. * @private
  52. */
  53. var setTreeValues = function setTreeValues(tree,
  54. options) {
  55. var before = options.before,
  56. idRoot = options.idRoot,
  57. mapIdToNode = options.mapIdToNode,
  58. nodeRoot = mapIdToNode[idRoot],
  59. levelIsConstant = (isBoolean(options.levelIsConstant) ?
  60. options.levelIsConstant :
  61. true),
  62. points = options.points,
  63. point = points[tree.i],
  64. optionsPoint = point && point.options || {},
  65. childrenTotal = 0,
  66. children = [],
  67. value;
  68. extend(tree, {
  69. levelDynamic: tree.level - (levelIsConstant ? 0 : nodeRoot.level),
  70. name: pick(point && point.name, ''),
  71. visible: (idRoot === tree.id ||
  72. (isBoolean(options.visible) ? options.visible : false))
  73. });
  74. if (isFn(before)) {
  75. tree = before(tree, options);
  76. }
  77. // First give the children some values
  78. tree.children.forEach(function (child, i) {
  79. var newOptions = extend({},
  80. options);
  81. extend(newOptions, {
  82. index: i,
  83. siblings: tree.children.length,
  84. visible: tree.visible
  85. });
  86. child = setTreeValues(child, newOptions);
  87. children.push(child);
  88. if (child.visible) {
  89. childrenTotal += child.val;
  90. }
  91. });
  92. tree.visible = childrenTotal > 0 || tree.visible;
  93. // Set the values
  94. value = pick(optionsPoint.value, childrenTotal);
  95. extend(tree, {
  96. children: children,
  97. childrenTotal: childrenTotal,
  98. isLeaf: tree.visible && !childrenTotal,
  99. val: value
  100. });
  101. return tree;
  102. };
  103. /**
  104. * @private
  105. */
  106. var getColor = function getColor(node,
  107. options) {
  108. var index = options.index,
  109. mapOptionsToLevel = options.mapOptionsToLevel,
  110. parentColor = options.parentColor,
  111. parentColorIndex = options.parentColorIndex,
  112. series = options.series,
  113. colors = options.colors,
  114. siblings = options.siblings,
  115. points = series.points,
  116. getColorByPoint,
  117. chartOptionsChart = series.chart.options.chart,
  118. point,
  119. level,
  120. colorByPoint,
  121. colorIndexByPoint,
  122. color,
  123. colorIndex;
  124. /**
  125. * @private
  126. */
  127. function variation(color) {
  128. var colorVariation = level && level.colorVariation;
  129. if (colorVariation) {
  130. if (colorVariation.key === 'brightness') {
  131. return Color.parse(color).brighten(colorVariation.to * (index / siblings)).get();
  132. }
  133. }
  134. return color;
  135. }
  136. if (node) {
  137. point = points[node.i];
  138. level = mapOptionsToLevel[node.level] || {};
  139. getColorByPoint = point && level.colorByPoint;
  140. if (getColorByPoint) {
  141. colorIndexByPoint = point.index % (colors ?
  142. colors.length :
  143. chartOptionsChart.colorCount);
  144. colorByPoint = colors && colors[colorIndexByPoint];
  145. }
  146. // Select either point color, level color or inherited color.
  147. if (!series.chart.styledMode) {
  148. color = pick(point && point.options.color, level && level.color, colorByPoint, parentColor && variation(parentColor), series.color);
  149. }
  150. colorIndex = pick(point && point.options.colorIndex, level && level.colorIndex, colorIndexByPoint, parentColorIndex, options.colorIndex);
  151. }
  152. return {
  153. color: color,
  154. colorIndex: colorIndex
  155. };
  156. };
  157. /**
  158. * Creates a map from level number to its given options.
  159. *
  160. * @private
  161. * @function getLevelOptions
  162. * @param {object} params
  163. * Object containing parameters.
  164. * - `defaults` Object containing default options. The default options
  165. * are merged with the userOptions to get the final options for a
  166. * specific level.
  167. * - `from` The lowest level number.
  168. * - `levels` User options from series.levels.
  169. * - `to` The highest level number.
  170. * @return {Highcharts.Dictionary<object>|null}
  171. * Returns a map from level number to its given options.
  172. */
  173. var getLevelOptions = function getLevelOptions(params) {
  174. var result = null,
  175. defaults,
  176. converted,
  177. i,
  178. from,
  179. to,
  180. levels;
  181. if (isObject(params)) {
  182. result = {};
  183. from = isNumber(params.from) ? params.from : 1;
  184. levels = params.levels;
  185. converted = {};
  186. defaults = isObject(params.defaults) ? params.defaults : {};
  187. if (isArray(levels)) {
  188. converted = levels.reduce(function (obj, item) {
  189. var level,
  190. levelIsConstant,
  191. options;
  192. if (isObject(item) && isNumber(item.level)) {
  193. options = merge({}, item);
  194. levelIsConstant = (isBoolean(options.levelIsConstant) ?
  195. options.levelIsConstant :
  196. defaults.levelIsConstant);
  197. // Delete redundant properties.
  198. delete options.levelIsConstant;
  199. delete options.level;
  200. // Calculate which level these options apply to.
  201. level = item.level + (levelIsConstant ? 0 : from - 1);
  202. if (isObject(obj[level])) {
  203. extend(obj[level], options);
  204. }
  205. else {
  206. obj[level] = options;
  207. }
  208. }
  209. return obj;
  210. }, {});
  211. }
  212. to = isNumber(params.to) ? params.to : 1;
  213. for (i = 0; i <= to; i++) {
  214. result[i] = merge({}, defaults, isObject(converted[i]) ? converted[i] : {});
  215. }
  216. }
  217. return result;
  218. };
  219. /**
  220. * Update the rootId property on the series. Also makes sure that it is
  221. * accessible to exporting.
  222. *
  223. * @private
  224. * @function updateRootId
  225. *
  226. * @param {object} series
  227. * The series to operate on.
  228. *
  229. * @return {string}
  230. * Returns the resulting rootId after update.
  231. */
  232. var updateRootId = function (series) {
  233. var rootId,
  234. options;
  235. if (isObject(series)) {
  236. // Get the series options.
  237. options = isObject(series.options) ? series.options : {};
  238. // Calculate the rootId.
  239. rootId = pick(series.rootNode, options.rootId, '');
  240. // Set rootId on series.userOptions to pick it up in exporting.
  241. if (isObject(series.userOptions)) {
  242. series.userOptions.rootId = rootId;
  243. }
  244. // Set rootId on series to pick it up on next update.
  245. series.rootNode = rootId;
  246. }
  247. return rootId;
  248. };
  249. var result = {
  250. getColor: getColor,
  251. getLevelOptions: getLevelOptions,
  252. setTreeValues: setTreeValues,
  253. updateRootId: updateRootId
  254. };
  255. return result;
  256. });
  257. _registerModule(_modules, 'Mixins/DrawPoint.js', [], function () {
  258. /* *
  259. *
  260. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  261. *
  262. * */
  263. var isFn = function (x) {
  264. return typeof x === 'function';
  265. };
  266. /* eslint-disable no-invalid-this, valid-jsdoc */
  267. /**
  268. * Handles the drawing of a component.
  269. * Can be used for any type of component that reserves the graphic property, and
  270. * provides a shouldDraw on its context.
  271. *
  272. * @private
  273. * @function draw
  274. * @param {DrawPointParams} params
  275. * Parameters.
  276. *
  277. * @todo add type checking.
  278. * @todo export this function to enable usage
  279. */
  280. var draw = function draw(params) {
  281. var _a;
  282. var component = this,
  283. graphic = component.graphic,
  284. animatableAttribs = params.animatableAttribs,
  285. onComplete = params.onComplete,
  286. css = params.css,
  287. renderer = params.renderer,
  288. animation = (_a = component.series) === null || _a === void 0 ? void 0 : _a.options.animation;
  289. if (component.shouldDraw()) {
  290. if (!graphic) {
  291. component.graphic = graphic =
  292. renderer[params.shapeType](params.shapeArgs)
  293. .add(params.group);
  294. }
  295. graphic
  296. .css(css)
  297. .attr(params.attribs)
  298. .animate(animatableAttribs, params.isNew ? false : animation, onComplete);
  299. }
  300. else if (graphic) {
  301. var destroy = function () {
  302. component.graphic = graphic = graphic.destroy();
  303. if (isFn(onComplete)) {
  304. onComplete();
  305. }
  306. };
  307. // animate only runs complete callback if something was animated.
  308. if (Object.keys(animatableAttribs).length) {
  309. graphic.animate(animatableAttribs, void 0, function () {
  310. destroy();
  311. });
  312. }
  313. else {
  314. destroy();
  315. }
  316. }
  317. };
  318. /**
  319. * An extended version of draw customized for points.
  320. * It calls additional methods that is expected when rendering a point.
  321. * @private
  322. * @param {Highcharts.Dictionary<any>} params Parameters
  323. */
  324. var drawPoint = function drawPoint(params) {
  325. var point = this,
  326. attribs = params.attribs = params.attribs || {};
  327. // Assigning class in dot notation does go well in IE8
  328. // eslint-disable-next-line dot-notation
  329. attribs['class'] = point.getClassName();
  330. // Call draw to render component
  331. draw.call(point, params);
  332. };
  333. var drawPointModule = {
  334. draw: draw,
  335. drawPoint: drawPoint,
  336. isFn: isFn
  337. };
  338. return drawPointModule;
  339. });
  340. _registerModule(_modules, 'Series/TreemapSeries.js', [_modules['Core/Globals.js'], _modules['Mixins/TreeSeries.js'], _modules['Mixins/DrawPoint.js'], _modules['Core/Color.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, mixinTreeSeries, drawPointModule, Color, LegendSymbolMixin, Point, U) {
  341. /* *
  342. *
  343. * (c) 2014-2020 Highsoft AS
  344. *
  345. * Authors: Jon Arild Nygard / Oystein Moseng
  346. *
  347. * License: www.highcharts.com/license
  348. *
  349. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  350. *
  351. * */
  352. var getColor = mixinTreeSeries.getColor,
  353. getLevelOptions = mixinTreeSeries.getLevelOptions,
  354. updateRootId = mixinTreeSeries.updateRootId;
  355. var drawPoint = drawPointModule.drawPoint;
  356. var color = Color.parse;
  357. var addEvent = U.addEvent,
  358. correctFloat = U.correctFloat,
  359. defined = U.defined,
  360. error = U.error,
  361. extend = U.extend,
  362. fireEvent = U.fireEvent,
  363. isArray = U.isArray,
  364. isNumber = U.isNumber,
  365. isObject = U.isObject,
  366. isString = U.isString,
  367. merge = U.merge,
  368. objectEach = U.objectEach,
  369. pick = U.pick,
  370. seriesType = U.seriesType,
  371. stableSort = U.stableSort;
  372. /* eslint-disable no-invalid-this */
  373. var AXIS_MAX = 100;
  374. var seriesTypes = H.seriesTypes,
  375. noop = H.noop,
  376. // @todo Similar to eachObject, this function is likely redundant
  377. isBoolean = function (x) {
  378. return typeof x === 'boolean';
  379. }, Series = H.Series,
  380. // @todo Similar to recursive, this function is likely redundant
  381. eachObject = function (list, func, context) {
  382. context = context || this;
  383. objectEach(list, function (val, key) {
  384. func.call(context, val, key, list);
  385. });
  386. },
  387. // @todo find correct name for this function.
  388. // @todo Similar to reduce, this function is likely redundant
  389. recursive = function (item, func, context) {
  390. var next;
  391. context = context || this;
  392. next = func.call(context, item);
  393. if (next !== false) {
  394. recursive(next, func, context);
  395. }
  396. }, treemapAxisDefaultValues = false;
  397. /* eslint-enable no-invalid-this */
  398. /**
  399. * @private
  400. * @class
  401. * @name Highcharts.seriesTypes.treemap
  402. *
  403. * @augments Highcharts.Series
  404. */
  405. seriesType('treemap', 'scatter'
  406. /**
  407. * A treemap displays hierarchical data using nested rectangles. The data
  408. * can be laid out in varying ways depending on options.
  409. *
  410. * @sample highcharts/demo/treemap-large-dataset/
  411. * Treemap
  412. *
  413. * @extends plotOptions.scatter
  414. * @excluding dragDrop, marker, jitter, dataSorting
  415. * @product highcharts
  416. * @requires modules/treemap
  417. * @optionparent plotOptions.treemap
  418. */
  419. , {
  420. /**
  421. * When enabled the user can click on a point which is a parent and
  422. * zoom in on its children. Deprecated and replaced by
  423. * [allowTraversingTree](#plotOptions.treemap.allowTraversingTree).
  424. *
  425. * @sample {highcharts} highcharts/plotoptions/treemap-allowdrilltonode/
  426. * Enabled
  427. *
  428. * @deprecated
  429. * @type {boolean}
  430. * @default false
  431. * @since 4.1.0
  432. * @product highcharts
  433. * @apioption plotOptions.treemap.allowDrillToNode
  434. */
  435. /**
  436. * When enabled the user can click on a point which is a parent and
  437. * zoom in on its children.
  438. *
  439. * @sample {highcharts} highcharts/plotoptions/treemap-allowtraversingtree/
  440. * Enabled
  441. *
  442. * @since 7.0.3
  443. * @product highcharts
  444. */
  445. allowTraversingTree: false,
  446. animationLimit: 250,
  447. /**
  448. * When the series contains less points than the crop threshold, all
  449. * points are drawn, event if the points fall outside the visible plot
  450. * area at the current zoom. The advantage of drawing all points
  451. * (including markers and columns), is that animation is performed on
  452. * updates. On the other hand, when the series contains more points than
  453. * the crop threshold, the series data is cropped to only contain points
  454. * that fall within the plot area. The advantage of cropping away
  455. * invisible points is to increase performance on large series.
  456. *
  457. * @type {number}
  458. * @default 300
  459. * @since 4.1.0
  460. * @product highcharts
  461. * @apioption plotOptions.treemap.cropThreshold
  462. */
  463. /**
  464. * Fires on a request for change of root node for the tree, before the
  465. * update is made. An event object is passed to the function, containing
  466. * additional properties `newRootId`, `previousRootId`, `redraw` and
  467. * `trigger`.
  468. *
  469. * @type {function}
  470. * @default undefined
  471. * @sample {highcharts} highcharts/plotoptions/treemap-events-setrootnode/
  472. * Alert update information on setRootNode event.
  473. * @since 7.0.3
  474. * @product highcharts
  475. * @apioption plotOptions.treemap.events.setRootNode
  476. */
  477. /**
  478. * This option decides if the user can interact with the parent nodes
  479. * or just the leaf nodes. When this option is undefined, it will be
  480. * true by default. However when allowTraversingTree is true, then it
  481. * will be false by default.
  482. *
  483. * @sample {highcharts} highcharts/plotoptions/treemap-interactbyleaf-false/
  484. * False
  485. * @sample {highcharts} highcharts/plotoptions/treemap-interactbyleaf-true-and-allowtraversingtree/
  486. * InteractByLeaf and allowTraversingTree is true
  487. *
  488. * @type {boolean}
  489. * @since 4.1.2
  490. * @product highcharts
  491. * @apioption plotOptions.treemap.interactByLeaf
  492. */
  493. /**
  494. * The sort index of the point inside the treemap level.
  495. *
  496. * @sample {highcharts} highcharts/plotoptions/treemap-sortindex/
  497. * Sort by years
  498. *
  499. * @type {number}
  500. * @since 4.1.10
  501. * @product highcharts
  502. * @apioption plotOptions.treemap.sortIndex
  503. */
  504. /**
  505. * A series specific or series type specific color set to apply instead
  506. * of the global [colors](#colors) when
  507. * [colorByPoint](#plotOptions.treemap.colorByPoint) is true.
  508. *
  509. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  510. * @since 3.0
  511. * @product highcharts
  512. * @apioption plotOptions.treemap.colors
  513. */
  514. /**
  515. * Whether to display this series type or specific series item in the
  516. * legend.
  517. */
  518. showInLegend: false,
  519. /**
  520. * @ignore-option
  521. */
  522. marker: false,
  523. /**
  524. * When using automatic point colors pulled from the `options.colors`
  525. * collection, this option determines whether the chart should receive
  526. * one color per series or one color per point.
  527. *
  528. * @see [series colors](#plotOptions.treemap.colors)
  529. *
  530. * @since 2.0
  531. * @product highcharts
  532. * @apioption plotOptions.treemap.colorByPoint
  533. */
  534. colorByPoint: false,
  535. /**
  536. * @since 4.1.0
  537. */
  538. dataLabels: {
  539. defer: false,
  540. enabled: true,
  541. formatter: function () {
  542. var point = this && this.point ?
  543. this.point :
  544. {},
  545. name = isString(point.name) ? point.name : '';
  546. return name;
  547. },
  548. inside: true,
  549. verticalAlign: 'middle'
  550. },
  551. tooltip: {
  552. headerFormat: '',
  553. pointFormat: '<b>{point.name}</b>: {point.value}<br/>'
  554. },
  555. /**
  556. * Whether to ignore hidden points when the layout algorithm runs.
  557. * If `false`, hidden points will leave open spaces.
  558. *
  559. * @since 5.0.8
  560. */
  561. ignoreHiddenPoint: true,
  562. /**
  563. * This option decides which algorithm is used for setting position
  564. * and dimensions of the points.
  565. *
  566. * @see [How to write your own algorithm](https://www.highcharts.com/docs/chart-and-series-types/treemap)
  567. *
  568. * @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-sliceanddice/
  569. * SliceAndDice by default
  570. * @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-stripes/
  571. * Stripes
  572. * @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-squarified/
  573. * Squarified
  574. * @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-strip/
  575. * Strip
  576. *
  577. * @since 4.1.0
  578. * @validvalue ["sliceAndDice", "stripes", "squarified", "strip"]
  579. */
  580. layoutAlgorithm: 'sliceAndDice',
  581. /**
  582. * Defines which direction the layout algorithm will start drawing.
  583. *
  584. * @since 4.1.0
  585. * @validvalue ["vertical", "horizontal"]
  586. */
  587. layoutStartingDirection: 'vertical',
  588. /**
  589. * Enabling this option will make the treemap alternate the drawing
  590. * direction between vertical and horizontal. The next levels starting
  591. * direction will always be the opposite of the previous.
  592. *
  593. * @sample {highcharts} highcharts/plotoptions/treemap-alternatestartingdirection-true/
  594. * Enabled
  595. *
  596. * @since 4.1.0
  597. */
  598. alternateStartingDirection: false,
  599. /**
  600. * Used together with the levels and allowTraversingTree options. When
  601. * set to false the first level visible to be level one, which is
  602. * dynamic when traversing the tree. Otherwise the level will be the
  603. * same as the tree structure.
  604. *
  605. * @since 4.1.0
  606. */
  607. levelIsConstant: true,
  608. /**
  609. * Options for the button appearing when drilling down in a treemap.
  610. * Deprecated and replaced by
  611. * [traverseUpButton](#plotOptions.treemap.traverseUpButton).
  612. *
  613. * @deprecated
  614. */
  615. drillUpButton: {
  616. /**
  617. * The position of the button.
  618. *
  619. * @deprecated
  620. */
  621. position: {
  622. /**
  623. * Vertical alignment of the button.
  624. *
  625. * @deprecated
  626. * @type {Highcharts.VerticalAlignValue}
  627. * @default top
  628. * @product highcharts
  629. * @apioption plotOptions.treemap.drillUpButton.position.verticalAlign
  630. */
  631. /**
  632. * Horizontal alignment of the button.
  633. *
  634. * @deprecated
  635. * @type {Highcharts.AlignValue}
  636. */
  637. align: 'right',
  638. /**
  639. * Horizontal offset of the button.
  640. *
  641. * @deprecated
  642. */
  643. x: -10,
  644. /**
  645. * Vertical offset of the button.
  646. *
  647. * @deprecated
  648. */
  649. y: 10
  650. }
  651. },
  652. /**
  653. * Options for the button appearing when traversing down in a treemap.
  654. */
  655. traverseUpButton: {
  656. /**
  657. * The position of the button.
  658. */
  659. position: {
  660. /**
  661. * Vertical alignment of the button.
  662. *
  663. * @type {Highcharts.VerticalAlignValue}
  664. * @default top
  665. * @product highcharts
  666. * @apioption plotOptions.treemap.traverseUpButton.position.verticalAlign
  667. */
  668. /**
  669. * Horizontal alignment of the button.
  670. *
  671. * @type {Highcharts.AlignValue}
  672. */
  673. align: 'right',
  674. /**
  675. * Horizontal offset of the button.
  676. */
  677. x: -10,
  678. /**
  679. * Vertical offset of the button.
  680. */
  681. y: 10
  682. }
  683. },
  684. /**
  685. * Set options on specific levels. Takes precedence over series options,
  686. * but not point options.
  687. *
  688. * @sample {highcharts} highcharts/plotoptions/treemap-levels/
  689. * Styling dataLabels and borders
  690. * @sample {highcharts} highcharts/demo/treemap-with-levels/
  691. * Different layoutAlgorithm
  692. *
  693. * @type {Array<*>}
  694. * @since 4.1.0
  695. * @product highcharts
  696. * @apioption plotOptions.treemap.levels
  697. */
  698. /**
  699. * Can set a `borderColor` on all points which lies on the same level.
  700. *
  701. * @type {Highcharts.ColorString}
  702. * @since 4.1.0
  703. * @product highcharts
  704. * @apioption plotOptions.treemap.levels.borderColor
  705. */
  706. /**
  707. * Set the dash style of the border of all the point which lies on the
  708. * level. See
  709. * [plotOptions.scatter.dashStyle](#plotoptions.scatter.dashstyle)
  710. * for possible options.
  711. *
  712. * @type {Highcharts.DashStyleValue}
  713. * @since 4.1.0
  714. * @product highcharts
  715. * @apioption plotOptions.treemap.levels.borderDashStyle
  716. */
  717. /**
  718. * Can set the borderWidth on all points which lies on the same level.
  719. *
  720. * @type {number}
  721. * @since 4.1.0
  722. * @product highcharts
  723. * @apioption plotOptions.treemap.levels.borderWidth
  724. */
  725. /**
  726. * Can set a color on all points which lies on the same level.
  727. *
  728. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  729. * @since 4.1.0
  730. * @product highcharts
  731. * @apioption plotOptions.treemap.levels.color
  732. */
  733. /**
  734. * A configuration object to define how the color of a child varies from
  735. * the parent's color. The variation is distributed among the children
  736. * of node. For example when setting brightness, the brightness change
  737. * will range from the parent's original brightness on the first child,
  738. * to the amount set in the `to` setting on the last node. This allows a
  739. * gradient-like color scheme that sets children out from each other
  740. * while highlighting the grouping on treemaps and sectors on sunburst
  741. * charts.
  742. *
  743. * @sample highcharts/demo/sunburst/
  744. * Sunburst with color variation
  745. *
  746. * @since 6.0.0
  747. * @product highcharts
  748. * @apioption plotOptions.treemap.levels.colorVariation
  749. */
  750. /**
  751. * The key of a color variation. Currently supports `brightness` only.
  752. *
  753. * @type {string}
  754. * @since 6.0.0
  755. * @product highcharts
  756. * @validvalue ["brightness"]
  757. * @apioption plotOptions.treemap.levels.colorVariation.key
  758. */
  759. /**
  760. * The ending value of a color variation. The last sibling will receive
  761. * this value.
  762. *
  763. * @type {number}
  764. * @since 6.0.0
  765. * @product highcharts
  766. * @apioption plotOptions.treemap.levels.colorVariation.to
  767. */
  768. /**
  769. * Can set the options of dataLabels on each point which lies on the
  770. * level.
  771. * [plotOptions.treemap.dataLabels](#plotOptions.treemap.dataLabels) for
  772. * possible values.
  773. *
  774. * @extends plotOptions.treemap.dataLabels
  775. * @since 4.1.0
  776. * @product highcharts
  777. * @apioption plotOptions.treemap.levels.dataLabels
  778. */
  779. /**
  780. * Can set the layoutAlgorithm option on a specific level.
  781. *
  782. * @type {string}
  783. * @since 4.1.0
  784. * @product highcharts
  785. * @validvalue ["sliceAndDice", "stripes", "squarified", "strip"]
  786. * @apioption plotOptions.treemap.levels.layoutAlgorithm
  787. */
  788. /**
  789. * Can set the layoutStartingDirection option on a specific level.
  790. *
  791. * @type {string}
  792. * @since 4.1.0
  793. * @product highcharts
  794. * @validvalue ["vertical", "horizontal"]
  795. * @apioption plotOptions.treemap.levels.layoutStartingDirection
  796. */
  797. /**
  798. * Decides which level takes effect from the options set in the levels
  799. * object.
  800. *
  801. * @sample {highcharts} highcharts/plotoptions/treemap-levels/
  802. * Styling of both levels
  803. *
  804. * @type {number}
  805. * @since 4.1.0
  806. * @product highcharts
  807. * @apioption plotOptions.treemap.levels.level
  808. */
  809. // Presentational options
  810. /**
  811. * The color of the border surrounding each tree map item.
  812. *
  813. * @type {Highcharts.ColorString}
  814. */
  815. borderColor: '#e6e6e6',
  816. /**
  817. * The width of the border surrounding each tree map item.
  818. */
  819. borderWidth: 1,
  820. colorKey: 'colorValue',
  821. /**
  822. * The opacity of a point in treemap. When a point has children, the
  823. * visibility of the children is determined by the opacity.
  824. *
  825. * @since 4.2.4
  826. */
  827. opacity: 0.15,
  828. /**
  829. * A wrapper object for all the series options in specific states.
  830. *
  831. * @extends plotOptions.heatmap.states
  832. */
  833. states: {
  834. /**
  835. * Options for the hovered series
  836. *
  837. * @extends plotOptions.heatmap.states.hover
  838. * @excluding halo
  839. */
  840. hover: {
  841. /**
  842. * The border color for the hovered state.
  843. */
  844. borderColor: '#999999',
  845. /**
  846. * Brightness for the hovered point. Defaults to 0 if the
  847. * heatmap series is loaded first, otherwise 0.1.
  848. *
  849. * @type {number}
  850. * @default undefined
  851. */
  852. brightness: seriesTypes.heatmap ? 0 : 0.1,
  853. /**
  854. * @extends plotOptions.heatmap.states.hover.halo
  855. */
  856. halo: false,
  857. /**
  858. * The opacity of a point in treemap. When a point has children,
  859. * the visibility of the children is determined by the opacity.
  860. *
  861. * @since 4.2.4
  862. */
  863. opacity: 0.75,
  864. /**
  865. * The shadow option for hovered state.
  866. */
  867. shadow: false
  868. }
  869. }
  870. // Prototype members
  871. }, {
  872. pointArrayMap: ['value'],
  873. directTouch: true,
  874. optionalAxis: 'colorAxis',
  875. getSymbol: noop,
  876. parallelArrays: ['x', 'y', 'value', 'colorValue'],
  877. colorKey: 'colorValue',
  878. trackerGroups: ['group', 'dataLabelsGroup'],
  879. /* eslint-disable no-invalid-this, valid-jsdoc */
  880. /**
  881. * Creates an object map from parent id to childrens index.
  882. *
  883. * @private
  884. * @function Highcharts.Series#getListOfParents
  885. *
  886. * @param {Highcharts.SeriesTreemapDataOptions} [data]
  887. * List of points set in options.
  888. *
  889. * @param {Array<string>} [existingIds]
  890. * List of all point ids.
  891. *
  892. * @return {object}
  893. * Map from parent id to children index in data.
  894. */
  895. getListOfParents: function (data, existingIds) {
  896. var arr = isArray(data) ? data : [],
  897. ids = isArray(existingIds) ? existingIds : [],
  898. listOfParents = arr.reduce(function (prev,
  899. curr,
  900. i) {
  901. var parent = pick(curr.parent, '');
  902. if (typeof prev[parent] === 'undefined') {
  903. prev[parent] = [];
  904. }
  905. prev[parent].push(i);
  906. return prev;
  907. }, {
  908. '': [] // Root of tree
  909. });
  910. // If parent does not exist, hoist parent to root of tree.
  911. eachObject(listOfParents, function (children, parent, list) {
  912. if ((parent !== '') && (ids.indexOf(parent) === -1)) {
  913. children.forEach(function (child) {
  914. list[''].push(child);
  915. });
  916. delete list[parent];
  917. }
  918. });
  919. return listOfParents;
  920. },
  921. // Creates a tree structured object from the series points
  922. getTree: function () {
  923. var series = this,
  924. allIds = this.data.map(function (d) {
  925. return d.id;
  926. }), parentList = series.getListOfParents(this.data, allIds);
  927. series.nodeMap = [];
  928. return series.buildNode('', -1, 0, parentList, null);
  929. },
  930. // Define hasData function for non-cartesian series.
  931. // Returns true if the series has points at all.
  932. hasData: function () {
  933. return !!this.processedXData.length; // != 0
  934. },
  935. init: function (chart, options) {
  936. var series = this,
  937. colorMapSeriesMixin = H.colorMapSeriesMixin,
  938. setOptionsEvent;
  939. // If color series logic is loaded, add some properties
  940. if (colorMapSeriesMixin) {
  941. this.colorAttribs = colorMapSeriesMixin.colorAttribs;
  942. }
  943. setOptionsEvent = addEvent(series, 'setOptions', function (event) {
  944. var options = event.userOptions;
  945. if (defined(options.allowDrillToNode) &&
  946. !defined(options.allowTraversingTree)) {
  947. options.allowTraversingTree = options.allowDrillToNode;
  948. delete options.allowDrillToNode;
  949. }
  950. if (defined(options.drillUpButton) &&
  951. !defined(options.traverseUpButton)) {
  952. options.traverseUpButton = options.drillUpButton;
  953. delete options.drillUpButton;
  954. }
  955. });
  956. Series.prototype.init.call(series, chart, options);
  957. // Treemap's opacity is a different option from other series
  958. delete series.opacity;
  959. // Handle deprecated options.
  960. series.eventsToUnbind.push(setOptionsEvent);
  961. if (series.options.allowTraversingTree) {
  962. series.eventsToUnbind.push(addEvent(series, 'click', series.onClickDrillToNode));
  963. }
  964. },
  965. buildNode: function (id, i, level, list, parent) {
  966. var series = this,
  967. children = [],
  968. point = series.points[i],
  969. height = 0,
  970. node,
  971. child;
  972. // Actions
  973. ((list[id] || [])).forEach(function (i) {
  974. child = series.buildNode(series.points[i].id, i, (level + 1), list, id);
  975. height = Math.max(child.height + 1, height);
  976. children.push(child);
  977. });
  978. node = {
  979. id: id,
  980. i: i,
  981. children: children,
  982. height: height,
  983. level: level,
  984. parent: parent,
  985. visible: false // @todo move this to better location
  986. };
  987. series.nodeMap[node.id] = node;
  988. if (point) {
  989. point.node = node;
  990. }
  991. return node;
  992. },
  993. setTreeValues: function (tree) {
  994. var series = this,
  995. options = series.options,
  996. idRoot = series.rootNode,
  997. mapIdToNode = series.nodeMap,
  998. nodeRoot = mapIdToNode[idRoot],
  999. levelIsConstant = (isBoolean(options.levelIsConstant) ?
  1000. options.levelIsConstant :
  1001. true),
  1002. childrenTotal = 0,
  1003. children = [],
  1004. val,
  1005. point = series.points[tree.i];
  1006. // First give the children some values
  1007. tree.children.forEach(function (child) {
  1008. child = series.setTreeValues(child);
  1009. children.push(child);
  1010. if (!child.ignore) {
  1011. childrenTotal += child.val;
  1012. }
  1013. });
  1014. // Sort the children
  1015. stableSort(children, function (a, b) {
  1016. return a.sortIndex - b.sortIndex;
  1017. });
  1018. // Set the values
  1019. val = pick(point && point.options.value, childrenTotal);
  1020. if (point) {
  1021. point.value = val;
  1022. }
  1023. extend(tree, {
  1024. children: children,
  1025. childrenTotal: childrenTotal,
  1026. // Ignore this node if point is not visible
  1027. ignore: !(pick(point && point.visible, true) && (val > 0)),
  1028. isLeaf: tree.visible && !childrenTotal,
  1029. levelDynamic: (tree.level - (levelIsConstant ? 0 : nodeRoot.level)),
  1030. name: pick(point && point.name, ''),
  1031. sortIndex: pick(point && point.sortIndex, -val),
  1032. val: val
  1033. });
  1034. return tree;
  1035. },
  1036. /**
  1037. * Recursive function which calculates the area for all children of a
  1038. * node.
  1039. *
  1040. * @private
  1041. * @function Highcharts.Series#calculateChildrenAreas
  1042. *
  1043. * @param {object} node
  1044. * The node which is parent to the children.
  1045. *
  1046. * @param {object} area
  1047. * The rectangular area of the parent.
  1048. */
  1049. calculateChildrenAreas: function (parent, area) {
  1050. var series = this,
  1051. options = series.options,
  1052. mapOptionsToLevel = series.mapOptionsToLevel,
  1053. level = mapOptionsToLevel[parent.level + 1],
  1054. algorithm = pick((series[(level && level.layoutAlgorithm)] &&
  1055. level.layoutAlgorithm),
  1056. options.layoutAlgorithm),
  1057. alternate = options.alternateStartingDirection,
  1058. childrenValues = [],
  1059. children;
  1060. // Collect all children which should be included
  1061. children = parent.children.filter(function (n) {
  1062. return !n.ignore;
  1063. });
  1064. if (level && level.layoutStartingDirection) {
  1065. area.direction = level.layoutStartingDirection === 'vertical' ?
  1066. 0 :
  1067. 1;
  1068. }
  1069. childrenValues = series[algorithm](area, children);
  1070. children.forEach(function (child, index) {
  1071. var values = childrenValues[index];
  1072. child.values = merge(values, {
  1073. val: child.childrenTotal,
  1074. direction: (alternate ? 1 - area.direction : area.direction)
  1075. });
  1076. child.pointValues = merge(values, {
  1077. x: (values.x / series.axisRatio),
  1078. // Flip y-values to avoid visual regression with csvCoord in
  1079. // Axis.translate at setPointValues. #12488
  1080. y: AXIS_MAX - values.y - values.height,
  1081. width: (values.width / series.axisRatio)
  1082. });
  1083. // If node has children, then call method recursively
  1084. if (child.children.length) {
  1085. series.calculateChildrenAreas(child, child.values);
  1086. }
  1087. });
  1088. },
  1089. setPointValues: function () {
  1090. var series = this;
  1091. var points = series.points,
  1092. xAxis = series.xAxis,
  1093. yAxis = series.yAxis;
  1094. var styledMode = series.chart.styledMode;
  1095. // Get the crisp correction in classic mode. For this to work in
  1096. // styled mode, we would need to first add the shape (without x,
  1097. // y, width and height), then read the rendered stroke width
  1098. // using point.graphic.strokeWidth(), then modify and apply the
  1099. // shapeArgs. This applies also to column series, but the
  1100. // downside is performance and code complexity.
  1101. var getCrispCorrection = function (point) { return (styledMode ?
  1102. 0 :
  1103. ((series.pointAttribs(point)['stroke-width'] || 0) % 2) / 2); };
  1104. points.forEach(function (point) {
  1105. var _a = point.node,
  1106. values = _a.pointValues,
  1107. visible = _a.visible;
  1108. // Points which is ignored, have no values.
  1109. if (values && visible) {
  1110. var height = values.height,
  1111. width = values.width,
  1112. x = values.x,
  1113. y = values.y;
  1114. var crispCorr = getCrispCorrection(point);
  1115. var x1 = Math.round(xAxis.toPixels(x,
  1116. true)) - crispCorr;
  1117. var x2 = Math.round(xAxis.toPixels(x + width,
  1118. true)) - crispCorr;
  1119. var y1 = Math.round(yAxis.toPixels(y,
  1120. true)) - crispCorr;
  1121. var y2 = Math.round(yAxis.toPixels(y + height,
  1122. true)) - crispCorr;
  1123. // Set point values
  1124. point.shapeArgs = {
  1125. x: Math.min(x1, x2),
  1126. y: Math.min(y1, y2),
  1127. width: Math.abs(x2 - x1),
  1128. height: Math.abs(y2 - y1)
  1129. };
  1130. point.plotX =
  1131. point.shapeArgs.x + (point.shapeArgs.width / 2);
  1132. point.plotY =
  1133. point.shapeArgs.y + (point.shapeArgs.height / 2);
  1134. }
  1135. else {
  1136. // Reset visibility
  1137. delete point.plotX;
  1138. delete point.plotY;
  1139. }
  1140. });
  1141. },
  1142. // Set the node's color recursively, from the parent down.
  1143. setColorRecursive: function (node, parentColor, colorIndex, index, siblings) {
  1144. var series = this,
  1145. chart = series && series.chart,
  1146. colors = chart && chart.options && chart.options.colors,
  1147. colorInfo,
  1148. point;
  1149. if (node) {
  1150. colorInfo = getColor(node, {
  1151. colors: colors,
  1152. index: index,
  1153. mapOptionsToLevel: series.mapOptionsToLevel,
  1154. parentColor: parentColor,
  1155. parentColorIndex: colorIndex,
  1156. series: series,
  1157. siblings: siblings
  1158. });
  1159. point = series.points[node.i];
  1160. if (point) {
  1161. point.color = colorInfo.color;
  1162. point.colorIndex = colorInfo.colorIndex;
  1163. }
  1164. // Do it all again with the children
  1165. (node.children || []).forEach(function (child, i) {
  1166. series.setColorRecursive(child, colorInfo.color, colorInfo.colorIndex, i, node.children.length);
  1167. });
  1168. }
  1169. },
  1170. algorithmGroup: function (h, w, d, p) {
  1171. this.height = h;
  1172. this.width = w;
  1173. this.plot = p;
  1174. this.direction = d;
  1175. this.startDirection = d;
  1176. this.total = 0;
  1177. this.nW = 0;
  1178. this.lW = 0;
  1179. this.nH = 0;
  1180. this.lH = 0;
  1181. this.elArr = [];
  1182. this.lP = {
  1183. total: 0,
  1184. lH: 0,
  1185. nH: 0,
  1186. lW: 0,
  1187. nW: 0,
  1188. nR: 0,
  1189. lR: 0,
  1190. aspectRatio: function (w, h) {
  1191. return Math.max((w / h), (h / w));
  1192. }
  1193. };
  1194. this.addElement = function (el) {
  1195. this.lP.total = this.elArr[this.elArr.length - 1];
  1196. this.total = this.total + el;
  1197. if (this.direction === 0) {
  1198. // Calculate last point old aspect ratio
  1199. this.lW = this.nW;
  1200. this.lP.lH = this.lP.total / this.lW;
  1201. this.lP.lR = this.lP.aspectRatio(this.lW, this.lP.lH);
  1202. // Calculate last point new aspect ratio
  1203. this.nW = this.total / this.height;
  1204. this.lP.nH = this.lP.total / this.nW;
  1205. this.lP.nR = this.lP.aspectRatio(this.nW, this.lP.nH);
  1206. }
  1207. else {
  1208. // Calculate last point old aspect ratio
  1209. this.lH = this.nH;
  1210. this.lP.lW = this.lP.total / this.lH;
  1211. this.lP.lR = this.lP.aspectRatio(this.lP.lW, this.lH);
  1212. // Calculate last point new aspect ratio
  1213. this.nH = this.total / this.width;
  1214. this.lP.nW = this.lP.total / this.nH;
  1215. this.lP.nR = this.lP.aspectRatio(this.lP.nW, this.nH);
  1216. }
  1217. this.elArr.push(el);
  1218. };
  1219. this.reset = function () {
  1220. this.nW = 0;
  1221. this.lW = 0;
  1222. this.elArr = [];
  1223. this.total = 0;
  1224. };
  1225. },
  1226. algorithmCalcPoints: function (directionChange, last, group, childrenArea) {
  1227. var pX,
  1228. pY,
  1229. pW,
  1230. pH,
  1231. gW = group.lW,
  1232. gH = group.lH,
  1233. plot = group.plot,
  1234. keep,
  1235. i = 0,
  1236. end = group.elArr.length - 1;
  1237. if (last) {
  1238. gW = group.nW;
  1239. gH = group.nH;
  1240. }
  1241. else {
  1242. keep = group.elArr[group.elArr.length - 1];
  1243. }
  1244. group.elArr.forEach(function (p) {
  1245. if (last || (i < end)) {
  1246. if (group.direction === 0) {
  1247. pX = plot.x;
  1248. pY = plot.y;
  1249. pW = gW;
  1250. pH = p / pW;
  1251. }
  1252. else {
  1253. pX = plot.x;
  1254. pY = plot.y;
  1255. pH = gH;
  1256. pW = p / pH;
  1257. }
  1258. childrenArea.push({
  1259. x: pX,
  1260. y: pY,
  1261. width: pW,
  1262. height: correctFloat(pH)
  1263. });
  1264. if (group.direction === 0) {
  1265. plot.y = plot.y + pH;
  1266. }
  1267. else {
  1268. plot.x = plot.x + pW;
  1269. }
  1270. }
  1271. i = i + 1;
  1272. });
  1273. // Reset variables
  1274. group.reset();
  1275. if (group.direction === 0) {
  1276. group.width = group.width - gW;
  1277. }
  1278. else {
  1279. group.height = group.height - gH;
  1280. }
  1281. plot.y = plot.parent.y + (plot.parent.height - group.height);
  1282. plot.x = plot.parent.x + (plot.parent.width - group.width);
  1283. if (directionChange) {
  1284. group.direction = 1 - group.direction;
  1285. }
  1286. // If not last, then add uncalculated element
  1287. if (!last) {
  1288. group.addElement(keep);
  1289. }
  1290. },
  1291. algorithmLowAspectRatio: function (directionChange, parent, children) {
  1292. var childrenArea = [],
  1293. series = this,
  1294. pTot,
  1295. plot = {
  1296. x: parent.x,
  1297. y: parent.y,
  1298. parent: parent
  1299. },
  1300. direction = parent.direction,
  1301. i = 0,
  1302. end = children.length - 1,
  1303. group = new this.algorithmGroup(// eslint-disable-line new-cap
  1304. parent.height,
  1305. parent.width,
  1306. direction,
  1307. plot);
  1308. // Loop through and calculate all areas
  1309. children.forEach(function (child) {
  1310. pTot =
  1311. (parent.width * parent.height) * (child.val / parent.val);
  1312. group.addElement(pTot);
  1313. if (group.lP.nR > group.lP.lR) {
  1314. series.algorithmCalcPoints(directionChange, false, group, childrenArea, plot // @todo no supported
  1315. );
  1316. }
  1317. // If last child, then calculate all remaining areas
  1318. if (i === end) {
  1319. series.algorithmCalcPoints(directionChange, true, group, childrenArea, plot // @todo not supported
  1320. );
  1321. }
  1322. i = i + 1;
  1323. });
  1324. return childrenArea;
  1325. },
  1326. algorithmFill: function (directionChange, parent, children) {
  1327. var childrenArea = [],
  1328. pTot,
  1329. direction = parent.direction,
  1330. x = parent.x,
  1331. y = parent.y,
  1332. width = parent.width,
  1333. height = parent.height,
  1334. pX,
  1335. pY,
  1336. pW,
  1337. pH;
  1338. children.forEach(function (child) {
  1339. pTot =
  1340. (parent.width * parent.height) * (child.val / parent.val);
  1341. pX = x;
  1342. pY = y;
  1343. if (direction === 0) {
  1344. pH = height;
  1345. pW = pTot / pH;
  1346. width = width - pW;
  1347. x = x + pW;
  1348. }
  1349. else {
  1350. pW = width;
  1351. pH = pTot / pW;
  1352. height = height - pH;
  1353. y = y + pH;
  1354. }
  1355. childrenArea.push({
  1356. x: pX,
  1357. y: pY,
  1358. width: pW,
  1359. height: pH
  1360. });
  1361. if (directionChange) {
  1362. direction = 1 - direction;
  1363. }
  1364. });
  1365. return childrenArea;
  1366. },
  1367. strip: function (parent, children) {
  1368. return this.algorithmLowAspectRatio(false, parent, children);
  1369. },
  1370. squarified: function (parent, children) {
  1371. return this.algorithmLowAspectRatio(true, parent, children);
  1372. },
  1373. sliceAndDice: function (parent, children) {
  1374. return this.algorithmFill(true, parent, children);
  1375. },
  1376. stripes: function (parent, children) {
  1377. return this.algorithmFill(false, parent, children);
  1378. },
  1379. translate: function () {
  1380. var series = this,
  1381. options = series.options,
  1382. // NOTE: updateRootId modifies series.
  1383. rootId = updateRootId(series),
  1384. rootNode,
  1385. pointValues,
  1386. seriesArea,
  1387. tree,
  1388. val;
  1389. // Call prototype function
  1390. Series.prototype.translate.call(series);
  1391. // @todo Only if series.isDirtyData is true
  1392. tree = series.tree = series.getTree();
  1393. rootNode = series.nodeMap[rootId];
  1394. series.renderTraverseUpButton(rootId);
  1395. series.mapOptionsToLevel = getLevelOptions({
  1396. from: rootNode.level + 1,
  1397. levels: options.levels,
  1398. to: tree.height,
  1399. defaults: {
  1400. levelIsConstant: series.options.levelIsConstant,
  1401. colorByPoint: options.colorByPoint
  1402. }
  1403. });
  1404. if (rootId !== '' &&
  1405. (!rootNode || !rootNode.children.length)) {
  1406. series.setRootNode('', false);
  1407. rootId = series.rootNode;
  1408. rootNode = series.nodeMap[rootId];
  1409. }
  1410. // Parents of the root node is by default visible
  1411. recursive(series.nodeMap[series.rootNode], function (node) {
  1412. var next = false,
  1413. p = node.parent;
  1414. node.visible = true;
  1415. if (p || p === '') {
  1416. next = series.nodeMap[p];
  1417. }
  1418. return next;
  1419. });
  1420. // Children of the root node is by default visible
  1421. recursive(series.nodeMap[series.rootNode].children, function (children) {
  1422. var next = false;
  1423. children.forEach(function (child) {
  1424. child.visible = true;
  1425. if (child.children.length) {
  1426. next = (next || []).concat(child.children);
  1427. }
  1428. });
  1429. return next;
  1430. });
  1431. series.setTreeValues(tree);
  1432. // Calculate plotting values.
  1433. series.axisRatio = (series.xAxis.len / series.yAxis.len);
  1434. series.nodeMap[''].pointValues = pointValues = {
  1435. x: 0,
  1436. y: 0,
  1437. width: AXIS_MAX,
  1438. height: AXIS_MAX
  1439. };
  1440. series.nodeMap[''].values = seriesArea = merge(pointValues, {
  1441. width: (pointValues.width * series.axisRatio),
  1442. direction: (options.layoutStartingDirection === 'vertical' ? 0 : 1),
  1443. val: tree.val
  1444. });
  1445. series.calculateChildrenAreas(tree, seriesArea);
  1446. // Logic for point colors
  1447. if (!series.colorAxis &&
  1448. !options.colorByPoint) {
  1449. series.setColorRecursive(series.tree);
  1450. }
  1451. // Update axis extremes according to the root node.
  1452. if (options.allowTraversingTree) {
  1453. val = rootNode.pointValues;
  1454. series.xAxis.setExtremes(val.x, val.x + val.width, false);
  1455. series.yAxis.setExtremes(val.y, val.y + val.height, false);
  1456. series.xAxis.setScale();
  1457. series.yAxis.setScale();
  1458. }
  1459. // Assign values to points.
  1460. series.setPointValues();
  1461. },
  1462. /**
  1463. * Extend drawDataLabels with logic to handle custom options related to
  1464. * the treemap series:
  1465. *
  1466. * - Points which is not a leaf node, has dataLabels disabled by
  1467. * default.
  1468. *
  1469. * - Options set on series.levels is merged in.
  1470. *
  1471. * - Width of the dataLabel is set to match the width of the point
  1472. * shape.
  1473. *
  1474. * @private
  1475. * @function Highcharts.Series#drawDataLabels
  1476. */
  1477. drawDataLabels: function () {
  1478. var series = this,
  1479. mapOptionsToLevel = series.mapOptionsToLevel,
  1480. points = series.points.filter(function (n) {
  1481. return n.node.visible;
  1482. }), options, level;
  1483. points.forEach(function (point) {
  1484. level = mapOptionsToLevel[point.node.level];
  1485. // Set options to new object to avoid problems with scope
  1486. options = { style: {} };
  1487. // If not a leaf, then label should be disabled as default
  1488. if (!point.node.isLeaf) {
  1489. options.enabled = false;
  1490. }
  1491. // If options for level exists, include them as well
  1492. if (level && level.dataLabels) {
  1493. options = merge(options, level.dataLabels);
  1494. series._hasPointLabels = true;
  1495. }
  1496. // Set dataLabel width to the width of the point shape.
  1497. if (point.shapeArgs) {
  1498. options.style.width = point.shapeArgs.width;
  1499. if (point.dataLabel) {
  1500. point.dataLabel.css({
  1501. width: point.shapeArgs.width + 'px'
  1502. });
  1503. }
  1504. }
  1505. // Merge custom options with point options
  1506. point.dlOptions = merge(options, point.options.dataLabels);
  1507. });
  1508. Series.prototype.drawDataLabels.call(this);
  1509. },
  1510. // Over the alignment method by setting z index
  1511. alignDataLabel: function (point, dataLabel, labelOptions) {
  1512. var style = labelOptions.style;
  1513. // #8160: Prevent the label from exceeding the point's
  1514. // boundaries in treemaps by applying ellipsis overflow.
  1515. // The issue was happening when datalabel's text contained a
  1516. // long sequence of characters without a whitespace.
  1517. if (!defined(style.textOverflow) &&
  1518. dataLabel.text &&
  1519. dataLabel.getBBox().width > dataLabel.text.textWidth) {
  1520. dataLabel.css({
  1521. textOverflow: 'ellipsis',
  1522. // unit (px) is required when useHTML is true
  1523. width: style.width += 'px'
  1524. });
  1525. }
  1526. seriesTypes.column.prototype.alignDataLabel.apply(this, arguments);
  1527. if (point.dataLabel) {
  1528. // point.node.zIndex could be undefined (#6956)
  1529. point.dataLabel.attr({ zIndex: (point.node.zIndex || 0) + 1 });
  1530. }
  1531. },
  1532. // Get presentational attributes
  1533. pointAttribs: function (point, state) {
  1534. var series = this,
  1535. mapOptionsToLevel = (isObject(series.mapOptionsToLevel) ?
  1536. series.mapOptionsToLevel :
  1537. {}),
  1538. level = point && mapOptionsToLevel[point.node.level] || {},
  1539. options = this.options,
  1540. attr,
  1541. stateOptions = (state && options.states[state]) || {},
  1542. className = (point && point.getClassName()) || '',
  1543. opacity;
  1544. // Set attributes by precedence. Point trumps level trumps series.
  1545. // Stroke width uses pick because it can be 0.
  1546. attr = {
  1547. 'stroke': (point && point.borderColor) ||
  1548. level.borderColor ||
  1549. stateOptions.borderColor ||
  1550. options.borderColor,
  1551. 'stroke-width': pick(point && point.borderWidth, level.borderWidth, stateOptions.borderWidth, options.borderWidth),
  1552. 'dashstyle': (point && point.borderDashStyle) ||
  1553. level.borderDashStyle ||
  1554. stateOptions.borderDashStyle ||
  1555. options.borderDashStyle,
  1556. 'fill': (point && point.color) || this.color
  1557. };
  1558. // Hide levels above the current view
  1559. if (className.indexOf('highcharts-above-level') !== -1) {
  1560. attr.fill = 'none';
  1561. attr['stroke-width'] = 0;
  1562. // Nodes with children that accept interaction
  1563. }
  1564. else if (className.indexOf('highcharts-internal-node-interactive') !== -1) {
  1565. opacity = pick(stateOptions.opacity, options.opacity);
  1566. attr.fill = color(attr.fill).setOpacity(opacity).get();
  1567. attr.cursor = 'pointer';
  1568. // Hide nodes that have children
  1569. }
  1570. else if (className.indexOf('highcharts-internal-node') !== -1) {
  1571. attr.fill = 'none';
  1572. }
  1573. else if (state) {
  1574. // Brighten and hoist the hover nodes
  1575. attr.fill = color(attr.fill)
  1576. .brighten(stateOptions.brightness)
  1577. .get();
  1578. }
  1579. return attr;
  1580. },
  1581. // Override drawPoints
  1582. drawPoints: function () {
  1583. var series = this,
  1584. chart = series.chart,
  1585. renderer = chart.renderer,
  1586. points = series.points,
  1587. styledMode = chart.styledMode,
  1588. options = series.options,
  1589. shadow = styledMode ? {} : options.shadow,
  1590. borderRadius = options.borderRadius,
  1591. withinAnimationLimit = chart.pointCount < options.animationLimit,
  1592. allowTraversingTree = options.allowTraversingTree;
  1593. points.forEach(function (point) {
  1594. var levelDynamic = point.node.levelDynamic,
  1595. animate = {},
  1596. attr = {},
  1597. css = {},
  1598. groupKey = 'level-group-' + levelDynamic,
  1599. hasGraphic = !!point.graphic,
  1600. shouldAnimate = withinAnimationLimit && hasGraphic,
  1601. shapeArgs = point.shapeArgs;
  1602. // Don't bother with calculate styling if the point is not drawn
  1603. if (point.shouldDraw()) {
  1604. if (borderRadius) {
  1605. attr.r = borderRadius;
  1606. }
  1607. merge(true, // Extend object
  1608. // Which object to extend
  1609. shouldAnimate ? animate : attr,
  1610. // Add shapeArgs to animate/attr if graphic exists
  1611. hasGraphic ? shapeArgs : {},
  1612. // Add style attribs if !styleMode
  1613. styledMode ?
  1614. {} :
  1615. series.pointAttribs(point, (point.selected && 'select')));
  1616. // In styled mode apply point.color. Use CSS, otherwise the
  1617. // fill used in the style sheet will take precedence over
  1618. // the fill attribute.
  1619. if (series.colorAttribs && styledMode) {
  1620. // Heatmap is loaded
  1621. extend(css, series.colorAttribs(point));
  1622. }
  1623. if (!series[groupKey]) {
  1624. series[groupKey] = renderer.g(groupKey)
  1625. .attr({
  1626. // @todo Set the zIndex based upon the number of
  1627. // levels, instead of using 1000
  1628. zIndex: 1000 - levelDynamic
  1629. })
  1630. .add(series.group);
  1631. series[groupKey].survive = true;
  1632. }
  1633. }
  1634. // Draw the point
  1635. point.draw({
  1636. animatableAttribs: animate,
  1637. attribs: attr,
  1638. css: css,
  1639. group: series[groupKey],
  1640. renderer: renderer,
  1641. shadow: shadow,
  1642. shapeArgs: shapeArgs,
  1643. shapeType: 'rect'
  1644. });
  1645. // If setRootNode is allowed, set a point cursor on clickables &
  1646. // add drillId to point
  1647. if (allowTraversingTree && point.graphic) {
  1648. point.drillId = options.interactByLeaf ?
  1649. series.drillToByLeaf(point) :
  1650. series.drillToByGroup(point);
  1651. }
  1652. });
  1653. },
  1654. // Add drilling on the suitable points
  1655. onClickDrillToNode: function (event) {
  1656. var series = this,
  1657. point = event.point,
  1658. drillId = point && point.drillId;
  1659. // If a drill id is returned, add click event and cursor.
  1660. if (isString(drillId) &&
  1661. (series.isDrillAllowed ? series.isDrillAllowed(drillId) : true)) {
  1662. point.setState(''); // Remove hover
  1663. series.setRootNode(drillId, true, { trigger: 'click' });
  1664. }
  1665. },
  1666. /**
  1667. * Finds the drill id for a parent node. Returns false if point should
  1668. * not have a click event.
  1669. *
  1670. * @private
  1671. * @function Highcharts.Series#drillToByGroup
  1672. *
  1673. * @param {Highcharts.Point} point
  1674. *
  1675. * @return {boolean|string}
  1676. * Drill to id or false when point should not have a click
  1677. * event.
  1678. */
  1679. drillToByGroup: function (point) {
  1680. var series = this,
  1681. drillId = false;
  1682. if ((point.node.level - series.nodeMap[series.rootNode].level) ===
  1683. 1 &&
  1684. !point.node.isLeaf) {
  1685. drillId = point.id;
  1686. }
  1687. return drillId;
  1688. },
  1689. /**
  1690. * Finds the drill id for a leaf node. Returns false if point should not
  1691. * have a click event
  1692. *
  1693. * @private
  1694. * @function Highcharts.Series#drillToByLeaf
  1695. *
  1696. * @param {Highcharts.Point} point
  1697. *
  1698. * @return {boolean|string}
  1699. * Drill to id or false when point should not have a click
  1700. * event.
  1701. */
  1702. drillToByLeaf: function (point) {
  1703. var series = this,
  1704. drillId = false,
  1705. nodeParent;
  1706. if ((point.node.parent !== series.rootNode) &&
  1707. point.node.isLeaf) {
  1708. nodeParent = point.node;
  1709. while (!drillId) {
  1710. nodeParent = series.nodeMap[nodeParent.parent];
  1711. if (nodeParent.parent === series.rootNode) {
  1712. drillId = nodeParent.id;
  1713. }
  1714. }
  1715. }
  1716. return drillId;
  1717. },
  1718. drillUp: function () {
  1719. var series = this,
  1720. node = series.nodeMap[series.rootNode];
  1721. if (node && isString(node.parent)) {
  1722. series.setRootNode(node.parent, true, { trigger: 'traverseUpButton' });
  1723. }
  1724. },
  1725. // TODO remove this function at a suitable version.
  1726. drillToNode: function (id, redraw) {
  1727. error(32, false, void 0, { 'treemap.drillToNode': 'use treemap.setRootNode' });
  1728. this.setRootNode(id, redraw);
  1729. },
  1730. /**
  1731. * Sets a new root node for the series.
  1732. *
  1733. * @private
  1734. * @function Highcharts.Series#setRootNode
  1735. *
  1736. * @param {string} id The id of the new root node.
  1737. * @param {boolean} [redraw=true] Wether to redraw the chart or not.
  1738. * @param {object} [eventArguments] Arguments to be accessed in
  1739. * event handler.
  1740. * @param {string} [eventArguments.newRootId] Id of the new root.
  1741. * @param {string} [eventArguments.previousRootId] Id of the previous
  1742. * root.
  1743. * @param {boolean} [eventArguments.redraw] Wether to redraw the
  1744. * chart after.
  1745. * @param {object} [eventArguments.series] The series to update the root
  1746. * of.
  1747. * @param {string} [eventArguments.trigger] The action which
  1748. * triggered the event. Undefined if the setRootNode is called
  1749. * directly.
  1750. * @return {void}
  1751. *
  1752. * @fires Highcharts.Series#event:setRootNode
  1753. */
  1754. setRootNode: function (id, redraw, eventArguments) {
  1755. var series = this,
  1756. eventArgs = extend({
  1757. newRootId: id,
  1758. previousRootId: series.rootNode,
  1759. redraw: pick(redraw,
  1760. true),
  1761. series: series
  1762. },
  1763. eventArguments);
  1764. /**
  1765. * The default functionality of the setRootNode event.
  1766. *
  1767. * @private
  1768. * @param {object} args The event arguments.
  1769. * @param {string} args.newRootId Id of the new root.
  1770. * @param {string} args.previousRootId Id of the previous root.
  1771. * @param {boolean} args.redraw Wether to redraw the chart after.
  1772. * @param {object} args.series The series to update the root of.
  1773. * @param {string} [args.trigger=undefined] The action which
  1774. * triggered the event. Undefined if the setRootNode is called
  1775. * directly.
  1776. * @return {void}
  1777. */
  1778. var defaultFn = function (args) {
  1779. var series = args.series;
  1780. // Store previous and new root ids on the series.
  1781. series.idPreviousRoot = args.previousRootId;
  1782. series.rootNode = args.newRootId;
  1783. // Redraw the chart
  1784. series.isDirty = true; // Force redraw
  1785. if (args.redraw) {
  1786. series.chart.redraw();
  1787. }
  1788. };
  1789. // Fire setRootNode event.
  1790. fireEvent(series, 'setRootNode', eventArgs, defaultFn);
  1791. },
  1792. /**
  1793. * Check if the drill up/down is allowed.
  1794. *
  1795. * @private
  1796. */
  1797. isDrillAllowed: function (targetNode) {
  1798. var tree = this.tree,
  1799. firstChild = tree.children[0];
  1800. // The sunburst series looks exactly the same on the level ''
  1801. // and level 1 if there’s only one element on level 1. Disable
  1802. // drilling up/down when it doesn't perform any visual
  1803. // difference (#13388).
  1804. return !(tree.children.length === 1 && ((this.rootNode === '' && targetNode === firstChild.id) ||
  1805. (this.rootNode === firstChild.id && targetNode === '')));
  1806. },
  1807. renderTraverseUpButton: function (rootId) {
  1808. var series = this,
  1809. nodeMap = series.nodeMap,
  1810. node = nodeMap[rootId],
  1811. name = node.name,
  1812. buttonOptions = series.options.traverseUpButton,
  1813. backText = pick(buttonOptions.text,
  1814. name, '< Back'),
  1815. attr,
  1816. states;
  1817. if (rootId === '' ||
  1818. (series.isDrillAllowed ?
  1819. !(isString(node.parent) && series.isDrillAllowed(node.parent)) : false)) {
  1820. if (series.drillUpButton) {
  1821. series.drillUpButton =
  1822. series.drillUpButton.destroy();
  1823. }
  1824. }
  1825. else if (!this.drillUpButton) {
  1826. attr = buttonOptions.theme;
  1827. states = attr && attr.states;
  1828. this.drillUpButton = this.chart.renderer
  1829. .button(backText, null, null, function () {
  1830. series.drillUp();
  1831. }, attr, states && states.hover, states && states.select)
  1832. .addClass('highcharts-drillup-button')
  1833. .attr({
  1834. align: buttonOptions.position.align,
  1835. zIndex: 7
  1836. })
  1837. .add()
  1838. .align(buttonOptions.position, false, buttonOptions.relativeTo || 'plotBox');
  1839. }
  1840. else {
  1841. this.drillUpButton.placed = false;
  1842. this.drillUpButton.attr({
  1843. text: backText
  1844. })
  1845. .align();
  1846. }
  1847. },
  1848. buildKDTree: noop,
  1849. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  1850. getExtremes: function () {
  1851. // Get the extremes from the value data
  1852. var _a = Series.prototype.getExtremes
  1853. .call(this,
  1854. this.colorValueData),
  1855. dataMin = _a.dataMin,
  1856. dataMax = _a.dataMax;
  1857. this.valueMin = dataMin;
  1858. this.valueMax = dataMax;
  1859. // Get the extremes from the y data
  1860. return Series.prototype.getExtremes.call(this);
  1861. },
  1862. getExtremesFromAll: true,
  1863. /**
  1864. * Workaround for `inactive` state. Since `series.opacity` option is
  1865. * already reserved, don't use that state at all by disabling
  1866. * `inactiveOtherPoints` and not inheriting states by points.
  1867. *
  1868. * @private
  1869. */
  1870. setState: function (state) {
  1871. this.options.inactiveOtherPoints = true;
  1872. Series.prototype.setState.call(this, state, false);
  1873. this.options.inactiveOtherPoints = false;
  1874. },
  1875. utils: {
  1876. recursive: recursive
  1877. }
  1878. /* eslint-enable no-invalid-this, valid-jsdoc */
  1879. }, {
  1880. draw: drawPoint,
  1881. setVisible: seriesTypes.pie.prototype.pointClass.prototype.setVisible,
  1882. /* eslint-disable no-invalid-this, valid-jsdoc */
  1883. getClassName: function () {
  1884. var className = Point.prototype.getClassName.call(this),
  1885. series = this.series,
  1886. options = series.options;
  1887. // Above the current level
  1888. if (this.node.level <= series.nodeMap[series.rootNode].level) {
  1889. className += ' highcharts-above-level';
  1890. }
  1891. else if (!this.node.isLeaf &&
  1892. !pick(options.interactByLeaf, !options.allowTraversingTree)) {
  1893. className += ' highcharts-internal-node-interactive';
  1894. }
  1895. else if (!this.node.isLeaf) {
  1896. className += ' highcharts-internal-node';
  1897. }
  1898. return className;
  1899. },
  1900. /**
  1901. * A tree point is valid if it has han id too, assume it may be a parent
  1902. * item.
  1903. *
  1904. * @private
  1905. * @function Highcharts.Point#isValid
  1906. */
  1907. isValid: function () {
  1908. return this.id || isNumber(this.value);
  1909. },
  1910. setState: function (state) {
  1911. Point.prototype.setState.call(this, state);
  1912. // Graphic does not exist when point is not visible.
  1913. if (this.graphic) {
  1914. this.graphic.attr({
  1915. zIndex: state === 'hover' ? 1 : 0
  1916. });
  1917. }
  1918. },
  1919. shouldDraw: function () {
  1920. var point = this;
  1921. return isNumber(point.plotY) && point.y !== null;
  1922. }
  1923. });
  1924. addEvent(H.Series, 'afterBindAxes', function () {
  1925. var series = this,
  1926. xAxis = series.xAxis,
  1927. yAxis = series.yAxis,
  1928. treeAxis;
  1929. if (xAxis && yAxis) {
  1930. if (series.is('treemap')) {
  1931. treeAxis = {
  1932. endOnTick: false,
  1933. gridLineWidth: 0,
  1934. lineWidth: 0,
  1935. min: 0,
  1936. dataMin: 0,
  1937. minPadding: 0,
  1938. max: AXIS_MAX,
  1939. dataMax: AXIS_MAX,
  1940. maxPadding: 0,
  1941. startOnTick: false,
  1942. title: null,
  1943. tickPositions: []
  1944. };
  1945. extend(yAxis.options, treeAxis);
  1946. extend(xAxis.options, treeAxis);
  1947. treemapAxisDefaultValues = true;
  1948. }
  1949. else if (treemapAxisDefaultValues) {
  1950. yAxis.setOptions(yAxis.userOptions);
  1951. xAxis.setOptions(xAxis.userOptions);
  1952. treemapAxisDefaultValues = false;
  1953. }
  1954. }
  1955. });
  1956. /* eslint-enable no-invalid-this, valid-jsdoc */
  1957. /**
  1958. * A `treemap` series. If the [type](#series.treemap.type) option is
  1959. * not specified, it is inherited from [chart.type](#chart.type).
  1960. *
  1961. * @extends series,plotOptions.treemap
  1962. * @excluding dataParser, dataURL, stack, dataSorting
  1963. * @product highcharts
  1964. * @requires modules/treemap
  1965. * @apioption series.treemap
  1966. */
  1967. /**
  1968. * An array of data points for the series. For the `treemap` series
  1969. * type, points can be given in the following ways:
  1970. *
  1971. * 1. An array of numerical values. In this case, the numerical values will be
  1972. * interpreted as `value` options. Example:
  1973. * ```js
  1974. * data: [0, 5, 3, 5]
  1975. * ```
  1976. *
  1977. * 2. An array of objects with named values. The following snippet shows only a
  1978. * few settings, see the complete options set below. If the total number of
  1979. * data points exceeds the series'
  1980. * [turboThreshold](#series.treemap.turboThreshold),
  1981. * this option is not available.
  1982. * ```js
  1983. * data: [{
  1984. * value: 9,
  1985. * name: "Point2",
  1986. * color: "#00FF00"
  1987. * }, {
  1988. * value: 6,
  1989. * name: "Point1",
  1990. * color: "#FF00FF"
  1991. * }]
  1992. * ```
  1993. *
  1994. * @sample {highcharts} highcharts/chart/reflow-true/
  1995. * Numerical values
  1996. * @sample {highcharts} highcharts/series/data-array-of-objects/
  1997. * Config objects
  1998. *
  1999. * @type {Array<number|null|*>}
  2000. * @extends series.heatmap.data
  2001. * @excluding x, y
  2002. * @product highcharts
  2003. * @apioption series.treemap.data
  2004. */
  2005. /**
  2006. * The value of the point, resulting in a relative area of the point
  2007. * in the treemap.
  2008. *
  2009. * @type {number|null}
  2010. * @product highcharts
  2011. * @apioption series.treemap.data.value
  2012. */
  2013. /**
  2014. * Serves a purpose only if a `colorAxis` object is defined in the chart
  2015. * options. This value will decide which color the point gets from the
  2016. * scale of the colorAxis.
  2017. *
  2018. * @type {number}
  2019. * @since 4.1.0
  2020. * @product highcharts
  2021. * @apioption series.treemap.data.colorValue
  2022. */
  2023. /**
  2024. * Only for treemap. Use this option to build a tree structure. The
  2025. * value should be the id of the point which is the parent. If no points
  2026. * has a matching id, or this option is undefined, then the parent will
  2027. * be set to the root.
  2028. *
  2029. * @sample {highcharts} highcharts/point/parent/
  2030. * Point parent
  2031. * @sample {highcharts} highcharts/demo/treemap-with-levels/
  2032. * Example where parent id is not matching
  2033. *
  2034. * @type {string}
  2035. * @since 4.1.0
  2036. * @product highcharts
  2037. * @apioption series.treemap.data.parent
  2038. */
  2039. ''; // adds doclets above to transpiled file
  2040. });
  2041. _registerModule(_modules, 'masters/modules/treemap.src.js', [], function () {
  2042. });
  2043. }));