highcharts
Version:
JavaScript charting framework
13 lines • 21.3 kB
JavaScript
/**
* 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
*/import*as t from"../highcharts.js";let e={};e.n=t=>{let i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{if(Array.isArray(i))for(var s=0;s<i.length;){var o=i[s++],l=i[s++];e.o(t,o)?0===l&&s++:0===l?Object.defineProperty(t,o,{enumerable:!0,value:i[s++]}):Object.defineProperty(t,o,{enumerable:!0,get:l})}else for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var s,o=e.n(i);function l(t){let{x1:e,y1:i,x2:s,y2:o,bendAt:l,width:n=0,inverted:a=!1,radius:h,parentVisible:d}=t;if(d){let t=l??n/2;return r([["M",e,i],["L",e+t*(a?-1:1),i],["L",e+t*(a?-1:1),o],["L",s,o]],h)}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 r(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}let n=t.default.SeriesRegistry;var a=e.n(n);let h=t.default.SVGRenderer;var d=e.n(h);let{seriesTypes:{treemap:{prototype:{NodeClass:p}}}}=a(),c=class extends p{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]}},u=t.default.Point;var f=e.n(u);let{seriesTypes:{treemap:{prototype:{pointClass:g}}}}=a();class v extends g{constructor(){super(...arguments),this.dataLabelOnHidden=!0,this.isLink=!1,this.setState=f().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,s=t.mapOptionsToLevel[this.node.level||0]||{},o=(0,i.merge)(t.options.collapseButton,s.collapseButton,this.options.collapseButton),{width:l,height:r,shape:n,style:a}=o,h=this.series.chart,d=this.visible&&(this.collapsed||!o.onlyOnHover||"hover"===this.state)?1:0;if(this.shapeArgs)if(this.collapseButtonOptions=o,this.collapseButton)if(this.node.children.length&&o.enabled){let{x:t,y:e}=this.getCollapseBtnPosition(o);this.collapseButton.attr({text:this.collapsed?"+":"-",rotation:90*!!h.inverted,rotationOriginX:l/2,rotationOriginY:r/2,visibility:this.visible?"inherit":"hidden"}).animate({x:t,y:e,opacity:d})}else this.collapseButton.destroy(),delete this.collapseButton;else{if(!this.node.children.length||!o.enabled)return;let{x:t,y:s}=this.getCollapseBtnPosition(o),p=o.fillColor||this.color||"var(--highcharts-neutral-color-20)";this.collapseButton=h.renderer.label(this.collapsed?"+":"-",t,s,n).attr({height:r-4,width:l-4,padding:2,fill:p,rotation:90*!!h.inverted,rotationOriginX:l/2,rotationOriginY:r/2,stroke:o.lineColor||"var(--highcharts-background-color)","stroke-width":o.lineWidth,"text-align":"center",align:"center",zIndex:1,opacity:d,visibility:this.visible?"inherit":"hidden"}).addClass("highcharts-tracker").addClass("highcharts-collapse-button").removeClass("highcharts-no-tooltip").css((0,i.merge)({color:"string"==typeof p?h.renderer.getContrast(p):"var(--highcharts-neutral-color-80)"},a)).add(e),this.collapseButton.element.point=this}}toggleCollapse(t){let e=this.series;this.update({collapsed:t??!this.collapsed},!1,void 0,!1),(0,i.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,i.addEvent)(v,"mouseOut",function(){let t=this.collapseButton,e=this.collapseButtonOptions;t&&e?.onlyOnHover&&!this.collapsed&&t.animate({opacity:0})}),(0,i.addEvent)(v,"mouseOver",function(){this.collapseButton&&this.visible&&this.collapseButton.animate({opacity:1},this.series.options.states?.hover?.animation)}),(0,i.addEvent)(v,"click",function(){this.toggleCollapse()});let b=t.default.Color;var m=e.n(b);let y={getColor:function(t,e){let s,o,l,r,n,a,h=e.index,d=e.mapOptionsToLevel,p=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 y;s=v[t.i],o=d[t.level]||{},s&&o.colorByPoint&&(r=s.index%(f?f.length:b.colorCount),l=f&&f[r]),u.chart.styledMode||(n=(0,i.pick)(s&&s.options.color,o&&o.color,l,p&&((y=o&&o.colorVariation)&&"brightness"===y.key&&h&&g?m().parse(p).brighten(y.to*(h/g)).get():p),u.color)),a=(0,i.pick)(s&&s.options.colorIndex,o&&o.colorIndex,r,c,e.colorIndex)}return{color:n,colorIndex:a}},getLevelOptions:function(t){let e,s,o,l,r,n,a={};if((0,i.isObject)(t))for(l=(0,i.isNumber)(t.from)?t.from:1,n=t.levels,s={},e=(0,i.isObject)(t.defaults)?t.defaults:{},(0,i.isArray)(n)&&(s=n.reduce((t,s)=>{let o,r,n;return(0,i.isObject)(s)&&(0,i.isNumber)(s.level)&&(n=(0,i.merge)({},s),r=(0,i.pick)(n.levelIsConstant,e.levelIsConstant),delete n.levelIsConstant,delete n.level,o=s.level+(r?0:l-1),(0,i.isObject)(t[o])?(0,i.merge)(!0,t[o],n):t[o]=n),t},{})),r=(0,i.isNumber)(t.to)?t.to:1,o=0;o<=r;o++)a[o]=(0,i.merge)({},e,(0,i.isObject)(s[o])?s[o]:{});return a},getNodeWidth:function(t,e){let{chart:s,options:o}=t,{nodeDistance:l=0,nodeWidth:r=0}=o,{plotSizeX:n=1}=s;if("auto"===r){if("string"==typeof l&&/%$/.test(l))return n/(e+parseFloat(l)/100*(e-1));let t=Number(l);return(n+t)/(e||1)-t}return(0,i.relativeLength)(r,n)},setTreeValues:function t(e,s){let o=s.before,l=s.idRoot,r=s.mapIdToNode[l],n=!1!==s.levelIsConstant,a=s.points[e.i],h=a&&a.options||{},d=[],p=0;e.levelDynamic=e.level-(n?0:r.level),e.name=(0,i.pick)(a&&a.name,""),e.visible=l===e.id||!0===s.visible,"function"==typeof o&&(e=o(e,s)),e.children.forEach((o,l)=>{let r=(0,i.extend)({},s);(0,i.extend)(r,{index:l,siblings:e.children.length,visible:e.visible}),o=t(o,r),d.push(o),o.visible&&(p+=o.val)});let c=(0,i.pick)(h.value,p);return e.visible=c>=0&&(p>0||e.visible),e.children=d,e.childrenTotal=p,e.isLeaf=e.visible&&!p,e.val=c,e},updateRootId:function(t){let e,s;return(0,i.isObject)(t)&&(s=(0,i.isObject)(t.options)?t.options:{},e=(0,i.pick)(t.rootNode,s.rootId,""),(0,i.isObject)(t.userOptions)&&(t.userOptions.rootId=e),t.rootNode=e),e}},{seriesTypes:{column:{prototype:{pointClass:x}}}}=a(),L=class extends x{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,s,o){let l={id:this.id,formatPrefix:this.formatPrefix};f().prototype.update.call(this,t,!this.isLink&&e,s,o),this.visible=this.toNode.visible,(0,i.extend)(this,l),(0,i.pick)(e,!0)&&this.series.chart.redraw(s)}};class k{static createDummyNode(t,e,i){let s=new c;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=k.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)}}let P=t.default.SVGElement;var C=e.n(P);let{composed:T,deg2rad:O}=o(),{getLinkPath:M}={applyRadius:r,getLinkPath:{default:l,orthogonal:l,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:N},seriesTypes:{treemap:X,column:A}}=a(),{prototype:{symbols:B}}=d(),{getLevelOptions:S,getNodeWidth:w}=y;s=C(),(0,i.pushUnique)(T,"TextPath")&&((0,i.addEvent)(s,"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)*O,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,i.addEvent)(s,"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()))}),s.prototype.setTextPath=s.prototype.setTextPath??function(t,e){let s=this.renderer.url,o=this.text||this,l=o.textPath,{attributes:r,enabled:n}=(0,i.merge)({enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);if(t=t||l&&l.path,l?.undo(),t&&n){let e=(0,i.addEvent)(o,"afterModifyTree",e=>{if(t&&n){let l=t.attr("id");l||t.attr("id",l=(0,i.uniqueKey)());let n={x:0,y:0};(0,i.defined)(r.dx)&&(n.dx=r.dx,delete r.dx),(0,i.defined)(r.dy)&&(n.dy=r.dy,delete r.dy),o.attr(n),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let a=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:(0,i.extend)(r,{"text-anchor":r.textAnchor,href:`${s}#${l}`}),children:a}}});o.textPath={path:t,undo:e}}else o.attr({dx:0,dy:0}),delete o.textPath;return this.added&&(o.textCache="",this.renderer.buildText(o)),this});class R extends X{constructor(){super(...arguments),this.nodeList=[],this.links=[]}init(){super.init.apply(this,arguments),this.layoutAlgorithm=new k;let t=this,e=this.chart.labelCollectors;e.some(t=>"collectorFunc"===t.name)||e.push(function(){let e=[];if(t.options.dataLabels&&!(0,i.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,s=t.plotSizeX,o=t.plotSizeY,l=e.options.link?.lineWidth||0,r=(0,i.arrayMax)(this.points.map(t=>t.node.xPosition)),n=1/0,a=-1/0,h=1/0,d=-1/0,p=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,i.merge)(this.options.marker,v.marker,t.options.marker),m=b.width??w(this,r),y=(0,i.relativeLength)(b.radius||0,Math.min(s,o)),x=Math.max(b.lineWidth||0,l),L=b.symbol,k="circle"!==L&&b.height?(0,i.relativeLength)(b.height,o):2*y,P="circle"!==L&&m?(0,i.relativeLength)(m,s):2*y;g.nodeSizeX=P,g.nodeSizeY=k,g.xPosition<=n&&(n=g.xPosition,c=Math.max(P+x,c)),g.xPosition>=a&&(a=g.xPosition,p=Math.max(P+x,p)),g.yPosition<=h&&(h=g.yPosition,f=Math.max(k+x,f)),g.yPosition>=d&&(d=g.yPosition,u=Math.max(k+x,u))});let g=d===h?1:(o-(f+u)/2)/(d-h),v=d===h?o/2:-g*h+f/2,b=a===n?1:(s-(p+p)/2)/(a-n),m=a===n?s/2:-b*n+c/2;return{ax:b,bx:m,ay:g,by:v}}getLinks(){let t=this,e=[];return this.data.forEach(s=>{let o=t.mapOptionsToLevel[s.node.level??0]||{};if(s.node.parent){let l=(0,i.merge)(o,s.options);if(!s.linkToParent||s.linkToParent.condemned){let e=new t.LinkClass(t,l,void 0,s);s.linkToParent=e}else s.collapsed=s.collapsed??(this.mapOptionsToLevel[s.node.level]||{}).collapsed,s.linkToParent.visible=s.linkToParent.toNode.visible;s.linkToParent.index=e.push(s.linkToParent)-1}else s.linkToParent&&(t.links.splice(s.linkToParent.index),s.linkToParent.destroy(),delete s.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(){A.prototype.drawTracker.apply(this,arguments),A.prototype.drawTracker.call(this,this.links)}translate(){let t=this.options,e=y.updateRootId(this),i;N.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=S({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,s=t.toNode,o=this.options.link?.lineWidth||0,l=this.options.link?.curveFactor??.5,r=s.x!==s.node.level||e.x!==e.node.level,n=t.options.link?.type??this.options.link?.type??"default";if(e.shapeArgs&&s.shapeArgs){let a=e.shapeArgs.width||0,h=this.chart.inverted,d=(0,i.crisp)((e.shapeArgs.y||0)+(e.shapeArgs.height||0)/2,o),p=(0,i.crisp)((s.shapeArgs.y||0)+(s.shapeArgs.height||0)/2,o),c=(0,i.crisp)((e.shapeArgs.x||0)+a,o),u=(0,i.crisp)(s.shapeArgs.x||0,o);h&&(c-=Math.round(a),u+=Math.round(s.shapeArgs.width||0));let f=s.node.xPosition-e.node.xPosition,g=Math.abs(u-c)+a,v=(r?g:g/f)-a,b=(0,i.crisp)((u+c)/2,o),m=(0,i.relativeLength)(t.options.link?.bendAt??this.options.link?.bendAt??"50%",g-a);t.shapeType="path",t.plotX=b,t.plotY=p,t.shapeArgs={d:M[n]({x1:c,y1:d,x2:u,y2:p,width:v,offset:v*l*(h?-1:1),inverted:h,parentVisible:s.visible,radius:this.options.link?.radius,bendAt:m})},t.dlBox={x:(c+u)/2,y:(d+p)/2,height:o,width:0},t.tooltipPos=h?[(this.chart.plotSizeY||0)-t.dlBox.y,(this.chart.plotSizeX||0)-t.dlBox.x]:[t.dlBox.x,t.dlBox.y]}}drawNodeLabels(t){let e,s,o=this.mapOptionsToLevel;for(let l of t){if(s=o[l.node.level],e={style:{}},s&&s.dataLabels&&(e=(0,i.merge)(e,s.dataLabels),this.hasDataLabels=()=>!0),l.shapeArgs&&this.options.dataLabels){let t={},{width:s=0,height:o=0}=l.shapeArgs;this.chart.inverted&&([s,o]=[o,s]),(0,i.splat)(this.options.dataLabels)[0].style?.width||(t.width=`${s}px`),(0,i.splat)(this.options.dataLabels)[0].style?.lineClamp||(t.lineClamp=Math.floor(o/16)),(0,i.extend)(e.style,t),l.dataLabel?.css(t)}l.dlOptions=(0,i.merge)(e,l.options.dataLabels)}N.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,i.splat)(this.options.dataLabels),this.drawNodeLabels(this.points),N.drawDataLabels.call(this,this.links))}destroy(){if(this.links){for(let t of this.links)t.destroy(!0);this.links.length=0}return N.destroy.apply(this,arguments)}pointAttribs(t,e){let s=t&&this.mapOptionsToLevel[t.node.level]||{},o=t?.options||{},l=s.states?.[e||"normal"]||{};t&&(t.options.marker=(0,i.merge)(this.options.marker,s.marker,t.options.marker));let r=l.link?.color??o.link?.color??s.link?.color??this.options.link?.color,n=l.link?.lineWidth??o.link?.lineWidth??s.link?.lineWidth??this.options.link?.lineWidth,a=N.pointAttribs.call(this,t,e);return t&&(t.isLink&&(a.stroke=r,a["stroke-width"]=n,delete a.fill),t.visible||(a.opacity=0)),a}drawPoints(){X.prototype.drawPoints.apply(this,arguments),A.prototype.drawPoints.call(this,this.links)}translateNode(t){let e=this.chart,{node:s,plotX:o=0}=t,l=e.plotSizeY,r=e.plotSizeX,{ax:n,bx:a,ay:h,by:d}=this.layoutModifier,p=this.isCartesian?e.inverted?r-o:o:n*s.xPosition+a,c=h*s.yPosition+d,u=this.mapOptionsToLevel[s.level]||{},f=(0,i.merge)(this.options.marker,u.marker,t.options.marker).symbol,g=s.nodeSizeY,v=s.nodeSizeX,b=this.options.reversed,m=s.x=e.inverted?r-v/2-p:p-v/2,y=s.y=b?c-g/2:l-c-g/2,x=t.options.borderRadius??u.borderRadius??this.options.borderRadius,L=B[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:s=0,y:o=0,width:l=0,height:r=0}=e.shapeArgs||{};t.shapeArgs||(t.shapeArgs={}),t.hasImage||(0,i.extend)(t.shapeArgs,{d:L(s,o,l,r,x?{r:x}:void 0)}),(0,i.extend)(t.shapeArgs,{x:s,y:o}),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?[l-y-g/2,r-m-v/2]:[m+v/2,y]}}R.defaultOptions=(0,i.merge)(X.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,i.extend)(R.prototype,{forceDL:!0,pointClass:v,NodeClass:c,LinkClass:L,isCartesian:!1}),a().registerSeriesType("treegraph",R);let W=o();export{W as default};