treemap.src.js 81 KB

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