sunburst.src.js 134 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218
  1. /**
  2. * @license Highcharts JS v8.2.2 (2020-10-22)
  3. *
  4. * (c) 2016-2019 Highsoft AS
  5. * Authors: Jon Arild Nygard
  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/sunburst', ['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/DrawPoint.js', [], function () {
  31. /* *
  32. *
  33. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  34. *
  35. * */
  36. var isFn = function (x) {
  37. return typeof x === 'function';
  38. };
  39. /* eslint-disable no-invalid-this, valid-jsdoc */
  40. /**
  41. * Handles the drawing of a component.
  42. * Can be used for any type of component that reserves the graphic property, and
  43. * provides a shouldDraw on its context.
  44. *
  45. * @private
  46. * @function draw
  47. * @param {DrawPointParams} params
  48. * Parameters.
  49. *
  50. * @todo add type checking.
  51. * @todo export this function to enable usage
  52. */
  53. var draw = function draw(params) {
  54. var _a;
  55. var component = this,
  56. graphic = component.graphic,
  57. animatableAttribs = params.animatableAttribs,
  58. onComplete = params.onComplete,
  59. css = params.css,
  60. renderer = params.renderer,
  61. animation = (_a = component.series) === null || _a === void 0 ? void 0 : _a.options.animation;
  62. if (component.shouldDraw()) {
  63. if (!graphic) {
  64. component.graphic = graphic =
  65. renderer[params.shapeType](params.shapeArgs)
  66. .add(params.group);
  67. }
  68. graphic
  69. .css(css)
  70. .attr(params.attribs)
  71. .animate(animatableAttribs, params.isNew ? false : animation, onComplete);
  72. }
  73. else if (graphic) {
  74. var destroy = function () {
  75. component.graphic = graphic = graphic.destroy();
  76. if (isFn(onComplete)) {
  77. onComplete();
  78. }
  79. };
  80. // animate only runs complete callback if something was animated.
  81. if (Object.keys(animatableAttribs).length) {
  82. graphic.animate(animatableAttribs, void 0, function () {
  83. destroy();
  84. });
  85. }
  86. else {
  87. destroy();
  88. }
  89. }
  90. };
  91. /**
  92. * An extended version of draw customized for points.
  93. * It calls additional methods that is expected when rendering a point.
  94. * @private
  95. * @param {Highcharts.Dictionary<any>} params Parameters
  96. */
  97. var drawPoint = function drawPoint(params) {
  98. var point = this,
  99. attribs = params.attribs = params.attribs || {};
  100. // Assigning class in dot notation does go well in IE8
  101. // eslint-disable-next-line dot-notation
  102. attribs['class'] = point.getClassName();
  103. // Call draw to render component
  104. draw.call(point, params);
  105. };
  106. var drawPointModule = {
  107. draw: draw,
  108. drawPoint: drawPoint,
  109. isFn: isFn
  110. };
  111. return drawPointModule;
  112. });
  113. _registerModule(_modules, 'Mixins/TreeSeries.js', [_modules['Core/Color/Color.js'], _modules['Core/Utilities.js']], function (Color, U) {
  114. /* *
  115. *
  116. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  117. *
  118. * */
  119. var extend = U.extend,
  120. isArray = U.isArray,
  121. isNumber = U.isNumber,
  122. isObject = U.isObject,
  123. merge = U.merge,
  124. pick = U.pick;
  125. var isBoolean = function (x) {
  126. return typeof x === 'boolean';
  127. }, isFn = function (x) {
  128. return typeof x === 'function';
  129. };
  130. /* eslint-disable valid-jsdoc */
  131. /**
  132. * @todo Combine buildTree and buildNode with setTreeValues
  133. * @todo Remove logic from Treemap and make it utilize this mixin.
  134. * @private
  135. */
  136. var setTreeValues = function setTreeValues(tree,
  137. options) {
  138. var before = options.before,
  139. idRoot = options.idRoot,
  140. mapIdToNode = options.mapIdToNode,
  141. nodeRoot = mapIdToNode[idRoot],
  142. levelIsConstant = (isBoolean(options.levelIsConstant) ?
  143. options.levelIsConstant :
  144. true),
  145. points = options.points,
  146. point = points[tree.i],
  147. optionsPoint = point && point.options || {},
  148. childrenTotal = 0,
  149. children = [],
  150. value;
  151. extend(tree, {
  152. levelDynamic: tree.level - (levelIsConstant ? 0 : nodeRoot.level),
  153. name: pick(point && point.name, ''),
  154. visible: (idRoot === tree.id ||
  155. (isBoolean(options.visible) ? options.visible : false))
  156. });
  157. if (isFn(before)) {
  158. tree = before(tree, options);
  159. }
  160. // First give the children some values
  161. tree.children.forEach(function (child, i) {
  162. var newOptions = extend({},
  163. options);
  164. extend(newOptions, {
  165. index: i,
  166. siblings: tree.children.length,
  167. visible: tree.visible
  168. });
  169. child = setTreeValues(child, newOptions);
  170. children.push(child);
  171. if (child.visible) {
  172. childrenTotal += child.val;
  173. }
  174. });
  175. tree.visible = childrenTotal > 0 || tree.visible;
  176. // Set the values
  177. value = pick(optionsPoint.value, childrenTotal);
  178. extend(tree, {
  179. children: children,
  180. childrenTotal: childrenTotal,
  181. isLeaf: tree.visible && !childrenTotal,
  182. val: value
  183. });
  184. return tree;
  185. };
  186. /**
  187. * @private
  188. */
  189. var getColor = function getColor(node,
  190. options) {
  191. var index = options.index,
  192. mapOptionsToLevel = options.mapOptionsToLevel,
  193. parentColor = options.parentColor,
  194. parentColorIndex = options.parentColorIndex,
  195. series = options.series,
  196. colors = options.colors,
  197. siblings = options.siblings,
  198. points = series.points,
  199. getColorByPoint,
  200. chartOptionsChart = series.chart.options.chart,
  201. point,
  202. level,
  203. colorByPoint,
  204. colorIndexByPoint,
  205. color,
  206. colorIndex;
  207. /**
  208. * @private
  209. */
  210. function variation(color) {
  211. var colorVariation = level && level.colorVariation;
  212. if (colorVariation) {
  213. if (colorVariation.key === 'brightness') {
  214. return Color.parse(color).brighten(colorVariation.to * (index / siblings)).get();
  215. }
  216. }
  217. return color;
  218. }
  219. if (node) {
  220. point = points[node.i];
  221. level = mapOptionsToLevel[node.level] || {};
  222. getColorByPoint = point && level.colorByPoint;
  223. if (getColorByPoint) {
  224. colorIndexByPoint = point.index % (colors ?
  225. colors.length :
  226. chartOptionsChart.colorCount);
  227. colorByPoint = colors && colors[colorIndexByPoint];
  228. }
  229. // Select either point color, level color or inherited color.
  230. if (!series.chart.styledMode) {
  231. color = pick(point && point.options.color, level && level.color, colorByPoint, parentColor && variation(parentColor), series.color);
  232. }
  233. colorIndex = pick(point && point.options.colorIndex, level && level.colorIndex, colorIndexByPoint, parentColorIndex, options.colorIndex);
  234. }
  235. return {
  236. color: color,
  237. colorIndex: colorIndex
  238. };
  239. };
  240. /**
  241. * Creates a map from level number to its given options.
  242. *
  243. * @private
  244. * @function getLevelOptions
  245. * @param {object} params
  246. * Object containing parameters.
  247. * - `defaults` Object containing default options. The default options
  248. * are merged with the userOptions to get the final options for a
  249. * specific level.
  250. * - `from` The lowest level number.
  251. * - `levels` User options from series.levels.
  252. * - `to` The highest level number.
  253. * @return {Highcharts.Dictionary<object>|null}
  254. * Returns a map from level number to its given options.
  255. */
  256. var getLevelOptions = function getLevelOptions(params) {
  257. var result = null,
  258. defaults,
  259. converted,
  260. i,
  261. from,
  262. to,
  263. levels;
  264. if (isObject(params)) {
  265. result = {};
  266. from = isNumber(params.from) ? params.from : 1;
  267. levels = params.levels;
  268. converted = {};
  269. defaults = isObject(params.defaults) ? params.defaults : {};
  270. if (isArray(levels)) {
  271. converted = levels.reduce(function (obj, item) {
  272. var level,
  273. levelIsConstant,
  274. options;
  275. if (isObject(item) && isNumber(item.level)) {
  276. options = merge({}, item);
  277. levelIsConstant = (isBoolean(options.levelIsConstant) ?
  278. options.levelIsConstant :
  279. defaults.levelIsConstant);
  280. // Delete redundant properties.
  281. delete options.levelIsConstant;
  282. delete options.level;
  283. // Calculate which level these options apply to.
  284. level = item.level + (levelIsConstant ? 0 : from - 1);
  285. if (isObject(obj[level])) {
  286. extend(obj[level], options);
  287. }
  288. else {
  289. obj[level] = options;
  290. }
  291. }
  292. return obj;
  293. }, {});
  294. }
  295. to = isNumber(params.to) ? params.to : 1;
  296. for (i = 0; i <= to; i++) {
  297. result[i] = merge({}, defaults, isObject(converted[i]) ? converted[i] : {});
  298. }
  299. }
  300. return result;
  301. };
  302. /**
  303. * Update the rootId property on the series. Also makes sure that it is
  304. * accessible to exporting.
  305. *
  306. * @private
  307. * @function updateRootId
  308. *
  309. * @param {object} series
  310. * The series to operate on.
  311. *
  312. * @return {string}
  313. * Returns the resulting rootId after update.
  314. */
  315. var updateRootId = function (series) {
  316. var rootId,
  317. options;
  318. if (isObject(series)) {
  319. // Get the series options.
  320. options = isObject(series.options) ? series.options : {};
  321. // Calculate the rootId.
  322. rootId = pick(series.rootNode, options.rootId, '');
  323. // Set rootId on series.userOptions to pick it up in exporting.
  324. if (isObject(series.userOptions)) {
  325. series.userOptions.rootId = rootId;
  326. }
  327. // Set rootId on series to pick it up on next update.
  328. series.rootNode = rootId;
  329. }
  330. return rootId;
  331. };
  332. var result = {
  333. getColor: getColor,
  334. getLevelOptions: getLevelOptions,
  335. setTreeValues: setTreeValues,
  336. updateRootId: updateRootId
  337. };
  338. return result;
  339. });
  340. _registerModule(_modules, 'Mixins/ColorMapSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, Point, U) {
  341. /* *
  342. *
  343. * (c) 2010-2020 Torstein Honsi
  344. *
  345. * License: www.highcharts.com/license
  346. *
  347. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  348. *
  349. * */
  350. var defined = U.defined;
  351. var noop = H.noop,
  352. seriesTypes = H.seriesTypes;
  353. /**
  354. * Mixin for maps and heatmaps
  355. *
  356. * @private
  357. * @mixin Highcharts.colorMapPointMixin
  358. */
  359. var colorMapPointMixin = {
  360. dataLabelOnNull: true,
  361. /* eslint-disable valid-jsdoc */
  362. /**
  363. * Color points have a value option that determines whether or not it is
  364. * a null point
  365. * @private
  366. * @function Highcharts.colorMapPointMixin.isValid
  367. * @return {boolean}
  368. */
  369. isValid: function () {
  370. // undefined is allowed
  371. return (this.value !== null &&
  372. this.value !== Infinity &&
  373. this.value !== -Infinity);
  374. },
  375. /**
  376. * @private
  377. * @function Highcharts.colorMapPointMixin.setState
  378. * @param {string} state
  379. * @return {void}
  380. */
  381. setState: function (state) {
  382. Point.prototype.setState.call(this, state);
  383. if (this.graphic) {
  384. this.graphic.attr({
  385. zIndex: state === 'hover' ? 1 : 0
  386. });
  387. }
  388. }
  389. /* eslint-enable valid-jsdoc */
  390. };
  391. /**
  392. * @private
  393. * @mixin Highcharts.colorMapSeriesMixin
  394. */
  395. var colorMapSeriesMixin = {
  396. pointArrayMap: ['value'],
  397. axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
  398. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  399. getSymbol: noop,
  400. parallelArrays: ['x', 'y', 'value'],
  401. colorKey: 'value',
  402. pointAttribs: seriesTypes.column.prototype.pointAttribs,
  403. /* eslint-disable valid-jsdoc */
  404. /**
  405. * Get the color attibutes to apply on the graphic
  406. * @private
  407. * @function Highcharts.colorMapSeriesMixin.colorAttribs
  408. * @param {Highcharts.Point} point
  409. * @return {Highcharts.SVGAttributes}
  410. */
  411. colorAttribs: function (point) {
  412. var ret = {};
  413. if (defined(point.color)) {
  414. ret[this.colorProp || 'fill'] = point.color;
  415. }
  416. return ret;
  417. }
  418. };
  419. var exports = {
  420. colorMapPointMixin: colorMapPointMixin,
  421. colorMapSeriesMixin: colorMapSeriesMixin
  422. };
  423. return exports;
  424. });
  425. _registerModule(_modules, 'Series/TreemapSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Color/Color.js'], _modules['Mixins/ColorMapSeries.js'], _modules['Mixins/DrawPoint.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/Point.js'], _modules['Mixins/TreeSeries.js'], _modules['Core/Utilities.js']], function (BaseSeries, Color, ColorMapMixin, DrawPointMixin, H, LegendSymbolMixin, Point, TreeSeriesMixin, U) {
  426. /* *
  427. *
  428. * (c) 2014-2020 Highsoft AS
  429. *
  430. * Authors: Jon Arild Nygard / Oystein Moseng
  431. *
  432. * License: www.highcharts.com/license
  433. *
  434. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  435. *
  436. * */
  437. var seriesTypes = BaseSeries.seriesTypes;
  438. var color = Color.parse;
  439. var colorMapSeriesMixin = ColorMapMixin.colorMapSeriesMixin;
  440. var drawPoint = DrawPointMixin.drawPoint;
  441. var noop = H.noop;
  442. var getColor = TreeSeriesMixin.getColor,
  443. getLevelOptions = TreeSeriesMixin.getLevelOptions,
  444. updateRootId = TreeSeriesMixin.updateRootId;
  445. var addEvent = U.addEvent,
  446. correctFloat = U.correctFloat,
  447. defined = U.defined,
  448. error = U.error,
  449. extend = U.extend,
  450. fireEvent = U.fireEvent,
  451. isArray = U.isArray,
  452. isNumber = U.isNumber,
  453. isObject = U.isObject,
  454. isString = U.isString,
  455. merge = U.merge,
  456. objectEach = U.objectEach,
  457. pick = U.pick,
  458. stableSort = U.stableSort;
  459. /* eslint-disable no-invalid-this */
  460. var AXIS_MAX = 100;
  461. // @todo Similar to eachObject, this function is likely redundant
  462. var isBoolean = function (x) {
  463. return typeof x === 'boolean';
  464. }, Series = H.Series,
  465. // @todo Similar to recursive, this function is likely redundant
  466. eachObject = function (list, func, context) {
  467. context = context || this;
  468. objectEach(list, function (val, key) {
  469. func.call(context, val, key, list);
  470. });
  471. },
  472. // @todo find correct name for this function.
  473. // @todo Similar to reduce, this function is likely redundant
  474. recursive = function (item, func, context) {
  475. var next;
  476. context = context || this;
  477. next = func.call(context, item);
  478. if (next !== false) {
  479. recursive(next, func, context);
  480. }
  481. }, treemapAxisDefaultValues = false;
  482. /* eslint-enable no-invalid-this */
  483. /**
  484. * @private
  485. * @class
  486. * @name Highcharts.seriesTypes.treemap
  487. *
  488. * @augments Highcharts.Series
  489. */
  490. BaseSeries.seriesType('treemap', 'scatter'
  491. /**
  492. * A treemap displays hierarchical data using nested rectangles. The data
  493. * can be laid out in varying ways depending on options.
  494. *
  495. * @sample highcharts/demo/treemap-large-dataset/
  496. * Treemap
  497. *
  498. * @extends plotOptions.scatter
  499. * @excluding dragDrop, marker, jitter, dataSorting
  500. * @product highcharts
  501. * @requires modules/treemap
  502. * @optionparent plotOptions.treemap
  503. */
  504. , {
  505. /**
  506. * When enabled the user can click on a point which is a parent and
  507. * zoom in on its children. Deprecated and replaced by
  508. * [allowTraversingTree](#plotOptions.treemap.allowTraversingTree).
  509. *
  510. * @sample {highcharts} highcharts/plotoptions/treemap-allowdrilltonode/
  511. * Enabled
  512. *
  513. * @deprecated
  514. * @type {boolean}
  515. * @default false
  516. * @since 4.1.0
  517. * @product highcharts
  518. * @apioption plotOptions.treemap.allowDrillToNode
  519. */
  520. /**
  521. * When enabled the user can click on a point which is a parent and
  522. * zoom in on its children.
  523. *
  524. * @sample {highcharts} highcharts/plotoptions/treemap-allowtraversingtree/
  525. * Enabled
  526. *
  527. * @since 7.0.3
  528. * @product highcharts
  529. */
  530. allowTraversingTree: false,
  531. animationLimit: 250,
  532. /**
  533. * When the series contains less points than the crop threshold, all
  534. * points are drawn, event if the points fall outside the visible plot
  535. * area at the current zoom. The advantage of drawing all points
  536. * (including markers and columns), is that animation is performed on
  537. * updates. On the other hand, when the series contains more points than
  538. * the crop threshold, the series data is cropped to only contain points
  539. * that fall within the plot area. The advantage of cropping away
  540. * invisible points is to increase performance on large series.
  541. *
  542. * @type {number}
  543. * @default 300
  544. * @since 4.1.0
  545. * @product highcharts
  546. * @apioption plotOptions.treemap.cropThreshold
  547. */
  548. /**
  549. * Fires on a request for change of root node for the tree, before the
  550. * update is made. An event object is passed to the function, containing
  551. * additional properties `newRootId`, `previousRootId`, `redraw` and
  552. * `trigger`.
  553. *
  554. * @type {function}
  555. * @default undefined
  556. * @sample {highcharts} highcharts/plotoptions/treemap-events-setrootnode/
  557. * Alert update information on setRootNode event.
  558. * @since 7.0.3
  559. * @product highcharts
  560. * @apioption plotOptions.treemap.events.setRootNode
  561. */
  562. /**
  563. * This option decides if the user can interact with the parent nodes
  564. * or just the leaf nodes. When this option is undefined, it will be
  565. * true by default. However when allowTraversingTree is true, then it
  566. * will be false by default.
  567. *
  568. * @sample {highcharts} highcharts/plotoptions/treemap-interactbyleaf-false/
  569. * False
  570. * @sample {highcharts} highcharts/plotoptions/treemap-interactbyleaf-true-and-allowtraversingtree/
  571. * InteractByLeaf and allowTraversingTree is true
  572. *
  573. * @type {boolean}
  574. * @since 4.1.2
  575. * @product highcharts
  576. * @apioption plotOptions.treemap.interactByLeaf
  577. */
  578. /**
  579. * The sort index of the point inside the treemap level.
  580. *
  581. * @sample {highcharts} highcharts/plotoptions/treemap-sortindex/
  582. * Sort by years
  583. *
  584. * @type {number}
  585. * @since 4.1.10
  586. * @product highcharts
  587. * @apioption plotOptions.treemap.sortIndex
  588. */
  589. /**
  590. * A series specific or series type specific color set to apply instead
  591. * of the global [colors](#colors) when
  592. * [colorByPoint](#plotOptions.treemap.colorByPoint) is true.
  593. *
  594. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  595. * @since 3.0
  596. * @product highcharts
  597. * @apioption plotOptions.treemap.colors
  598. */
  599. /**
  600. * Whether to display this series type or specific series item in the
  601. * legend.
  602. */
  603. showInLegend: false,
  604. /**
  605. * @ignore-option
  606. */
  607. marker: void 0,
  608. /**
  609. * When using automatic point colors pulled from the `options.colors`
  610. * collection, this option determines whether the chart should receive
  611. * one color per series or one color per point.
  612. *
  613. * @see [series colors](#plotOptions.treemap.colors)
  614. *
  615. * @since 2.0
  616. * @product highcharts
  617. * @apioption plotOptions.treemap.colorByPoint
  618. */
  619. colorByPoint: false,
  620. /**
  621. * @since 4.1.0
  622. */
  623. dataLabels: {
  624. defer: false,
  625. enabled: true,
  626. formatter: function () {
  627. var point = this && this.point ?
  628. this.point :
  629. {},
  630. name = isString(point.name) ? point.name : '';
  631. return name;
  632. },
  633. inside: true,
  634. verticalAlign: 'middle'
  635. },
  636. tooltip: {
  637. headerFormat: '',
  638. pointFormat: '<b>{point.name}</b>: {point.value}<br/>'
  639. },
  640. /**
  641. * Whether to ignore hidden points when the layout algorithm runs.
  642. * If `false`, hidden points will leave open spaces.
  643. *
  644. * @since 5.0.8
  645. */
  646. ignoreHiddenPoint: true,
  647. /**
  648. * This option decides which algorithm is used for setting position
  649. * and dimensions of the points.
  650. *
  651. * @see [How to write your own algorithm](https://www.highcharts.com/docs/chart-and-series-types/treemap)
  652. *
  653. * @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-sliceanddice/
  654. * SliceAndDice by default
  655. * @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-stripes/
  656. * Stripes
  657. * @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-squarified/
  658. * Squarified
  659. * @sample {highcharts} highcharts/plotoptions/treemap-layoutalgorithm-strip/
  660. * Strip
  661. *
  662. * @since 4.1.0
  663. * @validvalue ["sliceAndDice", "stripes", "squarified", "strip"]
  664. */
  665. layoutAlgorithm: 'sliceAndDice',
  666. /**
  667. * Defines which direction the layout algorithm will start drawing.
  668. *
  669. * @since 4.1.0
  670. * @validvalue ["vertical", "horizontal"]
  671. */
  672. layoutStartingDirection: 'vertical',
  673. /**
  674. * Enabling this option will make the treemap alternate the drawing
  675. * direction between vertical and horizontal. The next levels starting
  676. * direction will always be the opposite of the previous.
  677. *
  678. * @sample {highcharts} highcharts/plotoptions/treemap-alternatestartingdirection-true/
  679. * Enabled
  680. *
  681. * @since 4.1.0
  682. */
  683. alternateStartingDirection: false,
  684. /**
  685. * Used together with the levels and allowTraversingTree options. When
  686. * set to false the first level visible to be level one, which is
  687. * dynamic when traversing the tree. Otherwise the level will be the
  688. * same as the tree structure.
  689. *
  690. * @since 4.1.0
  691. */
  692. levelIsConstant: true,
  693. /**
  694. * Options for the button appearing when drilling down in a treemap.
  695. * Deprecated and replaced by
  696. * [traverseUpButton](#plotOptions.treemap.traverseUpButton).
  697. *
  698. * @deprecated
  699. */
  700. drillUpButton: {
  701. /**
  702. * The position of the button.
  703. *
  704. * @deprecated
  705. */
  706. position: {
  707. /**
  708. * Vertical alignment of the button.
  709. *
  710. * @deprecated
  711. * @type {Highcharts.VerticalAlignValue}
  712. * @default top
  713. * @product highcharts
  714. * @apioption plotOptions.treemap.drillUpButton.position.verticalAlign
  715. */
  716. /**
  717. * Horizontal alignment of the button.
  718. *
  719. * @deprecated
  720. * @type {Highcharts.AlignValue}
  721. */
  722. align: 'right',
  723. /**
  724. * Horizontal offset of the button.
  725. *
  726. * @deprecated
  727. */
  728. x: -10,
  729. /**
  730. * Vertical offset of the button.
  731. *
  732. * @deprecated
  733. */
  734. y: 10
  735. }
  736. },
  737. /**
  738. * Options for the button appearing when traversing down in a treemap.
  739. */
  740. traverseUpButton: {
  741. /**
  742. * The position of the button.
  743. */
  744. position: {
  745. /**
  746. * Vertical alignment of the button.
  747. *
  748. * @type {Highcharts.VerticalAlignValue}
  749. * @default top
  750. * @product highcharts
  751. * @apioption plotOptions.treemap.traverseUpButton.position.verticalAlign
  752. */
  753. /**
  754. * Horizontal alignment of the button.
  755. *
  756. * @type {Highcharts.AlignValue}
  757. */
  758. align: 'right',
  759. /**
  760. * Horizontal offset of the button.
  761. */
  762. x: -10,
  763. /**
  764. * Vertical offset of the button.
  765. */
  766. y: 10
  767. }
  768. },
  769. /**
  770. * Set options on specific levels. Takes precedence over series options,
  771. * but not point options.
  772. *
  773. * @sample {highcharts} highcharts/plotoptions/treemap-levels/
  774. * Styling dataLabels and borders
  775. * @sample {highcharts} highcharts/demo/treemap-with-levels/
  776. * Different layoutAlgorithm
  777. *
  778. * @type {Array<*>}
  779. * @since 4.1.0
  780. * @product highcharts
  781. * @apioption plotOptions.treemap.levels
  782. */
  783. /**
  784. * Can set a `borderColor` on all points which lies on the same level.
  785. *
  786. * @type {Highcharts.ColorString}
  787. * @since 4.1.0
  788. * @product highcharts
  789. * @apioption plotOptions.treemap.levels.borderColor
  790. */
  791. /**
  792. * Set the dash style of the border of all the point which lies on the
  793. * level. See
  794. * [plotOptions.scatter.dashStyle](#plotoptions.scatter.dashstyle)
  795. * for possible options.
  796. *
  797. * @type {Highcharts.DashStyleValue}
  798. * @since 4.1.0
  799. * @product highcharts
  800. * @apioption plotOptions.treemap.levels.borderDashStyle
  801. */
  802. /**
  803. * Can set the borderWidth on all points which lies on the same level.
  804. *
  805. * @type {number}
  806. * @since 4.1.0
  807. * @product highcharts
  808. * @apioption plotOptions.treemap.levels.borderWidth
  809. */
  810. /**
  811. * Can set a color on all points which lies on the same level.
  812. *
  813. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  814. * @since 4.1.0
  815. * @product highcharts
  816. * @apioption plotOptions.treemap.levels.color
  817. */
  818. /**
  819. * A configuration object to define how the color of a child varies from
  820. * the parent's color. The variation is distributed among the children
  821. * of node. For example when setting brightness, the brightness change
  822. * will range from the parent's original brightness on the first child,
  823. * to the amount set in the `to` setting on the last node. This allows a
  824. * gradient-like color scheme that sets children out from each other
  825. * while highlighting the grouping on treemaps and sectors on sunburst
  826. * charts.
  827. *
  828. * @sample highcharts/demo/sunburst/
  829. * Sunburst with color variation
  830. *
  831. * @since 6.0.0
  832. * @product highcharts
  833. * @apioption plotOptions.treemap.levels.colorVariation
  834. */
  835. /**
  836. * The key of a color variation. Currently supports `brightness` only.
  837. *
  838. * @type {string}
  839. * @since 6.0.0
  840. * @product highcharts
  841. * @validvalue ["brightness"]
  842. * @apioption plotOptions.treemap.levels.colorVariation.key
  843. */
  844. /**
  845. * The ending value of a color variation. The last sibling will receive
  846. * this value.
  847. *
  848. * @type {number}
  849. * @since 6.0.0
  850. * @product highcharts
  851. * @apioption plotOptions.treemap.levels.colorVariation.to
  852. */
  853. /**
  854. * Can set the options of dataLabels on each point which lies on the
  855. * level.
  856. * [plotOptions.treemap.dataLabels](#plotOptions.treemap.dataLabels) for
  857. * possible values.
  858. *
  859. * @extends plotOptions.treemap.dataLabels
  860. * @since 4.1.0
  861. * @product highcharts
  862. * @apioption plotOptions.treemap.levels.dataLabels
  863. */
  864. /**
  865. * Can set the layoutAlgorithm option on a specific level.
  866. *
  867. * @type {string}
  868. * @since 4.1.0
  869. * @product highcharts
  870. * @validvalue ["sliceAndDice", "stripes", "squarified", "strip"]
  871. * @apioption plotOptions.treemap.levels.layoutAlgorithm
  872. */
  873. /**
  874. * Can set the layoutStartingDirection option on a specific level.
  875. *
  876. * @type {string}
  877. * @since 4.1.0
  878. * @product highcharts
  879. * @validvalue ["vertical", "horizontal"]
  880. * @apioption plotOptions.treemap.levels.layoutStartingDirection
  881. */
  882. /**
  883. * Decides which level takes effect from the options set in the levels
  884. * object.
  885. *
  886. * @sample {highcharts} highcharts/plotoptions/treemap-levels/
  887. * Styling of both levels
  888. *
  889. * @type {number}
  890. * @since 4.1.0
  891. * @product highcharts
  892. * @apioption plotOptions.treemap.levels.level
  893. */
  894. // Presentational options
  895. /**
  896. * The color of the border surrounding each tree map item.
  897. *
  898. * @type {Highcharts.ColorString}
  899. */
  900. borderColor: '#e6e6e6',
  901. /**
  902. * The width of the border surrounding each tree map item.
  903. */
  904. borderWidth: 1,
  905. colorKey: 'colorValue',
  906. /**
  907. * The opacity of a point in treemap. When a point has children, the
  908. * visibility of the children is determined by the opacity.
  909. *
  910. * @since 4.2.4
  911. */
  912. opacity: 0.15,
  913. /**
  914. * A wrapper object for all the series options in specific states.
  915. *
  916. * @extends plotOptions.heatmap.states
  917. */
  918. states: {
  919. /**
  920. * Options for the hovered series
  921. *
  922. * @extends plotOptions.heatmap.states.hover
  923. * @excluding halo
  924. */
  925. hover: {
  926. /**
  927. * The border color for the hovered state.
  928. */
  929. borderColor: '#999999',
  930. /**
  931. * Brightness for the hovered point. Defaults to 0 if the
  932. * heatmap series is loaded first, otherwise 0.1.
  933. *
  934. * @type {number}
  935. * @default undefined
  936. */
  937. brightness: seriesTypes.heatmap ? 0 : 0.1,
  938. /**
  939. * @extends plotOptions.heatmap.states.hover.halo
  940. */
  941. halo: false,
  942. /**
  943. * The opacity of a point in treemap. When a point has children,
  944. * the visibility of the children is determined by the opacity.
  945. *
  946. * @since 4.2.4
  947. */
  948. opacity: 0.75,
  949. /**
  950. * The shadow option for hovered state.
  951. */
  952. shadow: false
  953. }
  954. }
  955. // Prototype members
  956. }, {
  957. pointArrayMap: ['value'],
  958. directTouch: true,
  959. optionalAxis: 'colorAxis',
  960. getSymbol: noop,
  961. parallelArrays: ['x', 'y', 'value', 'colorValue'],
  962. colorKey: 'colorValue',
  963. trackerGroups: ['group', 'dataLabelsGroup'],
  964. /* eslint-disable no-invalid-this, valid-jsdoc */
  965. /**
  966. * Creates an object map from parent id to childrens index.
  967. *
  968. * @private
  969. * @function Highcharts.Series#getListOfParents
  970. *
  971. * @param {Highcharts.SeriesTreemapDataOptions} [data]
  972. * List of points set in options.
  973. *
  974. * @param {Array<string>} [existingIds]
  975. * List of all point ids.
  976. *
  977. * @return {object}
  978. * Map from parent id to children index in data.
  979. */
  980. getListOfParents: function (data, existingIds) {
  981. var arr = isArray(data) ? data : [],
  982. ids = isArray(existingIds) ? existingIds : [],
  983. listOfParents = arr.reduce(function (prev,
  984. curr,
  985. i) {
  986. var parent = pick(curr.parent, '');
  987. if (typeof prev[parent] === 'undefined') {
  988. prev[parent] = [];
  989. }
  990. prev[parent].push(i);
  991. return prev;
  992. }, {
  993. '': [] // Root of tree
  994. });
  995. // If parent does not exist, hoist parent to root of tree.
  996. eachObject(listOfParents, function (children, parent, list) {
  997. if ((parent !== '') && (ids.indexOf(parent) === -1)) {
  998. children.forEach(function (child) {
  999. list[''].push(child);
  1000. });
  1001. delete list[parent];
  1002. }
  1003. });
  1004. return listOfParents;
  1005. },
  1006. // Creates a tree structured object from the series points
  1007. getTree: function () {
  1008. var series = this,
  1009. allIds = this.data.map(function (d) {
  1010. return d.id;
  1011. }), parentList = series.getListOfParents(this.data, allIds);
  1012. series.nodeMap = {};
  1013. return series.buildNode('', -1, 0, parentList);
  1014. },
  1015. // Define hasData function for non-cartesian series.
  1016. // Returns true if the series has points at all.
  1017. hasData: function () {
  1018. return !!this.processedXData.length; // != 0
  1019. },
  1020. init: function (chart, options) {
  1021. var series = this,
  1022. setOptionsEvent;
  1023. // If color series logic is loaded, add some properties
  1024. if (colorMapSeriesMixin) {
  1025. this.colorAttribs = colorMapSeriesMixin.colorAttribs;
  1026. }
  1027. setOptionsEvent = addEvent(series, 'setOptions', function (event) {
  1028. var options = event.userOptions;
  1029. if (defined(options.allowDrillToNode) &&
  1030. !defined(options.allowTraversingTree)) {
  1031. options.allowTraversingTree = options.allowDrillToNode;
  1032. delete options.allowDrillToNode;
  1033. }
  1034. if (defined(options.drillUpButton) &&
  1035. !defined(options.traverseUpButton)) {
  1036. options.traverseUpButton = options.drillUpButton;
  1037. delete options.drillUpButton;
  1038. }
  1039. });
  1040. Series.prototype.init.call(series, chart, options);
  1041. // Treemap's opacity is a different option from other series
  1042. delete series.opacity;
  1043. // Handle deprecated options.
  1044. series.eventsToUnbind.push(setOptionsEvent);
  1045. if (series.options.allowTraversingTree) {
  1046. series.eventsToUnbind.push(addEvent(series, 'click', series.onClickDrillToNode));
  1047. }
  1048. },
  1049. buildNode: function (id, i, level, list, parent) {
  1050. var series = this,
  1051. children = [],
  1052. point = series.points[i],
  1053. height = 0,
  1054. node,
  1055. child;
  1056. // Actions
  1057. ((list[id] || [])).forEach(function (i) {
  1058. child = series.buildNode(series.points[i].id, i, (level + 1), list, id);
  1059. height = Math.max(child.height + 1, height);
  1060. children.push(child);
  1061. });
  1062. node = {
  1063. id: id,
  1064. i: i,
  1065. children: children,
  1066. height: height,
  1067. level: level,
  1068. parent: parent,
  1069. visible: false // @todo move this to better location
  1070. };
  1071. series.nodeMap[node.id] = node;
  1072. if (point) {
  1073. point.node = node;
  1074. }
  1075. return node;
  1076. },
  1077. setTreeValues: function (tree) {
  1078. var series = this,
  1079. options = series.options,
  1080. idRoot = series.rootNode,
  1081. mapIdToNode = series.nodeMap,
  1082. nodeRoot = mapIdToNode[idRoot],
  1083. levelIsConstant = (isBoolean(options.levelIsConstant) ?
  1084. options.levelIsConstant :
  1085. true),
  1086. childrenTotal = 0,
  1087. children = [],
  1088. val,
  1089. point = series.points[tree.i];
  1090. // First give the children some values
  1091. tree.children.forEach(function (child) {
  1092. child = series.setTreeValues(child);
  1093. children.push(child);
  1094. if (!child.ignore) {
  1095. childrenTotal += child.val;
  1096. }
  1097. });
  1098. // Sort the children
  1099. stableSort(children, function (a, b) {
  1100. return (a.sortIndex || 0) - (b.sortIndex || 0);
  1101. });
  1102. // Set the values
  1103. val = pick(point && point.options.value, childrenTotal);
  1104. if (point) {
  1105. point.value = val;
  1106. }
  1107. extend(tree, {
  1108. children: children,
  1109. childrenTotal: childrenTotal,
  1110. // Ignore this node if point is not visible
  1111. ignore: !(pick(point && point.visible, true) && (val > 0)),
  1112. isLeaf: tree.visible && !childrenTotal,
  1113. levelDynamic: (tree.level - (levelIsConstant ? 0 : nodeRoot.level)),
  1114. name: pick(point && point.name, ''),
  1115. sortIndex: pick(point && point.sortIndex, -val),
  1116. val: val
  1117. });
  1118. return tree;
  1119. },
  1120. /**
  1121. * Recursive function which calculates the area for all children of a
  1122. * node.
  1123. *
  1124. * @private
  1125. * @function Highcharts.Series#calculateChildrenAreas
  1126. *
  1127. * @param {object} node
  1128. * The node which is parent to the children.
  1129. *
  1130. * @param {object} area
  1131. * The rectangular area of the parent.
  1132. */
  1133. calculateChildrenAreas: function (parent, area) {
  1134. var series = this,
  1135. options = series.options,
  1136. mapOptionsToLevel = series.mapOptionsToLevel,
  1137. level = mapOptionsToLevel[parent.level + 1],
  1138. algorithm = pick((series[(level && level.layoutAlgorithm)] &&
  1139. level.layoutAlgorithm),
  1140. options.layoutAlgorithm),
  1141. alternate = options.alternateStartingDirection,
  1142. childrenValues = [],
  1143. children;
  1144. // Collect all children which should be included
  1145. children = parent.children.filter(function (n) {
  1146. return !n.ignore;
  1147. });
  1148. if (level && level.layoutStartingDirection) {
  1149. area.direction = level.layoutStartingDirection === 'vertical' ?
  1150. 0 :
  1151. 1;
  1152. }
  1153. childrenValues = series[algorithm](area, children);
  1154. children.forEach(function (child, index) {
  1155. var values = childrenValues[index];
  1156. child.values = merge(values, {
  1157. val: child.childrenTotal,
  1158. direction: (alternate ? 1 - area.direction : area.direction)
  1159. });
  1160. child.pointValues = merge(values, {
  1161. x: (values.x / series.axisRatio),
  1162. // Flip y-values to avoid visual regression with csvCoord in
  1163. // Axis.translate at setPointValues. #12488
  1164. y: AXIS_MAX - values.y - values.height,
  1165. width: (values.width / series.axisRatio)
  1166. });
  1167. // If node has children, then call method recursively
  1168. if (child.children.length) {
  1169. series.calculateChildrenAreas(child, child.values);
  1170. }
  1171. });
  1172. },
  1173. setPointValues: function () {
  1174. var series = this;
  1175. var points = series.points,
  1176. xAxis = series.xAxis,
  1177. yAxis = series.yAxis;
  1178. var styledMode = series.chart.styledMode;
  1179. // Get the crisp correction in classic mode. For this to work in
  1180. // styled mode, we would need to first add the shape (without x,
  1181. // y, width and height), then read the rendered stroke width
  1182. // using point.graphic.strokeWidth(), then modify and apply the
  1183. // shapeArgs. This applies also to column series, but the
  1184. // downside is performance and code complexity.
  1185. var getCrispCorrection = function (point) { return (styledMode ?
  1186. 0 :
  1187. ((series.pointAttribs(point)['stroke-width'] || 0) % 2) / 2); };
  1188. points.forEach(function (point) {
  1189. var _a = point.node,
  1190. values = _a.pointValues,
  1191. visible = _a.visible;
  1192. // Points which is ignored, have no values.
  1193. if (values && visible) {
  1194. var height = values.height,
  1195. width = values.width,
  1196. x = values.x,
  1197. y = values.y;
  1198. var crispCorr = getCrispCorrection(point);
  1199. var x1 = Math.round(xAxis.toPixels(x,
  1200. true)) - crispCorr;
  1201. var x2 = Math.round(xAxis.toPixels(x + width,
  1202. true)) - crispCorr;
  1203. var y1 = Math.round(yAxis.toPixels(y,
  1204. true)) - crispCorr;
  1205. var y2 = Math.round(yAxis.toPixels(y + height,
  1206. true)) - crispCorr;
  1207. // Set point values
  1208. point.shapeArgs = {
  1209. x: Math.min(x1, x2),
  1210. y: Math.min(y1, y2),
  1211. width: Math.abs(x2 - x1),
  1212. height: Math.abs(y2 - y1)
  1213. };
  1214. point.plotX =
  1215. point.shapeArgs.x + (point.shapeArgs.width / 2);
  1216. point.plotY =
  1217. point.shapeArgs.y + (point.shapeArgs.height / 2);
  1218. }
  1219. else {
  1220. // Reset visibility
  1221. delete point.plotX;
  1222. delete point.plotY;
  1223. }
  1224. });
  1225. },
  1226. // Set the node's color recursively, from the parent down.
  1227. setColorRecursive: function (node, parentColor, colorIndex, index, siblings) {
  1228. var series = this,
  1229. chart = series && series.chart,
  1230. colors = chart && chart.options && chart.options.colors,
  1231. colorInfo,
  1232. point;
  1233. if (node) {
  1234. colorInfo = getColor(node, {
  1235. colors: colors,
  1236. index: index,
  1237. mapOptionsToLevel: series.mapOptionsToLevel,
  1238. parentColor: parentColor,
  1239. parentColorIndex: colorIndex,
  1240. series: series,
  1241. siblings: siblings
  1242. });
  1243. point = series.points[node.i];
  1244. if (point) {
  1245. point.color = colorInfo.color;
  1246. point.colorIndex = colorInfo.colorIndex;
  1247. }
  1248. // Do it all again with the children
  1249. (node.children || []).forEach(function (child, i) {
  1250. series.setColorRecursive(child, colorInfo.color, colorInfo.colorIndex, i, node.children.length);
  1251. });
  1252. }
  1253. },
  1254. algorithmGroup: function (h, w, d, p) {
  1255. this.height = h;
  1256. this.width = w;
  1257. this.plot = p;
  1258. this.direction = d;
  1259. this.startDirection = d;
  1260. this.total = 0;
  1261. this.nW = 0;
  1262. this.lW = 0;
  1263. this.nH = 0;
  1264. this.lH = 0;
  1265. this.elArr = [];
  1266. this.lP = {
  1267. total: 0,
  1268. lH: 0,
  1269. nH: 0,
  1270. lW: 0,
  1271. nW: 0,
  1272. nR: 0,
  1273. lR: 0,
  1274. aspectRatio: function (w, h) {
  1275. return Math.max((w / h), (h / w));
  1276. }
  1277. };
  1278. this.addElement = function (el) {
  1279. this.lP.total = this.elArr[this.elArr.length - 1];
  1280. this.total = this.total + el;
  1281. if (this.direction === 0) {
  1282. // Calculate last point old aspect ratio
  1283. this.lW = this.nW;
  1284. this.lP.lH = this.lP.total / this.lW;
  1285. this.lP.lR = this.lP.aspectRatio(this.lW, this.lP.lH);
  1286. // Calculate last point new aspect ratio
  1287. this.nW = this.total / this.height;
  1288. this.lP.nH = this.lP.total / this.nW;
  1289. this.lP.nR = this.lP.aspectRatio(this.nW, this.lP.nH);
  1290. }
  1291. else {
  1292. // Calculate last point old aspect ratio
  1293. this.lH = this.nH;
  1294. this.lP.lW = this.lP.total / this.lH;
  1295. this.lP.lR = this.lP.aspectRatio(this.lP.lW, this.lH);
  1296. // Calculate last point new aspect ratio
  1297. this.nH = this.total / this.width;
  1298. this.lP.nW = this.lP.total / this.nH;
  1299. this.lP.nR = this.lP.aspectRatio(this.lP.nW, this.nH);
  1300. }
  1301. this.elArr.push(el);
  1302. };
  1303. this.reset = function () {
  1304. this.nW = 0;
  1305. this.lW = 0;
  1306. this.elArr = [];
  1307. this.total = 0;
  1308. };
  1309. },
  1310. algorithmCalcPoints: function (directionChange, last, group, childrenArea) {
  1311. var pX,
  1312. pY,
  1313. pW,
  1314. pH,
  1315. gW = group.lW,
  1316. gH = group.lH,
  1317. plot = group.plot,
  1318. keep,
  1319. i = 0,
  1320. end = group.elArr.length - 1;
  1321. if (last) {
  1322. gW = group.nW;
  1323. gH = group.nH;
  1324. }
  1325. else {
  1326. keep = group.elArr[group.elArr.length - 1];
  1327. }
  1328. group.elArr.forEach(function (p) {
  1329. if (last || (i < end)) {
  1330. if (group.direction === 0) {
  1331. pX = plot.x;
  1332. pY = plot.y;
  1333. pW = gW;
  1334. pH = p / pW;
  1335. }
  1336. else {
  1337. pX = plot.x;
  1338. pY = plot.y;
  1339. pH = gH;
  1340. pW = p / pH;
  1341. }
  1342. childrenArea.push({
  1343. x: pX,
  1344. y: pY,
  1345. width: pW,
  1346. height: correctFloat(pH)
  1347. });
  1348. if (group.direction === 0) {
  1349. plot.y = plot.y + pH;
  1350. }
  1351. else {
  1352. plot.x = plot.x + pW;
  1353. }
  1354. }
  1355. i = i + 1;
  1356. });
  1357. // Reset variables
  1358. group.reset();
  1359. if (group.direction === 0) {
  1360. group.width = group.width - gW;
  1361. }
  1362. else {
  1363. group.height = group.height - gH;
  1364. }
  1365. plot.y = plot.parent.y + (plot.parent.height - group.height);
  1366. plot.x = plot.parent.x + (plot.parent.width - group.width);
  1367. if (directionChange) {
  1368. group.direction = 1 - group.direction;
  1369. }
  1370. // If not last, then add uncalculated element
  1371. if (!last) {
  1372. group.addElement(keep);
  1373. }
  1374. },
  1375. algorithmLowAspectRatio: function (directionChange, parent, children) {
  1376. var childrenArea = [],
  1377. series = this,
  1378. pTot,
  1379. plot = {
  1380. x: parent.x,
  1381. y: parent.y,
  1382. parent: parent
  1383. },
  1384. direction = parent.direction,
  1385. i = 0,
  1386. end = children.length - 1,
  1387. group = new this.algorithmGroup(// eslint-disable-line new-cap
  1388. parent.height,
  1389. parent.width,
  1390. direction,
  1391. plot);
  1392. // Loop through and calculate all areas
  1393. children.forEach(function (child) {
  1394. pTot =
  1395. (parent.width * parent.height) * (child.val / parent.val);
  1396. group.addElement(pTot);
  1397. if (group.lP.nR > group.lP.lR) {
  1398. series.algorithmCalcPoints(directionChange, false, group, childrenArea, plot // @todo no supported
  1399. );
  1400. }
  1401. // If last child, then calculate all remaining areas
  1402. if (i === end) {
  1403. series.algorithmCalcPoints(directionChange, true, group, childrenArea, plot // @todo not supported
  1404. );
  1405. }
  1406. i = i + 1;
  1407. });
  1408. return childrenArea;
  1409. },
  1410. algorithmFill: function (directionChange, parent, children) {
  1411. var childrenArea = [],
  1412. pTot,
  1413. direction = parent.direction,
  1414. x = parent.x,
  1415. y = parent.y,
  1416. width = parent.width,
  1417. height = parent.height,
  1418. pX,
  1419. pY,
  1420. pW,
  1421. pH;
  1422. children.forEach(function (child) {
  1423. pTot =
  1424. (parent.width * parent.height) * (child.val / parent.val);
  1425. pX = x;
  1426. pY = y;
  1427. if (direction === 0) {
  1428. pH = height;
  1429. pW = pTot / pH;
  1430. width = width - pW;
  1431. x = x + pW;
  1432. }
  1433. else {
  1434. pW = width;
  1435. pH = pTot / pW;
  1436. height = height - pH;
  1437. y = y + pH;
  1438. }
  1439. childrenArea.push({
  1440. x: pX,
  1441. y: pY,
  1442. width: pW,
  1443. height: pH
  1444. });
  1445. if (directionChange) {
  1446. direction = 1 - direction;
  1447. }
  1448. });
  1449. return childrenArea;
  1450. },
  1451. strip: function (parent, children) {
  1452. return this.algorithmLowAspectRatio(false, parent, children);
  1453. },
  1454. squarified: function (parent, children) {
  1455. return this.algorithmLowAspectRatio(true, parent, children);
  1456. },
  1457. sliceAndDice: function (parent, children) {
  1458. return this.algorithmFill(true, parent, children);
  1459. },
  1460. stripes: function (parent, children) {
  1461. return this.algorithmFill(false, parent, children);
  1462. },
  1463. translate: function () {
  1464. var series = this,
  1465. options = series.options,
  1466. // NOTE: updateRootId modifies series.
  1467. rootId = updateRootId(series),
  1468. rootNode,
  1469. pointValues,
  1470. seriesArea,
  1471. tree,
  1472. val;
  1473. // Call prototype function
  1474. Series.prototype.translate.call(series);
  1475. // @todo Only if series.isDirtyData is true
  1476. tree = series.tree = series.getTree();
  1477. rootNode = series.nodeMap[rootId];
  1478. series.renderTraverseUpButton(rootId);
  1479. series.mapOptionsToLevel = getLevelOptions({
  1480. from: rootNode.level + 1,
  1481. levels: options.levels,
  1482. to: tree.height,
  1483. defaults: {
  1484. levelIsConstant: series.options.levelIsConstant,
  1485. colorByPoint: options.colorByPoint
  1486. }
  1487. });
  1488. if (rootId !== '' &&
  1489. (!rootNode || !rootNode.children.length)) {
  1490. series.setRootNode('', false);
  1491. rootId = series.rootNode;
  1492. rootNode = series.nodeMap[rootId];
  1493. }
  1494. // Parents of the root node is by default visible
  1495. recursive(series.nodeMap[series.rootNode], function (node) {
  1496. var next = false,
  1497. p = node.parent;
  1498. node.visible = true;
  1499. if (p || p === '') {
  1500. next = series.nodeMap[p];
  1501. }
  1502. return next;
  1503. });
  1504. // Children of the root node is by default visible
  1505. recursive(series.nodeMap[series.rootNode].children, function (children) {
  1506. var next = false;
  1507. children.forEach(function (child) {
  1508. child.visible = true;
  1509. if (child.children.length) {
  1510. next = (next || []).concat(child.children);
  1511. }
  1512. });
  1513. return next;
  1514. });
  1515. series.setTreeValues(tree);
  1516. // Calculate plotting values.
  1517. series.axisRatio = (series.xAxis.len / series.yAxis.len);
  1518. series.nodeMap[''].pointValues = pointValues = {
  1519. x: 0,
  1520. y: 0,
  1521. width: AXIS_MAX,
  1522. height: AXIS_MAX
  1523. };
  1524. series.nodeMap[''].values = seriesArea = merge(pointValues, {
  1525. width: (pointValues.width * series.axisRatio),
  1526. direction: (options.layoutStartingDirection === 'vertical' ? 0 : 1),
  1527. val: tree.val
  1528. });
  1529. series.calculateChildrenAreas(tree, seriesArea);
  1530. // Logic for point colors
  1531. if (!series.colorAxis &&
  1532. !options.colorByPoint) {
  1533. series.setColorRecursive(series.tree);
  1534. }
  1535. // Update axis extremes according to the root node.
  1536. if (options.allowTraversingTree) {
  1537. val = rootNode.pointValues;
  1538. series.xAxis.setExtremes(val.x, val.x + val.width, false);
  1539. series.yAxis.setExtremes(val.y, val.y + val.height, false);
  1540. series.xAxis.setScale();
  1541. series.yAxis.setScale();
  1542. }
  1543. // Assign values to points.
  1544. series.setPointValues();
  1545. },
  1546. /**
  1547. * Extend drawDataLabels with logic to handle custom options related to
  1548. * the treemap series:
  1549. *
  1550. * - Points which is not a leaf node, has dataLabels disabled by
  1551. * default.
  1552. *
  1553. * - Options set on series.levels is merged in.
  1554. *
  1555. * - Width of the dataLabel is set to match the width of the point
  1556. * shape.
  1557. *
  1558. * @private
  1559. * @function Highcharts.Series#drawDataLabels
  1560. */
  1561. drawDataLabels: function () {
  1562. var series = this,
  1563. mapOptionsToLevel = series.mapOptionsToLevel,
  1564. points = series.points.filter(function (n) {
  1565. return n.node.visible;
  1566. }), options, level;
  1567. points.forEach(function (point) {
  1568. level = mapOptionsToLevel[point.node.level];
  1569. // Set options to new object to avoid problems with scope
  1570. options = { style: {} };
  1571. // If not a leaf, then label should be disabled as default
  1572. if (!point.node.isLeaf) {
  1573. options.enabled = false;
  1574. }
  1575. // If options for level exists, include them as well
  1576. if (level && level.dataLabels) {
  1577. options = merge(options, level.dataLabels);
  1578. series._hasPointLabels = true;
  1579. }
  1580. // Set dataLabel width to the width of the point shape.
  1581. if (point.shapeArgs) {
  1582. options.style.width = point.shapeArgs.width;
  1583. if (point.dataLabel) {
  1584. point.dataLabel.css({
  1585. width: point.shapeArgs.width + 'px'
  1586. });
  1587. }
  1588. }
  1589. // Merge custom options with point options
  1590. point.dlOptions = merge(options, point.options.dataLabels);
  1591. });
  1592. Series.prototype.drawDataLabels.call(this);
  1593. },
  1594. // Over the alignment method by setting z index
  1595. alignDataLabel: function (point, dataLabel, labelOptions) {
  1596. var style = labelOptions.style;
  1597. // #8160: Prevent the label from exceeding the point's
  1598. // boundaries in treemaps by applying ellipsis overflow.
  1599. // The issue was happening when datalabel's text contained a
  1600. // long sequence of characters without a whitespace.
  1601. if (!defined(style.textOverflow) &&
  1602. dataLabel.text &&
  1603. dataLabel.getBBox().width > dataLabel.text.textWidth) {
  1604. dataLabel.css({
  1605. textOverflow: 'ellipsis',
  1606. // unit (px) is required when useHTML is true
  1607. width: style.width += 'px'
  1608. });
  1609. }
  1610. seriesTypes.column.prototype.alignDataLabel.apply(this, arguments);
  1611. if (point.dataLabel) {
  1612. // point.node.zIndex could be undefined (#6956)
  1613. point.dataLabel.attr({ zIndex: (point.node.zIndex || 0) + 1 });
  1614. }
  1615. },
  1616. // Get presentational attributes
  1617. pointAttribs: function (point, state) {
  1618. var series = this,
  1619. mapOptionsToLevel = (isObject(series.mapOptionsToLevel) ?
  1620. series.mapOptionsToLevel :
  1621. {}),
  1622. level = point && mapOptionsToLevel[point.node.level] || {},
  1623. options = this.options,
  1624. attr,
  1625. stateOptions = (state && options.states[state]) || {},
  1626. className = (point && point.getClassName()) || '',
  1627. opacity;
  1628. // Set attributes by precedence. Point trumps level trumps series.
  1629. // Stroke width uses pick because it can be 0.
  1630. attr = {
  1631. 'stroke': (point && point.borderColor) ||
  1632. level.borderColor ||
  1633. stateOptions.borderColor ||
  1634. options.borderColor,
  1635. 'stroke-width': pick(point && point.borderWidth, level.borderWidth, stateOptions.borderWidth, options.borderWidth),
  1636. 'dashstyle': (point && point.borderDashStyle) ||
  1637. level.borderDashStyle ||
  1638. stateOptions.borderDashStyle ||
  1639. options.borderDashStyle,
  1640. 'fill': (point && point.color) || this.color
  1641. };
  1642. // Hide levels above the current view
  1643. if (className.indexOf('highcharts-above-level') !== -1) {
  1644. attr.fill = 'none';
  1645. attr['stroke-width'] = 0;
  1646. // Nodes with children that accept interaction
  1647. }
  1648. else if (className.indexOf('highcharts-internal-node-interactive') !== -1) {
  1649. opacity = pick(stateOptions.opacity, options.opacity);
  1650. attr.fill = color(attr.fill).setOpacity(opacity).get();
  1651. attr.cursor = 'pointer';
  1652. // Hide nodes that have children
  1653. }
  1654. else if (className.indexOf('highcharts-internal-node') !== -1) {
  1655. attr.fill = 'none';
  1656. }
  1657. else if (state) {
  1658. // Brighten and hoist the hover nodes
  1659. attr.fill = color(attr.fill)
  1660. .brighten(stateOptions.brightness)
  1661. .get();
  1662. }
  1663. return attr;
  1664. },
  1665. // Override drawPoints
  1666. drawPoints: function () {
  1667. var series = this,
  1668. chart = series.chart,
  1669. renderer = chart.renderer,
  1670. points = series.points,
  1671. styledMode = chart.styledMode,
  1672. options = series.options,
  1673. shadow = styledMode ? {} : options.shadow,
  1674. borderRadius = options.borderRadius,
  1675. withinAnimationLimit = chart.pointCount < options.animationLimit,
  1676. allowTraversingTree = options.allowTraversingTree;
  1677. points.forEach(function (point) {
  1678. var levelDynamic = point.node.levelDynamic,
  1679. animatableAttribs = {},
  1680. attribs = {},
  1681. css = {},
  1682. groupKey = 'level-group-' + point.node.level,
  1683. hasGraphic = !!point.graphic,
  1684. shouldAnimate = withinAnimationLimit && hasGraphic,
  1685. shapeArgs = point.shapeArgs;
  1686. // Don't bother with calculate styling if the point is not drawn
  1687. if (point.shouldDraw()) {
  1688. if (borderRadius) {
  1689. attribs.r = borderRadius;
  1690. }
  1691. merge(true, // Extend object
  1692. // Which object to extend
  1693. shouldAnimate ? animatableAttribs : attribs,
  1694. // Add shapeArgs to animate/attr if graphic exists
  1695. hasGraphic ? shapeArgs : {},
  1696. // Add style attribs if !styleMode
  1697. styledMode ?
  1698. {} :
  1699. series.pointAttribs(point, point.selected ? 'select' : void 0));
  1700. // In styled mode apply point.color. Use CSS, otherwise the
  1701. // fill used in the style sheet will take precedence over
  1702. // the fill attribute.
  1703. if (series.colorAttribs && styledMode) {
  1704. // Heatmap is loaded
  1705. extend(css, series.colorAttribs(point));
  1706. }
  1707. if (!series[groupKey]) {
  1708. series[groupKey] = renderer.g(groupKey)
  1709. .attr({
  1710. // @todo Set the zIndex based upon the number of
  1711. // levels, instead of using 1000
  1712. zIndex: 1000 - (levelDynamic || 0)
  1713. })
  1714. .add(series.group);
  1715. series[groupKey].survive = true;
  1716. }
  1717. }
  1718. // Draw the point
  1719. point.draw({
  1720. animatableAttribs: animatableAttribs,
  1721. attribs: attribs,
  1722. css: css,
  1723. group: series[groupKey],
  1724. renderer: renderer,
  1725. shadow: shadow,
  1726. shapeArgs: shapeArgs,
  1727. shapeType: 'rect'
  1728. });
  1729. // If setRootNode is allowed, set a point cursor on clickables &
  1730. // add drillId to point
  1731. if (allowTraversingTree && point.graphic) {
  1732. point.drillId = options.interactByLeaf ?
  1733. series.drillToByLeaf(point) :
  1734. series.drillToByGroup(point);
  1735. }
  1736. });
  1737. },
  1738. // Add drilling on the suitable points
  1739. onClickDrillToNode: function (event) {
  1740. var series = this,
  1741. point = event.point,
  1742. drillId = point && point.drillId;
  1743. // If a drill id is returned, add click event and cursor.
  1744. if (isString(drillId)) {
  1745. point.setState(''); // Remove hover
  1746. series.setRootNode(drillId, true, { trigger: 'click' });
  1747. }
  1748. },
  1749. /**
  1750. * Finds the drill id for a parent node. Returns false if point should
  1751. * not have a click event.
  1752. *
  1753. * @private
  1754. * @function Highcharts.Series#drillToByGroup
  1755. *
  1756. * @param {Highcharts.Point} point
  1757. *
  1758. * @return {boolean|string}
  1759. * Drill to id or false when point should not have a click
  1760. * event.
  1761. */
  1762. drillToByGroup: function (point) {
  1763. var series = this,
  1764. drillId = false;
  1765. if ((point.node.level - series.nodeMap[series.rootNode].level) ===
  1766. 1 &&
  1767. !point.node.isLeaf) {
  1768. drillId = point.id;
  1769. }
  1770. return drillId;
  1771. },
  1772. /**
  1773. * Finds the drill id for a leaf node. Returns false if point should not
  1774. * have a click event
  1775. *
  1776. * @private
  1777. * @function Highcharts.Series#drillToByLeaf
  1778. *
  1779. * @param {Highcharts.Point} point
  1780. *
  1781. * @return {boolean|string}
  1782. * Drill to id or false when point should not have a click
  1783. * event.
  1784. */
  1785. drillToByLeaf: function (point) {
  1786. var series = this,
  1787. drillId = false,
  1788. nodeParent;
  1789. if ((point.node.parent !== series.rootNode) &&
  1790. point.node.isLeaf) {
  1791. nodeParent = point.node;
  1792. while (!drillId) {
  1793. nodeParent = series.nodeMap[nodeParent.parent];
  1794. if (nodeParent.parent === series.rootNode) {
  1795. drillId = nodeParent.id;
  1796. }
  1797. }
  1798. }
  1799. return drillId;
  1800. },
  1801. drillUp: function () {
  1802. var series = this,
  1803. node = series.nodeMap[series.rootNode];
  1804. if (node && isString(node.parent)) {
  1805. series.setRootNode(node.parent, true, { trigger: 'traverseUpButton' });
  1806. }
  1807. },
  1808. // TODO remove this function at a suitable version.
  1809. drillToNode: function (id, redraw) {
  1810. error(32, false, void 0, { 'treemap.drillToNode': 'use treemap.setRootNode' });
  1811. this.setRootNode(id, redraw);
  1812. },
  1813. /**
  1814. * Sets a new root node for the series.
  1815. *
  1816. * @private
  1817. * @function Highcharts.Series#setRootNode
  1818. *
  1819. * @param {string} id The id of the new root node.
  1820. * @param {boolean} [redraw=true] Wether to redraw the chart or not.
  1821. * @param {object} [eventArguments] Arguments to be accessed in
  1822. * event handler.
  1823. * @param {string} [eventArguments.newRootId] Id of the new root.
  1824. * @param {string} [eventArguments.previousRootId] Id of the previous
  1825. * root.
  1826. * @param {boolean} [eventArguments.redraw] Wether to redraw the
  1827. * chart after.
  1828. * @param {object} [eventArguments.series] The series to update the root
  1829. * of.
  1830. * @param {string} [eventArguments.trigger] The action which
  1831. * triggered the event. Undefined if the setRootNode is called
  1832. * directly.
  1833. * @return {void}
  1834. *
  1835. * @fires Highcharts.Series#event:setRootNode
  1836. */
  1837. setRootNode: function (id, redraw, eventArguments) {
  1838. var series = this,
  1839. eventArgs = extend({
  1840. newRootId: id,
  1841. previousRootId: series.rootNode,
  1842. redraw: pick(redraw,
  1843. true),
  1844. series: series
  1845. },
  1846. eventArguments);
  1847. /**
  1848. * The default functionality of the setRootNode event.
  1849. *
  1850. * @private
  1851. * @param {object} args The event arguments.
  1852. * @param {string} args.newRootId Id of the new root.
  1853. * @param {string} args.previousRootId Id of the previous root.
  1854. * @param {boolean} args.redraw Wether to redraw the chart after.
  1855. * @param {object} args.series The series to update the root of.
  1856. * @param {string} [args.trigger=undefined] The action which
  1857. * triggered the event. Undefined if the setRootNode is called
  1858. * directly.
  1859. * @return {void}
  1860. */
  1861. var defaultFn = function (args) {
  1862. var series = args.series;
  1863. // Store previous and new root ids on the series.
  1864. series.idPreviousRoot = args.previousRootId;
  1865. series.rootNode = args.newRootId;
  1866. // Redraw the chart
  1867. series.isDirty = true; // Force redraw
  1868. if (args.redraw) {
  1869. series.chart.redraw();
  1870. }
  1871. };
  1872. // Fire setRootNode event.
  1873. fireEvent(series, 'setRootNode', eventArgs, defaultFn);
  1874. },
  1875. renderTraverseUpButton: function (rootId) {
  1876. var series = this,
  1877. nodeMap = series.nodeMap,
  1878. node = nodeMap[rootId],
  1879. name = node.name,
  1880. buttonOptions = series.options.traverseUpButton,
  1881. backText = pick(buttonOptions.text,
  1882. name, '◁ Back'),
  1883. attr,
  1884. states;
  1885. if (rootId === '' || (series.is('sunburst') &&
  1886. series.tree.children.length === 1 &&
  1887. rootId === series.tree.children[0].id)) {
  1888. if (series.drillUpButton) {
  1889. series.drillUpButton = series.drillUpButton.destroy();
  1890. }
  1891. }
  1892. else if (!this.drillUpButton) {
  1893. attr = buttonOptions.theme;
  1894. states = attr && attr.states;
  1895. this.drillUpButton = this.chart.renderer
  1896. .button(backText, 0, 0, function () {
  1897. series.drillUp();
  1898. }, attr, states && states.hover, states && states.select)
  1899. .addClass('highcharts-drillup-button')
  1900. .attr({
  1901. align: buttonOptions.position.align,
  1902. zIndex: 7
  1903. })
  1904. .add()
  1905. .align(buttonOptions.position, false, buttonOptions.relativeTo || 'plotBox');
  1906. }
  1907. else {
  1908. this.drillUpButton.placed = false;
  1909. this.drillUpButton.attr({
  1910. text: backText
  1911. })
  1912. .align();
  1913. }
  1914. },
  1915. buildKDTree: noop,
  1916. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  1917. getExtremes: function () {
  1918. // Get the extremes from the value data
  1919. var _a = Series.prototype.getExtremes
  1920. .call(this,
  1921. this.colorValueData),
  1922. dataMin = _a.dataMin,
  1923. dataMax = _a.dataMax;
  1924. this.valueMin = dataMin;
  1925. this.valueMax = dataMax;
  1926. // Get the extremes from the y data
  1927. return Series.prototype.getExtremes.call(this);
  1928. },
  1929. getExtremesFromAll: true,
  1930. /**
  1931. * Workaround for `inactive` state. Since `series.opacity` option is
  1932. * already reserved, don't use that state at all by disabling
  1933. * `inactiveOtherPoints` and not inheriting states by points.
  1934. *
  1935. * @private
  1936. */
  1937. setState: function (state) {
  1938. this.options.inactiveOtherPoints = true;
  1939. Series.prototype.setState.call(this, state, false);
  1940. this.options.inactiveOtherPoints = false;
  1941. },
  1942. utils: {
  1943. recursive: recursive
  1944. }
  1945. /* eslint-enable no-invalid-this, valid-jsdoc */
  1946. }, {
  1947. draw: drawPoint,
  1948. setVisible: seriesTypes.pie.prototype.pointClass.prototype.setVisible,
  1949. /* eslint-disable no-invalid-this, valid-jsdoc */
  1950. getClassName: function () {
  1951. var className = Point.prototype.getClassName.call(this),
  1952. series = this.series,
  1953. options = series.options;
  1954. // Above the current level
  1955. if (this.node.level <= series.nodeMap[series.rootNode].level) {
  1956. className += ' highcharts-above-level';
  1957. }
  1958. else if (!this.node.isLeaf &&
  1959. !pick(options.interactByLeaf, !options.allowTraversingTree)) {
  1960. className += ' highcharts-internal-node-interactive';
  1961. }
  1962. else if (!this.node.isLeaf) {
  1963. className += ' highcharts-internal-node';
  1964. }
  1965. return className;
  1966. },
  1967. /**
  1968. * A tree point is valid if it has han id too, assume it may be a parent
  1969. * item.
  1970. *
  1971. * @private
  1972. * @function Highcharts.Point#isValid
  1973. */
  1974. isValid: function () {
  1975. return Boolean(this.id || isNumber(this.value));
  1976. },
  1977. setState: function (state) {
  1978. Point.prototype.setState.call(this, state);
  1979. // Graphic does not exist when point is not visible.
  1980. if (this.graphic) {
  1981. this.graphic.attr({
  1982. zIndex: state === 'hover' ? 1 : 0
  1983. });
  1984. }
  1985. },
  1986. shouldDraw: function () {
  1987. return isNumber(this.plotY) && this.y !== null;
  1988. }
  1989. });
  1990. addEvent(H.Series, 'afterBindAxes', function () {
  1991. var series = this,
  1992. xAxis = series.xAxis,
  1993. yAxis = series.yAxis,
  1994. treeAxis;
  1995. if (xAxis && yAxis) {
  1996. if (series.is('treemap')) {
  1997. treeAxis = {
  1998. endOnTick: false,
  1999. gridLineWidth: 0,
  2000. lineWidth: 0,
  2001. min: 0,
  2002. dataMin: 0,
  2003. minPadding: 0,
  2004. max: AXIS_MAX,
  2005. dataMax: AXIS_MAX,
  2006. maxPadding: 0,
  2007. startOnTick: false,
  2008. title: null,
  2009. tickPositions: []
  2010. };
  2011. extend(yAxis.options, treeAxis);
  2012. extend(xAxis.options, treeAxis);
  2013. treemapAxisDefaultValues = true;
  2014. }
  2015. else if (treemapAxisDefaultValues) {
  2016. yAxis.setOptions(yAxis.userOptions);
  2017. xAxis.setOptions(xAxis.userOptions);
  2018. treemapAxisDefaultValues = false;
  2019. }
  2020. }
  2021. });
  2022. /* eslint-enable no-invalid-this, valid-jsdoc */
  2023. /**
  2024. * A `treemap` series. If the [type](#series.treemap.type) option is
  2025. * not specified, it is inherited from [chart.type](#chart.type).
  2026. *
  2027. * @extends series,plotOptions.treemap
  2028. * @excluding dataParser, dataURL, stack, dataSorting
  2029. * @product highcharts
  2030. * @requires modules/treemap
  2031. * @apioption series.treemap
  2032. */
  2033. /**
  2034. * An array of data points for the series. For the `treemap` series
  2035. * type, points can be given in the following ways:
  2036. *
  2037. * 1. An array of numerical values. In this case, the numerical values will be
  2038. * interpreted as `value` options. Example:
  2039. * ```js
  2040. * data: [0, 5, 3, 5]
  2041. * ```
  2042. *
  2043. * 2. An array of objects with named values. The following snippet shows only a
  2044. * few settings, see the complete options set below. If the total number of
  2045. * data points exceeds the series'
  2046. * [turboThreshold](#series.treemap.turboThreshold),
  2047. * this option is not available.
  2048. * ```js
  2049. * data: [{
  2050. * value: 9,
  2051. * name: "Point2",
  2052. * color: "#00FF00"
  2053. * }, {
  2054. * value: 6,
  2055. * name: "Point1",
  2056. * color: "#FF00FF"
  2057. * }]
  2058. * ```
  2059. *
  2060. * @sample {highcharts} highcharts/chart/reflow-true/
  2061. * Numerical values
  2062. * @sample {highcharts} highcharts/series/data-array-of-objects/
  2063. * Config objects
  2064. *
  2065. * @type {Array<number|null|*>}
  2066. * @extends series.heatmap.data
  2067. * @excluding x, y
  2068. * @product highcharts
  2069. * @apioption series.treemap.data
  2070. */
  2071. /**
  2072. * The value of the point, resulting in a relative area of the point
  2073. * in the treemap.
  2074. *
  2075. * @type {number|null}
  2076. * @product highcharts
  2077. * @apioption series.treemap.data.value
  2078. */
  2079. /**
  2080. * Serves a purpose only if a `colorAxis` object is defined in the chart
  2081. * options. This value will decide which color the point gets from the
  2082. * scale of the colorAxis.
  2083. *
  2084. * @type {number}
  2085. * @since 4.1.0
  2086. * @product highcharts
  2087. * @apioption series.treemap.data.colorValue
  2088. */
  2089. /**
  2090. * Only for treemap. Use this option to build a tree structure. The
  2091. * value should be the id of the point which is the parent. If no points
  2092. * has a matching id, or this option is undefined, then the parent will
  2093. * be set to the root.
  2094. *
  2095. * @sample {highcharts} highcharts/point/parent/
  2096. * Point parent
  2097. * @sample {highcharts} highcharts/demo/treemap-with-levels/
  2098. * Example where parent id is not matching
  2099. *
  2100. * @type {string}
  2101. * @since 4.1.0
  2102. * @product highcharts
  2103. * @apioption series.treemap.data.parent
  2104. */
  2105. ''; // adds doclets above to transpiled file
  2106. });
  2107. _registerModule(_modules, 'Series/SunburstSeries.js', [_modules['Core/Series/Series.js'], _modules['Mixins/CenteredSeries.js'], _modules['Mixins/DrawPoint.js'], _modules['Core/Globals.js'], _modules['Mixins/TreeSeries.js'], _modules['Core/Utilities.js']], function (BaseSeries, CenteredSeriesMixin, DrawPointMixin, H, TreeSeriesMixin, U) {
  2108. /* *
  2109. *
  2110. * This module implements sunburst charts in Highcharts.
  2111. *
  2112. * (c) 2016-2020 Highsoft AS
  2113. *
  2114. * Authors: Jon Arild Nygard
  2115. *
  2116. * License: www.highcharts.com/license
  2117. *
  2118. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2119. *
  2120. * */
  2121. var seriesTypes = BaseSeries.seriesTypes;
  2122. var getCenter = CenteredSeriesMixin.getCenter,
  2123. getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians;
  2124. var drawPoint = DrawPointMixin.drawPoint;
  2125. var noop = H.noop;
  2126. var getColor = TreeSeriesMixin.getColor,
  2127. getLevelOptions = TreeSeriesMixin.getLevelOptions,
  2128. setTreeValues = TreeSeriesMixin.setTreeValues,
  2129. updateRootId = TreeSeriesMixin.updateRootId;
  2130. var correctFloat = U.correctFloat,
  2131. error = U.error,
  2132. extend = U.extend,
  2133. isNumber = U.isNumber,
  2134. isObject = U.isObject,
  2135. isString = U.isString,
  2136. merge = U.merge,
  2137. splat = U.splat;
  2138. var Series = H.Series,
  2139. isBoolean = function (x) {
  2140. return typeof x === 'boolean';
  2141. }, rad2deg = 180 / Math.PI;
  2142. // TODO introduce step, which should default to 1.
  2143. var range = function range(from,
  2144. to) {
  2145. var result = [],
  2146. i;
  2147. if (isNumber(from) && isNumber(to) && from <= to) {
  2148. for (i = from; i <= to; i++) {
  2149. result.push(i);
  2150. }
  2151. }
  2152. return result;
  2153. };
  2154. /**
  2155. * @private
  2156. * @function calculateLevelSizes
  2157. *
  2158. * @param {object} levelOptions
  2159. * Map of level to its options.
  2160. *
  2161. * @param {Highcharts.Dictionary<number>} params
  2162. * Object containing number parameters `innerRadius` and `outerRadius`.
  2163. *
  2164. * @return {Highcharts.SunburstSeriesLevelsOptions|undefined}
  2165. * Returns the modified options, or undefined.
  2166. */
  2167. var calculateLevelSizes = function calculateLevelSizes(levelOptions,
  2168. params) {
  2169. var result,
  2170. p = isObject(params) ? params : {},
  2171. totalWeight = 0,
  2172. diffRadius,
  2173. levels,
  2174. levelsNotIncluded,
  2175. remainingSize,
  2176. from,
  2177. to;
  2178. if (isObject(levelOptions)) {
  2179. result = merge({}, levelOptions);
  2180. from = isNumber(p.from) ? p.from : 0;
  2181. to = isNumber(p.to) ? p.to : 0;
  2182. levels = range(from, to);
  2183. levelsNotIncluded = Object.keys(result).filter(function (k) {
  2184. return levels.indexOf(+k) === -1;
  2185. });
  2186. diffRadius = remainingSize = isNumber(p.diffRadius) ? p.diffRadius : 0;
  2187. // Convert percentage to pixels.
  2188. // Calculate the remaining size to divide between "weight" levels.
  2189. // Calculate total weight to use in convertion from weight to pixels.
  2190. levels.forEach(function (level) {
  2191. var options = result[level],
  2192. unit = options.levelSize.unit,
  2193. value = options.levelSize.value;
  2194. if (unit === 'weight') {
  2195. totalWeight += value;
  2196. }
  2197. else if (unit === 'percentage') {
  2198. options.levelSize = {
  2199. unit: 'pixels',
  2200. value: (value / 100) * diffRadius
  2201. };
  2202. remainingSize -= options.levelSize.value;
  2203. }
  2204. else if (unit === 'pixels') {
  2205. remainingSize -= value;
  2206. }
  2207. });
  2208. // Convert weight to pixels.
  2209. levels.forEach(function (level) {
  2210. var options = result[level],
  2211. weight;
  2212. if (options.levelSize.unit === 'weight') {
  2213. weight = options.levelSize.value;
  2214. result[level].levelSize = {
  2215. unit: 'pixels',
  2216. value: (weight / totalWeight) * remainingSize
  2217. };
  2218. }
  2219. });
  2220. // Set all levels not included in interval [from,to] to have 0 pixels.
  2221. levelsNotIncluded.forEach(function (level) {
  2222. result[level].levelSize = {
  2223. value: 0,
  2224. unit: 'pixels'
  2225. };
  2226. });
  2227. }
  2228. return result;
  2229. };
  2230. /**
  2231. * Find a set of coordinates given a start coordinates, an angle, and a
  2232. * distance.
  2233. *
  2234. * @private
  2235. * @function getEndPoint
  2236. *
  2237. * @param {number} x
  2238. * Start coordinate x
  2239. *
  2240. * @param {number} y
  2241. * Start coordinate y
  2242. *
  2243. * @param {number} angle
  2244. * Angle in radians
  2245. *
  2246. * @param {number} distance
  2247. * Distance from start to end coordinates
  2248. *
  2249. * @return {Highcharts.SVGAttributes}
  2250. * Returns the end coordinates, x and y.
  2251. */
  2252. var getEndPoint = function getEndPoint(x,
  2253. y,
  2254. angle,
  2255. distance) {
  2256. return {
  2257. x: x + (Math.cos(angle) * distance),
  2258. y: y + (Math.sin(angle) * distance)
  2259. };
  2260. };
  2261. var layoutAlgorithm = function layoutAlgorithm(parent,
  2262. children,
  2263. options) {
  2264. var startAngle = parent.start,
  2265. range = parent.end - startAngle,
  2266. total = parent.val,
  2267. x = parent.x,
  2268. y = parent.y,
  2269. radius = ((options &&
  2270. isObject(options.levelSize) &&
  2271. isNumber(options.levelSize.value)) ?
  2272. options.levelSize.value :
  2273. 0),
  2274. innerRadius = parent.r,
  2275. outerRadius = innerRadius + radius,
  2276. slicedOffset = options && isNumber(options.slicedOffset) ?
  2277. options.slicedOffset :
  2278. 0;
  2279. return (children || []).reduce(function (arr, child) {
  2280. var percentage = (1 / total) * child.val,
  2281. radians = percentage * range,
  2282. radiansCenter = startAngle + (radians / 2),
  2283. offsetPosition = getEndPoint(x,
  2284. y,
  2285. radiansCenter,
  2286. slicedOffset),
  2287. values = {
  2288. x: child.sliced ? offsetPosition.x : x,
  2289. y: child.sliced ? offsetPosition.y : y,
  2290. innerR: innerRadius,
  2291. r: outerRadius,
  2292. radius: radius,
  2293. start: startAngle,
  2294. end: startAngle + radians
  2295. };
  2296. arr.push(values);
  2297. startAngle = values.end;
  2298. return arr;
  2299. }, []);
  2300. };
  2301. var getDlOptions = function getDlOptions(params) {
  2302. // Set options to new object to avoid problems with scope
  2303. var point = params.point,
  2304. shape = isObject(params.shapeArgs) ? params.shapeArgs : {},
  2305. optionsPoint = (isObject(params.optionsPoint) ?
  2306. params.optionsPoint.dataLabels :
  2307. {}),
  2308. // The splat was used because levels dataLabels
  2309. // options doesn't work as an array
  2310. optionsLevel = splat(isObject(params.level) ?
  2311. params.level.dataLabels :
  2312. {})[0],
  2313. options = merge({
  2314. style: {}
  2315. },
  2316. optionsLevel,
  2317. optionsPoint),
  2318. rotationRad,
  2319. rotation,
  2320. rotationMode = options.rotationMode;
  2321. if (!isNumber(options.rotation)) {
  2322. if (rotationMode === 'auto' || rotationMode === 'circular') {
  2323. if (point.innerArcLength < 1 &&
  2324. point.outerArcLength > shape.radius) {
  2325. rotationRad = 0;
  2326. // Triger setTextPath function to get textOutline etc.
  2327. if (point.dataLabelPath && rotationMode === 'circular') {
  2328. options.textPath = {
  2329. enabled: true
  2330. };
  2331. }
  2332. }
  2333. else if (point.innerArcLength > 1 &&
  2334. point.outerArcLength > 1.5 * shape.radius) {
  2335. if (rotationMode === 'circular') {
  2336. options.textPath = {
  2337. enabled: true,
  2338. attributes: {
  2339. dy: 5
  2340. }
  2341. };
  2342. }
  2343. else {
  2344. rotationMode = 'parallel';
  2345. }
  2346. }
  2347. else {
  2348. // Trigger the destroyTextPath function
  2349. if (point.dataLabel &&
  2350. point.dataLabel.textPathWrapper &&
  2351. rotationMode === 'circular') {
  2352. options.textPath = {
  2353. enabled: false
  2354. };
  2355. }
  2356. rotationMode = 'perpendicular';
  2357. }
  2358. }
  2359. if (rotationMode !== 'auto' && rotationMode !== 'circular') {
  2360. rotationRad = (shape.end -
  2361. (shape.end - shape.start) / 2);
  2362. }
  2363. if (rotationMode === 'parallel') {
  2364. options.style.width = Math.min(shape.radius * 2.5, (point.outerArcLength + point.innerArcLength) / 2);
  2365. }
  2366. else {
  2367. options.style.width = shape.radius;
  2368. }
  2369. if (rotationMode === 'perpendicular' &&
  2370. point.series.chart.renderer.fontMetrics(options.style.fontSize).h > point.outerArcLength) {
  2371. options.style.width = 1;
  2372. }
  2373. // Apply padding (#8515)
  2374. options.style.width = Math.max(options.style.width - 2 * (options.padding || 0), 1);
  2375. rotation = (rotationRad * rad2deg) % 180;
  2376. if (rotationMode === 'parallel') {
  2377. rotation -= 90;
  2378. }
  2379. // Prevent text from rotating upside down
  2380. if (rotation > 90) {
  2381. rotation -= 180;
  2382. }
  2383. else if (rotation < -90) {
  2384. rotation += 180;
  2385. }
  2386. options.rotation = rotation;
  2387. }
  2388. if (options.textPath) {
  2389. if (point.shapeExisting.innerR === 0 &&
  2390. options.textPath.enabled) {
  2391. // Enable rotation to render text
  2392. options.rotation = 0;
  2393. // Center dataLabel - disable textPath
  2394. options.textPath.enabled = false;
  2395. // Setting width and padding
  2396. options.style.width = Math.max((point.shapeExisting.r * 2) -
  2397. 2 * (options.padding || 0), 1);
  2398. }
  2399. else if (point.dlOptions &&
  2400. point.dlOptions.textPath &&
  2401. !point.dlOptions.textPath.enabled &&
  2402. (rotationMode === 'circular')) {
  2403. // Bring dataLabel back if was a center dataLabel
  2404. options.textPath.enabled = true;
  2405. }
  2406. if (options.textPath.enabled) {
  2407. // Enable rotation to render text
  2408. options.rotation = 0;
  2409. // Setting width and padding
  2410. options.style.width = Math.max((point.outerArcLength +
  2411. point.innerArcLength) / 2 -
  2412. 2 * (options.padding || 0), 1);
  2413. }
  2414. }
  2415. // NOTE: alignDataLabel positions the data label differntly when rotation is
  2416. // 0. Avoiding this by setting rotation to a small number.
  2417. if (options.rotation === 0) {
  2418. options.rotation = 0.001;
  2419. }
  2420. return options;
  2421. };
  2422. var getAnimation = function getAnimation(shape,
  2423. params) {
  2424. var point = params.point,
  2425. radians = params.radians,
  2426. innerR = params.innerR,
  2427. idRoot = params.idRoot,
  2428. idPreviousRoot = params.idPreviousRoot,
  2429. shapeExisting = params.shapeExisting,
  2430. shapeRoot = params.shapeRoot,
  2431. shapePreviousRoot = params.shapePreviousRoot,
  2432. visible = params.visible,
  2433. from = {},
  2434. to = {
  2435. end: shape.end,
  2436. start: shape.start,
  2437. innerR: shape.innerR,
  2438. r: shape.r,
  2439. x: shape.x,
  2440. y: shape.y
  2441. };
  2442. if (visible) {
  2443. // Animate points in
  2444. if (!point.graphic && shapePreviousRoot) {
  2445. if (idRoot === point.id) {
  2446. from = {
  2447. start: radians.start,
  2448. end: radians.end
  2449. };
  2450. }
  2451. else {
  2452. from = (shapePreviousRoot.end <= shape.start) ? {
  2453. start: radians.end,
  2454. end: radians.end
  2455. } : {
  2456. start: radians.start,
  2457. end: radians.start
  2458. };
  2459. }
  2460. // Animate from center and outwards.
  2461. from.innerR = from.r = innerR;
  2462. }
  2463. }
  2464. else {
  2465. // Animate points out
  2466. if (point.graphic) {
  2467. if (idPreviousRoot === point.id) {
  2468. to = {
  2469. innerR: innerR,
  2470. r: innerR
  2471. };
  2472. }
  2473. else if (shapeRoot) {
  2474. to = (shapeRoot.end <= shapeExisting.start) ?
  2475. {
  2476. innerR: innerR,
  2477. r: innerR,
  2478. start: radians.end,
  2479. end: radians.end
  2480. } : {
  2481. innerR: innerR,
  2482. r: innerR,
  2483. start: radians.start,
  2484. end: radians.start
  2485. };
  2486. }
  2487. }
  2488. }
  2489. return {
  2490. from: from,
  2491. to: to
  2492. };
  2493. };
  2494. var getDrillId = function getDrillId(point,
  2495. idRoot,
  2496. mapIdToNode) {
  2497. var drillId,
  2498. node = point.node,
  2499. nodeRoot;
  2500. if (!node.isLeaf) {
  2501. // When it is the root node, the drillId should be set to parent.
  2502. if (idRoot === point.id) {
  2503. nodeRoot = mapIdToNode[idRoot];
  2504. drillId = nodeRoot.parent;
  2505. }
  2506. else {
  2507. drillId = point.id;
  2508. }
  2509. }
  2510. return drillId;
  2511. };
  2512. var getLevelFromAndTo = function getLevelFromAndTo(_a) {
  2513. var level = _a.level,
  2514. height = _a.height;
  2515. // Never displays level below 1
  2516. var from = level > 0 ? level : 1;
  2517. var to = level + height;
  2518. return { from: from, to: to };
  2519. };
  2520. var cbSetTreeValuesBefore = function before(node,
  2521. options) {
  2522. var mapIdToNode = options.mapIdToNode,
  2523. nodeParent = mapIdToNode[node.parent],
  2524. series = options.series,
  2525. chart = series.chart,
  2526. points = series.points,
  2527. point = points[node.i],
  2528. colors = (series.options.colors || chart && chart.options.colors),
  2529. colorInfo = getColor(node, {
  2530. colors: colors,
  2531. colorIndex: series.colorIndex,
  2532. index: options.index,
  2533. mapOptionsToLevel: options.mapOptionsToLevel,
  2534. parentColor: nodeParent && nodeParent.color,
  2535. parentColorIndex: nodeParent && nodeParent.colorIndex,
  2536. series: options.series,
  2537. siblings: options.siblings
  2538. });
  2539. node.color = colorInfo.color;
  2540. node.colorIndex = colorInfo.colorIndex;
  2541. if (point) {
  2542. point.color = node.color;
  2543. point.colorIndex = node.colorIndex;
  2544. // Set slicing on node, but avoid slicing the top node.
  2545. node.sliced = (node.id !== options.idRoot) ? point.sliced : false;
  2546. }
  2547. return node;
  2548. };
  2549. /**
  2550. * A Sunburst displays hierarchical data, where a level in the hierarchy is
  2551. * represented by a circle. The center represents the root node of the tree.
  2552. * The visualization bears a resemblance to both treemap and pie charts.
  2553. *
  2554. * @sample highcharts/demo/sunburst
  2555. * Sunburst chart
  2556. *
  2557. * @extends plotOptions.pie
  2558. * @excluding allAreas, clip, colorAxis, colorKey, compare, compareBase,
  2559. * dataGrouping, depth, dragDrop, endAngle, gapSize, gapUnit,
  2560. * ignoreHiddenPoint, innerSize, joinBy, legendType, linecap,
  2561. * minSize, navigatorOptions, pointRange
  2562. * @product highcharts
  2563. * @requires modules/sunburst.js
  2564. * @optionparent plotOptions.sunburst
  2565. * @private
  2566. */
  2567. var sunburstOptions = {
  2568. /**
  2569. * Set options on specific levels. Takes precedence over series options,
  2570. * but not point options.
  2571. *
  2572. * @sample highcharts/demo/sunburst
  2573. * Sunburst chart
  2574. *
  2575. * @type {Array<*>}
  2576. * @apioption plotOptions.sunburst.levels
  2577. */
  2578. /**
  2579. * Can set a `borderColor` on all points which lies on the same level.
  2580. *
  2581. * @type {Highcharts.ColorString}
  2582. * @apioption plotOptions.sunburst.levels.borderColor
  2583. */
  2584. /**
  2585. * Can set a `borderWidth` on all points which lies on the same level.
  2586. *
  2587. * @type {number}
  2588. * @apioption plotOptions.sunburst.levels.borderWidth
  2589. */
  2590. /**
  2591. * Can set a `borderDashStyle` on all points which lies on the same level.
  2592. *
  2593. * @type {Highcharts.DashStyleValue}
  2594. * @apioption plotOptions.sunburst.levels.borderDashStyle
  2595. */
  2596. /**
  2597. * Can set a `color` on all points which lies on the same level.
  2598. *
  2599. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2600. * @apioption plotOptions.sunburst.levels.color
  2601. */
  2602. /**
  2603. * Can set a `colorVariation` on all points which lies on the same level.
  2604. *
  2605. * @apioption plotOptions.sunburst.levels.colorVariation
  2606. */
  2607. /**
  2608. * The key of a color variation. Currently supports `brightness` only.
  2609. *
  2610. * @type {string}
  2611. * @apioption plotOptions.sunburst.levels.colorVariation.key
  2612. */
  2613. /**
  2614. * The ending value of a color variation. The last sibling will receive this
  2615. * value.
  2616. *
  2617. * @type {number}
  2618. * @apioption plotOptions.sunburst.levels.colorVariation.to
  2619. */
  2620. /**
  2621. * Can set `dataLabels` on all points which lies on the same level.
  2622. *
  2623. * @extends plotOptions.sunburst.dataLabels
  2624. * @apioption plotOptions.sunburst.levels.dataLabels
  2625. */
  2626. /**
  2627. * Can set a `levelSize` on all points which lies on the same level.
  2628. *
  2629. * @type {object}
  2630. * @apioption plotOptions.sunburst.levels.levelSize
  2631. */
  2632. /**
  2633. * Can set a `rotation` on all points which lies on the same level.
  2634. *
  2635. * @type {number}
  2636. * @apioption plotOptions.sunburst.levels.rotation
  2637. */
  2638. /**
  2639. * Can set a `rotationMode` on all points which lies on the same level.
  2640. *
  2641. * @type {string}
  2642. * @apioption plotOptions.sunburst.levels.rotationMode
  2643. */
  2644. /**
  2645. * When enabled the user can click on a point which is a parent and
  2646. * zoom in on its children. Deprecated and replaced by
  2647. * [allowTraversingTree](#plotOptions.sunburst.allowTraversingTree).
  2648. *
  2649. * @deprecated
  2650. * @type {boolean}
  2651. * @default false
  2652. * @since 6.0.0
  2653. * @product highcharts
  2654. * @apioption plotOptions.sunburst.allowDrillToNode
  2655. */
  2656. /**
  2657. * When enabled the user can click on a point which is a parent and
  2658. * zoom in on its children.
  2659. *
  2660. * @type {boolean}
  2661. * @default false
  2662. * @since 7.0.3
  2663. * @product highcharts
  2664. * @apioption plotOptions.sunburst.allowTraversingTree
  2665. */
  2666. /**
  2667. * The center of the sunburst chart relative to the plot area. Can be
  2668. * percentages or pixel values.
  2669. *
  2670. * @sample {highcharts} highcharts/plotoptions/pie-center/
  2671. * Centered at 100, 100
  2672. *
  2673. * @type {Array<number|string>}
  2674. * @default ["50%", "50%"]
  2675. * @product highcharts
  2676. */
  2677. center: ['50%', '50%'],
  2678. colorByPoint: false,
  2679. /**
  2680. * Disable inherited opacity from Treemap series.
  2681. *
  2682. * @ignore-option
  2683. */
  2684. opacity: 1,
  2685. /**
  2686. * @declare Highcharts.SeriesSunburstDataLabelsOptionsObject
  2687. */
  2688. dataLabels: {
  2689. allowOverlap: true,
  2690. defer: true,
  2691. /**
  2692. * Decides how the data label will be rotated relative to the perimeter
  2693. * of the sunburst. Valid values are `auto`, `circular`, `parallel` and
  2694. * `perpendicular`. When `auto`, the best fit will be
  2695. * computed for the point. The `circular` option works similiar
  2696. * to `auto`, but uses the `textPath` feature - labels are curved,
  2697. * resulting in a better layout, however multiple lines and
  2698. * `textOutline` are not supported.
  2699. *
  2700. * The `series.rotation` option takes precedence over `rotationMode`.
  2701. *
  2702. * @type {string}
  2703. * @sample {highcharts} highcharts/plotoptions/sunburst-datalabels-rotationmode-circular/
  2704. * Circular rotation mode
  2705. * @validvalue ["auto", "perpendicular", "parallel", "circular"]
  2706. * @since 6.0.0
  2707. */
  2708. rotationMode: 'auto',
  2709. style: {
  2710. /** @internal */
  2711. textOverflow: 'ellipsis'
  2712. }
  2713. },
  2714. /**
  2715. * Which point to use as a root in the visualization.
  2716. *
  2717. * @type {string}
  2718. */
  2719. rootId: void 0,
  2720. /**
  2721. * Used together with the levels and `allowDrillToNode` options. When
  2722. * set to false the first level visible when drilling is considered
  2723. * to be level one. Otherwise the level will be the same as the tree
  2724. * structure.
  2725. */
  2726. levelIsConstant: true,
  2727. /**
  2728. * Determines the width of the ring per level.
  2729. *
  2730. * @sample {highcharts} highcharts/plotoptions/sunburst-levelsize/
  2731. * Sunburst with various sizes per level
  2732. *
  2733. * @since 6.0.5
  2734. */
  2735. levelSize: {
  2736. /**
  2737. * The value used for calculating the width of the ring. Its' affect is
  2738. * determined by `levelSize.unit`.
  2739. *
  2740. * @sample {highcharts} highcharts/plotoptions/sunburst-levelsize/
  2741. * Sunburst with various sizes per level
  2742. */
  2743. value: 1,
  2744. /**
  2745. * How to interpret `levelSize.value`.
  2746. *
  2747. * - `percentage` gives a width relative to result of outer radius minus
  2748. * inner radius.
  2749. *
  2750. * - `pixels` gives the ring a fixed width in pixels.
  2751. *
  2752. * - `weight` takes the remaining width after percentage and pixels, and
  2753. * distributes it accross all "weighted" levels. The value relative to
  2754. * the sum of all weights determines the width.
  2755. *
  2756. * @sample {highcharts} highcharts/plotoptions/sunburst-levelsize/
  2757. * Sunburst with various sizes per level
  2758. *
  2759. * @validvalue ["percentage", "pixels", "weight"]
  2760. */
  2761. unit: 'weight'
  2762. },
  2763. /**
  2764. * Options for the button appearing when traversing down in a treemap.
  2765. *
  2766. * @extends plotOptions.treemap.traverseUpButton
  2767. * @since 6.0.0
  2768. * @apioption plotOptions.sunburst.traverseUpButton
  2769. */
  2770. /**
  2771. * If a point is sliced, moved out from the center, how many pixels
  2772. * should it be moved?.
  2773. *
  2774. * @sample highcharts/plotoptions/sunburst-sliced
  2775. * Sliced sunburst
  2776. *
  2777. * @since 6.0.4
  2778. */
  2779. slicedOffset: 10
  2780. };
  2781. // Properties of the Sunburst series.
  2782. var sunburstSeries = {
  2783. drawDataLabels: noop,
  2784. drawPoints: function drawPoints() {
  2785. var series = this,
  2786. mapOptionsToLevel = series.mapOptionsToLevel,
  2787. shapeRoot = series.shapeRoot,
  2788. group = series.group,
  2789. hasRendered = series.hasRendered,
  2790. idRoot = series.rootNode,
  2791. idPreviousRoot = series.idPreviousRoot,
  2792. nodeMap = series.nodeMap,
  2793. nodePreviousRoot = nodeMap[idPreviousRoot],
  2794. shapePreviousRoot = nodePreviousRoot && nodePreviousRoot.shapeArgs,
  2795. points = series.points,
  2796. radians = series.startAndEndRadians,
  2797. chart = series.chart,
  2798. optionsChart = chart && chart.options && chart.options.chart || {},
  2799. animation = (isBoolean(optionsChart.animation) ?
  2800. optionsChart.animation :
  2801. true),
  2802. positions = series.center,
  2803. center = {
  2804. x: positions[0],
  2805. y: positions[1]
  2806. },
  2807. innerR = positions[3] / 2,
  2808. renderer = series.chart.renderer,
  2809. animateLabels,
  2810. animateLabelsCalled = false,
  2811. addedHack = false,
  2812. hackDataLabelAnimation = !!(animation &&
  2813. hasRendered &&
  2814. idRoot !== idPreviousRoot &&
  2815. series.dataLabelsGroup);
  2816. if (hackDataLabelAnimation) {
  2817. series.dataLabelsGroup.attr({ opacity: 0 });
  2818. animateLabels = function () {
  2819. var s = series;
  2820. animateLabelsCalled = true;
  2821. if (s.dataLabelsGroup) {
  2822. s.dataLabelsGroup.animate({
  2823. opacity: 1,
  2824. visibility: 'visible'
  2825. });
  2826. }
  2827. };
  2828. }
  2829. points.forEach(function (point) {
  2830. var node = point.node,
  2831. level = mapOptionsToLevel[node.level],
  2832. shapeExisting = point.shapeExisting || {},
  2833. shape = node.shapeArgs || {},
  2834. animationInfo,
  2835. onComplete,
  2836. visible = !!(node.visible && node.shapeArgs);
  2837. if (hasRendered && animation) {
  2838. animationInfo = getAnimation(shape, {
  2839. center: center,
  2840. point: point,
  2841. radians: radians,
  2842. innerR: innerR,
  2843. idRoot: idRoot,
  2844. idPreviousRoot: idPreviousRoot,
  2845. shapeExisting: shapeExisting,
  2846. shapeRoot: shapeRoot,
  2847. shapePreviousRoot: shapePreviousRoot,
  2848. visible: visible
  2849. });
  2850. }
  2851. else {
  2852. // When animation is disabled, attr is called from animation.
  2853. animationInfo = {
  2854. to: shape,
  2855. from: {}
  2856. };
  2857. }
  2858. extend(point, {
  2859. shapeExisting: shape,
  2860. tooltipPos: [shape.plotX, shape.plotY],
  2861. drillId: getDrillId(point, idRoot, nodeMap),
  2862. name: '' + (point.name || point.id || point.index),
  2863. plotX: shape.plotX,
  2864. plotY: shape.plotY,
  2865. value: node.val,
  2866. isNull: !visible // used for dataLabels & point.draw
  2867. });
  2868. point.dlOptions = getDlOptions({
  2869. point: point,
  2870. level: level,
  2871. optionsPoint: point.options,
  2872. shapeArgs: shape
  2873. });
  2874. if (!addedHack && visible) {
  2875. addedHack = true;
  2876. onComplete = animateLabels;
  2877. }
  2878. point.draw({
  2879. animatableAttribs: animationInfo.to,
  2880. attribs: extend(animationInfo.from, (!chart.styledMode && series.pointAttribs(point, (point.selected && 'select')))),
  2881. onComplete: onComplete,
  2882. group: group,
  2883. renderer: renderer,
  2884. shapeType: 'arc',
  2885. shapeArgs: shape
  2886. });
  2887. });
  2888. // Draw data labels after points
  2889. // TODO draw labels one by one to avoid addtional looping
  2890. if (hackDataLabelAnimation && addedHack) {
  2891. series.hasRendered = false;
  2892. series.options.dataLabels.defer = true;
  2893. Series.prototype.drawDataLabels.call(series);
  2894. series.hasRendered = true;
  2895. // If animateLabels is called before labels were hidden, then call
  2896. // it again.
  2897. if (animateLabelsCalled) {
  2898. animateLabels();
  2899. }
  2900. }
  2901. else {
  2902. Series.prototype.drawDataLabels.call(series);
  2903. }
  2904. },
  2905. pointAttribs: seriesTypes.column.prototype.pointAttribs,
  2906. // The layout algorithm for the levels
  2907. layoutAlgorithm: layoutAlgorithm,
  2908. // Set the shape arguments on the nodes. Recursive from root down.
  2909. setShapeArgs: function (parent, parentValues, mapOptionsToLevel) {
  2910. var childrenValues = [],
  2911. level = parent.level + 1,
  2912. options = mapOptionsToLevel[level],
  2913. // Collect all children which should be included
  2914. children = parent.children.filter(function (n) {
  2915. return n.visible;
  2916. }), twoPi = 6.28; // Two times Pi.
  2917. childrenValues = this.layoutAlgorithm(parentValues, children, options);
  2918. children.forEach(function (child, index) {
  2919. var values = childrenValues[index],
  2920. angle = values.start + ((values.end - values.start) / 2),
  2921. radius = values.innerR + ((values.r - values.innerR) / 2),
  2922. radians = (values.end - values.start),
  2923. isCircle = (values.innerR === 0 && radians > twoPi),
  2924. center = (isCircle ?
  2925. { x: values.x,
  2926. y: values.y } :
  2927. getEndPoint(values.x,
  2928. values.y,
  2929. angle,
  2930. radius)),
  2931. val = (child.val ?
  2932. (child.childrenTotal > child.val ?
  2933. child.childrenTotal :
  2934. child.val) :
  2935. child.childrenTotal);
  2936. // The inner arc length is a convenience for data label filters.
  2937. if (this.points[child.i]) {
  2938. this.points[child.i].innerArcLength = radians * values.innerR;
  2939. this.points[child.i].outerArcLength = radians * values.r;
  2940. }
  2941. child.shapeArgs = merge(values, {
  2942. plotX: center.x,
  2943. plotY: center.y + 4 * Math.abs(Math.cos(angle))
  2944. });
  2945. child.values = merge(values, {
  2946. val: val
  2947. });
  2948. // If node has children, then call method recursively
  2949. if (child.children.length) {
  2950. this.setShapeArgs(child, child.values, mapOptionsToLevel);
  2951. }
  2952. }, this);
  2953. },
  2954. translate: function translate() {
  2955. var series = this,
  2956. options = series.options,
  2957. positions = series.center = getCenter.call(series),
  2958. radians = series.startAndEndRadians = getStartAndEndRadians(options.startAngle,
  2959. options.endAngle),
  2960. innerRadius = positions[3] / 2,
  2961. outerRadius = positions[2] / 2,
  2962. diffRadius = outerRadius - innerRadius,
  2963. // NOTE: updateRootId modifies series.
  2964. rootId = updateRootId(series),
  2965. mapIdToNode = series.nodeMap,
  2966. mapOptionsToLevel,
  2967. idTop,
  2968. nodeRoot = mapIdToNode && mapIdToNode[rootId],
  2969. nodeTop,
  2970. tree,
  2971. values,
  2972. nodeIds = {};
  2973. series.shapeRoot = nodeRoot && nodeRoot.shapeArgs;
  2974. // Call prototype function
  2975. Series.prototype.translate.call(series);
  2976. // @todo Only if series.isDirtyData is true
  2977. tree = series.tree = series.getTree();
  2978. // Render traverseUpButton, after series.nodeMap i calculated.
  2979. series.renderTraverseUpButton(rootId);
  2980. mapIdToNode = series.nodeMap;
  2981. nodeRoot = mapIdToNode[rootId];
  2982. idTop = isString(nodeRoot.parent) ? nodeRoot.parent : '';
  2983. nodeTop = mapIdToNode[idTop];
  2984. var _a = getLevelFromAndTo(nodeRoot),
  2985. from = _a.from,
  2986. to = _a.to;
  2987. mapOptionsToLevel = getLevelOptions({
  2988. from: from,
  2989. levels: series.options.levels,
  2990. to: to,
  2991. defaults: {
  2992. colorByPoint: options.colorByPoint,
  2993. dataLabels: options.dataLabels,
  2994. levelIsConstant: options.levelIsConstant,
  2995. levelSize: options.levelSize,
  2996. slicedOffset: options.slicedOffset
  2997. }
  2998. });
  2999. // NOTE consider doing calculateLevelSizes in a callback to
  3000. // getLevelOptions
  3001. mapOptionsToLevel = calculateLevelSizes(mapOptionsToLevel, {
  3002. diffRadius: diffRadius,
  3003. from: from,
  3004. to: to
  3005. });
  3006. // TODO Try to combine setTreeValues & setColorRecursive to avoid
  3007. // unnecessary looping.
  3008. setTreeValues(tree, {
  3009. before: cbSetTreeValuesBefore,
  3010. idRoot: rootId,
  3011. levelIsConstant: options.levelIsConstant,
  3012. mapOptionsToLevel: mapOptionsToLevel,
  3013. mapIdToNode: mapIdToNode,
  3014. points: series.points,
  3015. series: series
  3016. });
  3017. values = mapIdToNode[''].shapeArgs = {
  3018. end: radians.end,
  3019. r: innerRadius,
  3020. start: radians.start,
  3021. val: nodeRoot.val,
  3022. x: positions[0],
  3023. y: positions[1]
  3024. };
  3025. this.setShapeArgs(nodeTop, values, mapOptionsToLevel);
  3026. // Set mapOptionsToLevel on series for use in drawPoints.
  3027. series.mapOptionsToLevel = mapOptionsToLevel;
  3028. // #10669 - verify if all nodes have unique ids
  3029. series.data.forEach(function (child) {
  3030. if (nodeIds[child.id]) {
  3031. error(31, false, series.chart);
  3032. }
  3033. // map
  3034. nodeIds[child.id] = true;
  3035. });
  3036. // reset object
  3037. nodeIds = {};
  3038. },
  3039. alignDataLabel: function (point, dataLabel, labelOptions) {
  3040. if (labelOptions.textPath && labelOptions.textPath.enabled) {
  3041. return;
  3042. }
  3043. return seriesTypes.treemap.prototype.alignDataLabel
  3044. .apply(this, arguments);
  3045. },
  3046. // Animate the slices in. Similar to the animation of polar charts.
  3047. animate: function (init) {
  3048. var chart = this.chart,
  3049. center = [
  3050. chart.plotWidth / 2,
  3051. chart.plotHeight / 2
  3052. ],
  3053. plotLeft = chart.plotLeft,
  3054. plotTop = chart.plotTop,
  3055. attribs,
  3056. group = this.group;
  3057. // Initialize the animation
  3058. if (init) {
  3059. // Scale down the group and place it in the center
  3060. attribs = {
  3061. translateX: center[0] + plotLeft,
  3062. translateY: center[1] + plotTop,
  3063. scaleX: 0.001,
  3064. scaleY: 0.001,
  3065. rotation: 10,
  3066. opacity: 0.01
  3067. };
  3068. group.attr(attribs);
  3069. // Run the animation
  3070. }
  3071. else {
  3072. attribs = {
  3073. translateX: plotLeft,
  3074. translateY: plotTop,
  3075. scaleX: 1,
  3076. scaleY: 1,
  3077. rotation: 0,
  3078. opacity: 1
  3079. };
  3080. group.animate(attribs, this.options.animation);
  3081. }
  3082. },
  3083. utils: {
  3084. calculateLevelSizes: calculateLevelSizes,
  3085. getLevelFromAndTo: getLevelFromAndTo,
  3086. range: range
  3087. }
  3088. };
  3089. // Properties of the Sunburst series.
  3090. var sunburstPoint = {
  3091. draw: drawPoint,
  3092. shouldDraw: function shouldDraw() {
  3093. return !this.isNull;
  3094. },
  3095. isValid: function isValid() {
  3096. return true;
  3097. },
  3098. getDataLabelPath: function (label) {
  3099. var renderer = this.series.chart.renderer,
  3100. shapeArgs = this.shapeExisting,
  3101. start = shapeArgs.start,
  3102. end = shapeArgs.end,
  3103. angle = start + (end - start) / 2, // arc middle value
  3104. upperHalf = angle < 0 &&
  3105. angle > -Math.PI ||
  3106. angle > Math.PI,
  3107. r = (shapeArgs.r + (label.options.distance || 0)),
  3108. moreThanHalf;
  3109. // Check if point is a full circle
  3110. if (start === -Math.PI / 2 &&
  3111. correctFloat(end) === correctFloat(Math.PI * 1.5)) {
  3112. start = -Math.PI + Math.PI / 360;
  3113. end = -Math.PI / 360;
  3114. upperHalf = true;
  3115. }
  3116. // Check if dataLabels should be render in the
  3117. // upper half of the circle
  3118. if (end - start > Math.PI) {
  3119. upperHalf = false;
  3120. moreThanHalf = true;
  3121. }
  3122. if (this.dataLabelPath) {
  3123. this.dataLabelPath = this.dataLabelPath.destroy();
  3124. }
  3125. this.dataLabelPath = renderer
  3126. .arc({
  3127. open: true,
  3128. longArc: moreThanHalf ? 1 : 0
  3129. })
  3130. // Add it inside the data label group so it gets destroyed
  3131. // with the label
  3132. .add(label);
  3133. this.dataLabelPath.attr({
  3134. start: (upperHalf ? start : end),
  3135. end: (upperHalf ? end : start),
  3136. clockwise: +upperHalf,
  3137. x: shapeArgs.x,
  3138. y: shapeArgs.y,
  3139. r: (r + shapeArgs.innerR) / 2
  3140. });
  3141. return this.dataLabelPath;
  3142. }
  3143. };
  3144. /**
  3145. * A `sunburst` series. If the [type](#series.sunburst.type) option is
  3146. * not specified, it is inherited from [chart.type](#chart.type).
  3147. *
  3148. * @extends series,plotOptions.sunburst
  3149. * @excluding dataParser, dataURL, stack, dataSorting, boostThreshold,
  3150. * boostBlending
  3151. * @product highcharts
  3152. * @requires modules/sunburst.js
  3153. * @apioption series.sunburst
  3154. */
  3155. /**
  3156. * @type {Array<number|null|*>}
  3157. * @extends series.treemap.data
  3158. * @excluding x, y
  3159. * @product highcharts
  3160. * @apioption series.sunburst.data
  3161. */
  3162. /**
  3163. * @type {Highcharts.SeriesSunburstDataLabelsOptionsObject|Array<Highcharts.SeriesSunburstDataLabelsOptionsObject>}
  3164. * @product highcharts
  3165. * @apioption series.sunburst.data.dataLabels
  3166. */
  3167. /**
  3168. * The value of the point, resulting in a relative area of the point
  3169. * in the sunburst.
  3170. *
  3171. * @type {number|null}
  3172. * @since 6.0.0
  3173. * @product highcharts
  3174. * @apioption series.sunburst.data.value
  3175. */
  3176. /**
  3177. * Use this option to build a tree structure. The value should be the id of the
  3178. * point which is the parent. If no points has a matching id, or this option is
  3179. * undefined, then the parent will be set to the root.
  3180. *
  3181. * @type {string}
  3182. * @since 6.0.0
  3183. * @product highcharts
  3184. * @apioption series.sunburst.data.parent
  3185. */
  3186. /**
  3187. * Whether to display a slice offset from the center. When a sunburst point is
  3188. * sliced, its children are also offset.
  3189. *
  3190. * @sample highcharts/plotoptions/sunburst-sliced
  3191. * Sliced sunburst
  3192. *
  3193. * @type {boolean}
  3194. * @default false
  3195. * @since 6.0.4
  3196. * @product highcharts
  3197. * @apioption series.sunburst.data.sliced
  3198. */
  3199. ''; // detach doclets above
  3200. /**
  3201. * @private
  3202. * @class
  3203. * @name Highcharts.seriesTypes.sunburst
  3204. *
  3205. * @augments Highcharts.Series
  3206. */
  3207. BaseSeries.seriesType('sunburst', 'treemap', sunburstOptions, sunburstSeries, sunburstPoint);
  3208. });
  3209. _registerModule(_modules, 'masters/modules/sunburst.src.js', [], function () {
  3210. });
  3211. }));