UNPKG

highcharts

Version:
13 lines 22.2 kB
!/** * Highcharts JS v13.0.1 (2026-08-17) * Treegraph chart series type * @module highcharts/modules/treegraph * @requires highcharts * @requires highcharts/modules/treemap * * (c) 2010-2026 Highsoft AS * Authors: Paweł Lysy, Grzegorz Blachliński * * A commercial license may be required depending on use, * see www.highcharts.com/license */function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.SeriesRegistry,t._Highcharts.SVGRenderer,t._Highcharts.Point,t._Highcharts.Color,t._Highcharts.SVGElement):"function"==typeof define&&define.amd?define("highcharts/modules/treegraph",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry,t.SVGRenderer,t.Point,t.Color,t.SVGElement)}):"object"==typeof exports?exports["highcharts/modules/treegraph"]=e(t._Highcharts,t._Highcharts.SeriesRegistry,t._Highcharts.SVGRenderer,t._Highcharts.Point,t._Highcharts.Color,t._Highcharts.SVGElement):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry,t.Highcharts.SVGRenderer,t.Highcharts.Point,t.Highcharts.Color,t.Highcharts.SVGElement)}("u"<typeof window?this:window,(t,e,i,s,o,l)=>(()=>{"use strict";var r,n={620(t){t.exports=o},260(t){t.exports=s},28(t){t.exports=l},540(t){t.exports=i},512(t){t.exports=e},944(e){e.exports=t}};let a={};function h(t){let e=a[t];if(void 0!==e)return e.exports;let i=a[t]={exports:{}};return n[t](i,i.exports,h),i.exports}h.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return h.d(e,{a:e}),e},h.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var s=e[i++],o=e[i++];h.o(t,s)?0===o&&i++:0===o?Object.defineProperty(t,s,{enumerable:!0,value:e[i++]}):Object.defineProperty(t,s,{enumerable:!0,get:o})}else for(var s in e)h.o(e,s)&&!h.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let d={};h.d(d,{default:()=>z});var p=h(944),c=h.n(p);function u(t){let{x1:e,y1:i,x2:s,y2:o,bendAt:l,width:r=0,inverted:n=!1,radius:a,parentVisible:h}=t;if(h){let t=l??r/2;return f([["M",e,i],["L",e+t*(n?-1:1),i],["L",e+t*(n?-1:1),o],["L",s,o]],a)}return[["M",e,i],["L",e,i],["C",e,i,e,o,e,o],["L",e,o],["C",e,i,e,o,e,o],["L",e,o]]}function f(t,e){let i=[];for(let s=0;s<t.length;s++){let o=t[s][1],l=t[s][2];if("number"==typeof o&&"number"==typeof l)if(0===s)i.push(["M",o,l]);else if(s===t.length-1)i.push(["L",o,l]);else if(e){let r=t[s-1],n=t[s+1];if(r&&n){let t=r[1],s=r[2],a=n[1],h=n[2];if("number"==typeof t&&"number"==typeof a&&"number"==typeof s&&"number"==typeof h&&t!==a&&s!==h){let r=t<a?1:-1,n=s<h?1:-1;i.push(["L",o-r*Math.min(Math.abs(o-t),e),l-n*Math.min(Math.abs(l-s),e)],["C",o,l,o,l,o+r*Math.min(Math.abs(o-a),e),l+n*Math.min(Math.abs(l-h),e)])}}}else i.push(["L",o,l])}return i}var g=h(512),v=h.n(g),b=h(540),m=h.n(b);let{seriesTypes:{treemap:{prototype:{NodeClass:y}}}}=v(),x=class extends y{constructor(){super(...arguments),this.mod=0,this.shift=0,this.change=0,this.children=[],this.preX=0,this.hidden=!1,this.wasVisited=!1,this.collapsed=!1}nextLeft(){return this.getLeftMostChild()||this.thread}nextRight(){return this.getRightMostChild()||this.thread}getAncestor(t,e){return t.ancestor.children[0]===this.children[0]?t.ancestor:e}getLeftMostSibling(){let t=this.getParent();if(t){for(let e of t.children)if(e&&e.point.visible)return e}}hasChildren(){let t=this.children;for(let e=0;e<t.length;e++)if(t[e].point.visible)return!0;return!1}getLeftSibling(){let t=this.getParent();if(t){let e=t.children;for(let t=this.relativeXPosition-1;t>=0;t--)if(e[t]&&e[t].point.visible)return e[t]}}getLeftMostChild(){let t=this.children;for(let e=0;e<t.length;e++)if(t[e].point.visible)return t[e]}getRightMostChild(){let t=this.children;for(let e=t.length-1;e>=0;e--)if(t[e].point.visible)return t[e]}getParent(){return this.parentNode}getFirstChild(){let t=this.children;for(let e=0;e<t.length;e++)if(t[e].point.visible)return t[e]}};var L=h(260),k=h.n(L);let{seriesTypes:{treemap:{prototype:{pointClass:P}}}}=v();class C extends P{constructor(){super(...arguments),this.dataLabelOnHidden=!0,this.isLink=!1,this.setState=k().prototype.setState}draw(){super.draw.apply(this,arguments);let t=this.graphic;t&&t.animate({visibility:this.visible?"inherit":"hidden"}),this.renderCollapseButton()}renderCollapseButton(){let t=this.series,e=this.graphic&&this.graphic.parentGroup,i=t.mapOptionsToLevel[this.node.level||0]||{},s=(0,p.merge)(t.options.collapseButton,i.collapseButton,this.options.collapseButton),{width:o,height:l,shape:r,style:n}=s,a=this.series.chart,h=this.visible&&(this.collapsed||!s.onlyOnHover||"hover"===this.state)?1:0;if(this.shapeArgs)if(this.collapseButtonOptions=s,this.collapseButton)if(this.node.children.length&&s.enabled){let{x:t,y:e}=this.getCollapseBtnPosition(s);this.collapseButton.attr({text:this.collapsed?"+":"-",rotation:90*!!a.inverted,rotationOriginX:o/2,rotationOriginY:l/2,visibility:this.visible?"inherit":"hidden"}).animate({x:t,y:e,opacity:h})}else this.collapseButton.destroy(),delete this.collapseButton;else{if(!this.node.children.length||!s.enabled)return;let{x:t,y:i}=this.getCollapseBtnPosition(s),d=s.fillColor||this.color||"var(--highcharts-neutral-color-20)";this.collapseButton=a.renderer.label(this.collapsed?"+":"-",t,i,r).attr({height:l-4,width:o-4,padding:2,fill:d,rotation:90*!!a.inverted,rotationOriginX:o/2,rotationOriginY:l/2,stroke:s.lineColor||"var(--highcharts-background-color)","stroke-width":s.lineWidth,"text-align":"center",align:"center",zIndex:1,opacity:h,visibility:this.visible?"inherit":"hidden"}).addClass("highcharts-tracker").addClass("highcharts-collapse-button").removeClass("highcharts-no-tooltip").css((0,p.merge)({color:"string"==typeof d?a.renderer.getContrast(d):"var(--highcharts-neutral-color-80)"},n)).add(e),this.collapseButton.element.point=this}}toggleCollapse(t){let e=this.series;this.update({collapsed:t??!this.collapsed},!1,void 0,!1),(0,p.fireEvent)(e,"toggleCollapse"),e.redraw()}destroy(){this.collapseButton&&(this.collapseButton.destroy(),delete this.collapseButton,this.collapseButton=void 0),this.linkToParent&&(this.linkToParent.destroy(),delete this.linkToParent),super.destroy.apply(this,arguments)}getCollapseBtnPosition(t){let e=this.series.chart.inverted,i=t.width,s=t.height,{x:o=0,y:l=0,width:r=0,height:n=0}=this.shapeArgs||{};return{x:o+t.x+(e?-(.3*s):r+-.3*i),y:l+n/2-s/2+t.y}}}(0,p.addEvent)(C,"mouseOut",function(){let t=this.collapseButton,e=this.collapseButtonOptions;t&&e?.onlyOnHover&&!this.collapsed&&t.animate({opacity:0})}),(0,p.addEvent)(C,"mouseOver",function(){this.collapseButton&&this.visible&&this.collapseButton.animate({opacity:1},this.series.options.states?.hover?.animation)}),(0,p.addEvent)(C,"click",function(){this.toggleCollapse()});var T=h(620),O=h.n(T);let M={getColor:function(t,e){let i,s,o,l,r,n,a=e.index,h=e.mapOptionsToLevel,d=e.parentColor,c=e.parentColorIndex,u=e.series,f=e.colors,g=e.siblings,v=u.points,b=u.chart.options.chart;if(t){let m;i=v[t.i],s=h[t.level]||{},i&&s.colorByPoint&&(l=i.index%(f?f.length:b.colorCount),o=f&&f[l]),u.chart.styledMode||(r=(0,p.pick)(i&&i.options.color,s&&s.color,o,d&&((m=s&&s.colorVariation)&&"brightness"===m.key&&a&&g?O().parse(d).brighten(m.to*(a/g)).get():d),u.color)),n=(0,p.pick)(i&&i.options.colorIndex,s&&s.colorIndex,l,c,e.colorIndex)}return{color:r,colorIndex:n}},getLevelOptions:function(t){let e,i,s,o,l,r,n={};if((0,p.isObject)(t))for(o=(0,p.isNumber)(t.from)?t.from:1,r=t.levels,i={},e=(0,p.isObject)(t.defaults)?t.defaults:{},(0,p.isArray)(r)&&(i=r.reduce((t,i)=>{let s,l,r;return(0,p.isObject)(i)&&(0,p.isNumber)(i.level)&&(r=(0,p.merge)({},i),l=(0,p.pick)(r.levelIsConstant,e.levelIsConstant),delete r.levelIsConstant,delete r.level,s=i.level+(l?0:o-1),(0,p.isObject)(t[s])?(0,p.merge)(!0,t[s],r):t[s]=r),t},{})),l=(0,p.isNumber)(t.to)?t.to:1,s=0;s<=l;s++)n[s]=(0,p.merge)({},e,(0,p.isObject)(i[s])?i[s]:{});return n},getNodeWidth:function(t,e){let{chart:i,options:s}=t,{nodeDistance:o=0,nodeWidth:l=0}=s,{plotSizeX:r=1}=i;if("auto"===l){if("string"==typeof o&&/%$/.test(o))return r/(e+parseFloat(o)/100*(e-1));let t=Number(o);return(r+t)/(e||1)-t}return(0,p.relativeLength)(l,r)},setTreeValues:function t(e,i){let s=i.before,o=i.idRoot,l=i.mapIdToNode[o],r=!1!==i.levelIsConstant,n=i.points[e.i],a=n&&n.options||{},h=[],d=0;e.levelDynamic=e.level-(r?0:l.level),e.name=(0,p.pick)(n&&n.name,""),e.visible=o===e.id||!0===i.visible,"function"==typeof s&&(e=s(e,i)),e.children.forEach((s,o)=>{let l=(0,p.extend)({},i);(0,p.extend)(l,{index:o,siblings:e.children.length,visible:e.visible}),s=t(s,l),h.push(s),s.visible&&(d+=s.val)});let c=(0,p.pick)(a.value,d);return e.visible=c>=0&&(d>0||e.visible),e.children=h,e.childrenTotal=d,e.isLeaf=e.visible&&!d,e.val=c,e},updateRootId:function(t){let e,i;return(0,p.isObject)(t)&&(i=(0,p.isObject)(t.options)?t.options:{},e=(0,p.pick)(t.rootNode,i.rootId,""),(0,p.isObject)(t.userOptions)&&(t.userOptions.rootId=e),t.rootNode=e),e}},{seriesTypes:{column:{prototype:{pointClass:N}}}}=v(),S=class extends N{constructor(t,e,i,s){super(t,e,i),this.dataLabelOnNull=!0,this.formatPrefix="link",this.isLink=!0,this.node={},this.formatPrefix="link",this.dataLabelOnNull=!0,s&&(this.fromNode=s.node.parentNode.point,this.visible=s.visible,this.toNode=s,this.id=this.toNode.id+"-"+this.fromNode.id)}update(t,e,i,s){let o={id:this.id,formatPrefix:this.formatPrefix};k().prototype.update.call(this,t,!this.isLink&&e,i,s),this.visible=this.toNode.visible,(0,p.extend)(this,o),(0,p.pick)(e,!0)&&this.series.chart.redraw(i)}};class X{static createDummyNode(t,e,i){let s=new x;return s.id=t.id+"-"+i,s.ancestor=t,s.children.push(e),s.parent=t.id,s.parentNode=t,s.point=e.point,s.level=e.level-i,s.relativeXPosition=e.relativeXPosition,s.visible=e.visible,t.children[e.relativeXPosition]=s,e.oldParentNode=t,e.relativeXPosition=0,e.parentNode=s,e.parent=s.id,s}calculatePositions(t){let e=t.nodeList;this.resetValues(e);let i=t.tree;i&&(this.calculateRelativeX(i,0),this.beforeLayout(e),this.firstWalk(i),this.secondWalk(i,-i.preX),this.afterLayout(e))}beforeLayout(t){for(let e of t)for(let t of e.children)if(t&&t.level-e.level>1){let i=t.level-e.level-1;for(;i>0;)t=X.createDummyNode(e,t,i),i--}}resetValues(t){for(let e of t)e.mod=0,e.ancestor=e,e.shift=0,e.thread=void 0,e.change=0,e.preX=0}calculateRelativeX(t,e){let i=t.children;for(let t=0,e=i.length;t<e;++t)this.calculateRelativeX(i[t],t);t.relativeXPosition=e}firstWalk(t){let e;if(t.hasChildren()){let i=t.getLeftMostChild();for(let e of t.children)this.firstWalk(e),i=this.apportion(e,i);this.executeShifts(t);let s=t.getLeftMostChild(),o=t.getRightMostChild(),l=(s.preX+o.preX)/2;(e=t.getLeftSibling())?(t.preX=e.preX+1,t.mod=t.preX-l):t.preX=l}else(e=t.getLeftSibling())?(t.preX=e.preX+1,t.mod=t.preX):t.preX=0}secondWalk(t,e){for(let i of(t.yPosition=t.preX+e,t.xPosition=t.point?.x??t.level,t.children))this.secondWalk(i,e+t.mod)}executeShifts(t){let e=0,i=0;for(let s=t.children.length-1;s>=0;s--){let o=t.children[s];o.preX+=e,o.mod+=e,i+=o.change,e+=o.shift+i}}apportion(t,e){let i=t.getLeftSibling();if(i){let s=t,o=t,l=i,r=s.getLeftMostSibling(),n=s.mod,a=o.mod,h=l.mod,d=r.mod;for(;l&&l.nextRight()&&s&&s.nextLeft();){l=l.nextRight(),r=r.nextLeft(),s=s.nextLeft(),(o=o.nextRight()).ancestor=t;let i=l.preX+h-(s.preX+n)+1;i>0&&(this.moveSubtree(t.getAncestor(l,e),t,i),n+=i,a+=i),h+=l.mod,n+=s.mod,d+=r.mod,a+=o.mod}l&&l.nextRight()&&!o.nextRight()&&(o.thread=l.nextRight(),o.mod+=h-a),s&&s.nextLeft()&&!r.nextLeft()&&(r.thread=s.nextLeft(),r.mod+=n-d),e=t}return e}moveSubtree(t,e,i){let s=e.relativeXPosition-t.relativeXPosition;e.change-=i/s,e.shift+=i,e.preX+=i,e.mod+=i,t.change+=i/s}afterLayout(t){for(let e of t)e.oldParentNode&&(e.relativeXPosition=e.parentNode.relativeXPosition,e.parent=e.oldParentNode.parent,e.parentNode=e.oldParentNode,e.oldParentNode.children.splice(e.relativeXPosition,1,e),e.oldParentNode=void 0)}}var w=h(28),A=h.n(w);let{composed:B,deg2rad:R}=c(),{getLinkPath:H}={applyRadius:f,getLinkPath:{default:u,orthogonal:u,straight:function(t){let{x1:e,y1:i,x2:s,y2:o,width:l=0,inverted:r=!1,parentVisible:n}=t;return n?[["M",e,i],["L",e+l*(r?-1:1),o],["L",s,o]]:[["M",e,i],["L",e,o],["L",e,o]]},curved:function(t){let{x1:e,y1:i,x2:s,y2:o,offset:l=0,width:r=0,inverted:n=!1,parentVisible:a}=t;return a?[["M",e,i],["C",e+l,i,e-l+r*(n?-1:1),o,e+r*(n?-1:1),o],["L",s,o]]:[["M",e,i],["C",e,i,e,o,e,o],["L",s,o]]}}},{series:{prototype:W},seriesTypes:{treemap:I,column:E}}=v(),{prototype:{symbols:j}}=m(),{getLevelOptions:V,getNodeWidth:_}=M;r=A(),(0,p.pushUnique)(B,"TextPath")&&((0,p.addEvent)(r,"afterGetBBox",function(t){let e=t.bBox,i=this.element?.querySelector("textPath");if(i){let t=[],{b:s,h:o}=this.renderer.fontMetrics(this.element),l=o-s,r=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),n=i.innerHTML.replace(r,"").split(/<tspan class="highcharts-br"[^>]*>/),a=n.length,h=(t,e)=>{let{x:o,y:r}=e,n=(i.getRotationOfChar(t)-90)*R,a=Math.cos(n),h=Math.sin(n);return[[o-l*a,r-l*h],[o+s*a,r+s*h]]};for(let e=0,s=0;s<a;s++){let o=n[s].length;for(let l=0;l<o;l+=5)try{let o=e+l+s,[r,n]=h(o,i.getStartPositionOfChar(o));0===l?(t.push(n),t.push(r)):(0===s&&t.unshift(n),s===a-1&&t.push(r))}catch{break}e+=o-1;try{let o=e+s,l=i.getEndPositionOfChar(o),[r,n]=h(o,l);t.unshift(n),t.unshift(r)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}),(0,p.addEvent)(r,"beforeAddingDataLabel",function(t){let e=t.labelOptions,i=t.point,s=e[i.formatPrefix+"TextPath"]||e.textPath;s&&!e.useHTML&&(this.setTextPath(i.getDataLabelPath?.(this)||i.graphic,s),i.dataLabelPath&&!s.enabled&&(i.dataLabelPath=i.dataLabelPath.destroy()))}),r.prototype.setTextPath=r.prototype.setTextPath??function(t,e){let i=this.renderer.url,s=this.text||this,o=s.textPath,{attributes:l,enabled:r}=(0,p.merge)({enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);if(t=t||o&&o.path,o?.undo(),t&&r){let e=(0,p.addEvent)(s,"afterModifyTree",e=>{if(t&&r){let o=t.attr("id");o||t.attr("id",o=(0,p.uniqueKey)());let r={x:0,y:0};(0,p.defined)(l.dx)&&(r.dx=l.dx,delete l.dx),(0,p.defined)(l.dy)&&(r.dy=l.dy,delete l.dy),s.attr(r),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let n=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:(0,p.extend)(l,{"text-anchor":l.textAnchor,href:`${i}#${o}`}),children:n}}});s.textPath={path:t,undo:e}}else s.attr({dx:0,dy:0}),delete s.textPath;return this.added&&(s.textCache="",this.renderer.buildText(s)),this});class D extends I{constructor(){super(...arguments),this.nodeList=[],this.links=[]}init(){super.init.apply(this,arguments),this.layoutAlgorithm=new X;let t=this,e=this.chart.labelCollectors;e.some(t=>"collectorFunc"===t.name)||e.push(function(){let e=[];if(t.options.dataLabels&&!(0,p.splat)(t.options.dataLabels)[0].allowOverlap)for(let i of t.links||[])i.dataLabel&&e.push(i.dataLabel);return e})}getLayoutModifiers(){let t=this.chart,e=this,i=t.plotSizeX,s=t.plotSizeY,o=e.options.link?.lineWidth||0,l=(0,p.arrayMax)(this.points.map(t=>t.node.xPosition)),r=1/0,n=-1/0,a=1/0,h=-1/0,d=0,c=0,u=0,f=0;this.points.forEach(t=>{if(this.options.fillSpace&&!t.visible)return;let g=t.node,v=e.mapOptionsToLevel[t.node.level]||{},b=(0,p.merge)(this.options.marker,v.marker,t.options.marker),m=b.width??_(this,l),y=(0,p.relativeLength)(b.radius||0,Math.min(i,s)),x=Math.max(b.lineWidth||0,o),L=b.symbol,k="circle"!==L&&b.height?(0,p.relativeLength)(b.height,s):2*y,P="circle"!==L&&m?(0,p.relativeLength)(m,i):2*y;g.nodeSizeX=P,g.nodeSizeY=k,g.xPosition<=r&&(r=g.xPosition,c=Math.max(P+x,c)),g.xPosition>=n&&(n=g.xPosition,d=Math.max(P+x,d)),g.yPosition<=a&&(a=g.yPosition,f=Math.max(k+x,f)),g.yPosition>=h&&(h=g.yPosition,u=Math.max(k+x,u))});let g=h===a?1:(s-(f+u)/2)/(h-a),v=h===a?s/2:-g*a+f/2,b=n===r?1:(i-(d+d)/2)/(n-r),m=n===r?i/2:-b*r+c/2;return{ax:b,bx:m,ay:g,by:v}}getLinks(){let t=this,e=[];return this.data.forEach(i=>{let s=t.mapOptionsToLevel[i.node.level??0]||{};if(i.node.parent){let o=(0,p.merge)(s,i.options);if(!i.linkToParent||i.linkToParent.condemned){let e=new t.LinkClass(t,o,void 0,i);i.linkToParent=e}else i.collapsed=i.collapsed??(this.mapOptionsToLevel[i.node.level]||{}).collapsed,i.linkToParent.visible=i.linkToParent.toNode.visible;i.linkToParent.index=e.push(i.linkToParent)-1}else i.linkToParent&&(t.links.splice(i.linkToParent.index),i.linkToParent.destroy(),delete i.linkToParent)}),e}buildTree(t,e,i,s,o){let l=this.points[e];return i=l?.level??i,super.buildTree.call(this,t,e,i,s,o)}markerAttribs(){return{}}setCollapsedStatus(t,e){let i=t.point;i&&(i.collapsed=i.collapsed??(this.mapOptionsToLevel[t.level]||{}).collapsed,i.visible=e,e=!1!==e&&!i.collapsed),t.children.forEach(t=>{this.setCollapsedStatus(t,e)})}drawTracker(){E.prototype.drawTracker.apply(this,arguments),E.prototype.drawTracker.call(this,this.links)}translate(){let t=this.options,e=M.updateRootId(this),i;W.translate.call(this);let s=this.tree=this.getTree();i=this.nodeMap[e],""===e||i&&i.children.length||(this.setRootNode("",!1),e=this.rootNode,i=this.nodeMap[e]),this.mapOptionsToLevel=V({from:i.level+1,levels:t.levels,to:s.height,defaults:{levelIsConstant:this.options.levelIsConstant,colorByPoint:t.colorByPoint}}),this.setCollapsedStatus(s,!0),this.links=this.getLinks(),this.setTreeValues(s),this.layoutAlgorithm.calculatePositions(this),this.layoutModifier=this.getLayoutModifiers(),this.points.forEach(t=>{this.translateNode(t)}),this.points.forEach(t=>{t.linkToParent&&this.translateLink(t.linkToParent)}),t.colorByPoint||this.setColorRecursive(this.tree)}translateLink(t){let e=t.fromNode,i=t.toNode,s=this.options.link?.lineWidth||0,o=this.options.link?.curveFactor??.5,l=i.x!==i.node.level||e.x!==e.node.level,r=t.options.link?.type??this.options.link?.type??"default";if(e.shapeArgs&&i.shapeArgs){let n=e.shapeArgs.width||0,a=this.chart.inverted,h=(0,p.crisp)((e.shapeArgs.y||0)+(e.shapeArgs.height||0)/2,s),d=(0,p.crisp)((i.shapeArgs.y||0)+(i.shapeArgs.height||0)/2,s),c=(0,p.crisp)((e.shapeArgs.x||0)+n,s),u=(0,p.crisp)(i.shapeArgs.x||0,s);a&&(c-=Math.round(n),u+=Math.round(i.shapeArgs.width||0));let f=i.node.xPosition-e.node.xPosition,g=Math.abs(u-c)+n,v=(l?g:g/f)-n,b=(0,p.crisp)((u+c)/2,s),m=(0,p.relativeLength)(t.options.link?.bendAt??this.options.link?.bendAt??"50%",g-n);t.shapeType="path",t.plotX=b,t.plotY=d,t.shapeArgs={d:H[r]({x1:c,y1:h,x2:u,y2:d,width:v,offset:v*o*(a?-1:1),inverted:a,parentVisible:i.visible,radius:this.options.link?.radius,bendAt:m})},t.dlBox={x:(c+u)/2,y:(h+d)/2,height:s,width:0},t.tooltipPos=a?[(this.chart.plotSizeY||0)-t.dlBox.y,(this.chart.plotSizeX||0)-t.dlBox.x]:[t.dlBox.x,t.dlBox.y]}}drawNodeLabels(t){let e,i,s=this.mapOptionsToLevel;for(let o of t){if(i=s[o.node.level],e={style:{}},i&&i.dataLabels&&(e=(0,p.merge)(e,i.dataLabels),this.hasDataLabels=()=>!0),o.shapeArgs&&this.options.dataLabels){let t={},{width:i=0,height:s=0}=o.shapeArgs;this.chart.inverted&&([i,s]=[s,i]),(0,p.splat)(this.options.dataLabels)[0].style?.width||(t.width=`${i}px`),(0,p.splat)(this.options.dataLabels)[0].style?.lineClamp||(t.lineClamp=Math.floor(s/16)),(0,p.extend)(e.style,t),o.dataLabel?.css(t)}o.dlOptions=(0,p.merge)(e,o.options.dataLabels)}W.drawDataLabels.call(this,t)}alignDataLabel(t,e){let i=t.visible;t.visible=!0,super.alignDataLabel.apply(this,arguments),e.animate({opacity:+(!1!==i)},void 0,function(){i||e.hide()}),t.visible=i}drawDataLabels(){this.options.dataLabels&&(this.options.dataLabels=(0,p.splat)(this.options.dataLabels),this.drawNodeLabels(this.points),W.drawDataLabels.call(this,this.links))}destroy(){if(this.links){for(let t of this.links)t.destroy(!0);this.links.length=0}return W.destroy.apply(this,arguments)}pointAttribs(t,e){let i=t&&this.mapOptionsToLevel[t.node.level]||{},s=t?.options||{},o=i.states?.[e||"normal"]||{};t&&(t.options.marker=(0,p.merge)(this.options.marker,i.marker,t.options.marker));let l=o.link?.color??s.link?.color??i.link?.color??this.options.link?.color,r=o.link?.lineWidth??s.link?.lineWidth??i.link?.lineWidth??this.options.link?.lineWidth,n=W.pointAttribs.call(this,t,e);return t&&(t.isLink&&(n.stroke=l,n["stroke-width"]=r,delete n.fill),t.visible||(n.opacity=0)),n}drawPoints(){I.prototype.drawPoints.apply(this,arguments),E.prototype.drawPoints.call(this,this.links)}translateNode(t){let e=this.chart,{node:i,plotX:s=0}=t,o=e.plotSizeY,l=e.plotSizeX,{ax:r,bx:n,ay:a,by:h}=this.layoutModifier,d=this.isCartesian?e.inverted?l-s:s:r*i.xPosition+n,c=a*i.yPosition+h,u=this.mapOptionsToLevel[i.level]||{},f=(0,p.merge)(this.options.marker,u.marker,t.options.marker).symbol,g=i.nodeSizeY,v=i.nodeSizeX,b=this.options.reversed,m=i.x=e.inverted?l-v/2-d:d-v/2,y=i.y=b?c-g/2:o-c-g/2,x=t.options.borderRadius??u.borderRadius??this.options.borderRadius,L=j[f||"circle"];if(void 0===L?(t.hasImage=!0,t.shapeType="image",t.imageUrl=f.match(/^url\((.*?)\)$/)[1]):t.shapeType="path",!t.visible&&t.linkToParent){let e=t.linkToParent.fromNode;if(e){let{x:i=0,y:s=0,width:o=0,height:l=0}=e.shapeArgs||{};t.shapeArgs||(t.shapeArgs={}),t.hasImage||(0,p.extend)(t.shapeArgs,{d:L(i,s,o,l,x?{r:x}:void 0)}),(0,p.extend)(t.shapeArgs,{x:i,y:s}),t.plotX=e.plotX,t.plotY=e.plotY}}else t.plotX=m,t.plotY=y,t.shapeArgs={x:m,y:y,width:v,height:g,cursor:t.node.isLeaf?"default":"pointer"},t.hasImage||(t.shapeArgs.d=L(m,y,v,g,x?{r:x}:void 0));t.tooltipPos=e.inverted?[o-y-g/2,l-m-v/2]:[m+v/2,y]}}D.defaultOptions=(0,p.merge)(I.defaultOptions,{reversed:!1,marker:{radius:10,lineWidth:0,symbol:"circle",fillOpacity:1,states:{}},link:{color:"var(--highcharts-neutral-color-60)",cursor:"default",lineWidth:1,radius:10,type:"curved"},collapseButton:{onlyOnHover:!0,enabled:!0,lineWidth:1,x:0,y:0,height:18,width:18,shape:"circle",style:{cursor:"pointer",fontWeight:"bold",fontSize:"1em"}},fillSpace:!1,tooltip:{linkFormat:"{point.fromNode.id} → {point.toNode.id}",pointFormat:"{point.id}"},dataLabels:{defer:!0,linkTextPath:{attributes:{startOffset:"50%"}},enabled:!0,linkFormatter:()=>"",pointFormat:void 0,padding:5,style:{textOverflow:"none"}},nodeDistance:30,nodeWidth:void 0}),(0,p.extend)(D.prototype,{forceDL:!0,pointClass:C,NodeClass:x,LinkClass:S,isCartesian:!1}),v().registerSeriesType("treegraph",D);let z=c();return d.default})());