highcharts
Version:
JavaScript charting framework
13 lines • 11.3 kB
JavaScript
/**
* Highcharts JS v12.6.0 (2026-04-13)
* Organization chart series type
* @module highcharts/modules/organization
* @requires highcharts
* @requires highcharts/modules/sankey
*
* (c) 2019-2026 Highsoft AS
* Author: Torstein Hønsi
*
* A commercial license may be required depending on use.
* See www.highcharts.com/license
*/import*as t from"../highcharts.js";var e={};e.n=t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var n=e.n(i);let r=t.default.SeriesRegistry;var s=e.n(r);let{doc:o,win:a}=n();function l(t,e,i,r={}){let s="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(s,"hcEvents")||(s.hcEvents={});let o=s.hcEvents;n().Point&&t instanceof n().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let a=t.addEventListener;a&&a.call(t,e,i,!!n().supportsPassiveEvents&&{passive:void 0===r.passive?-1!==e.indexOf("touch"):r.passive,capture:!1}),o[e]||(o[e]=[]);let h={fn:i,order:"number"==typeof r.order?r.order:1/0};return o[e].push(h),o[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,i){function n(e,i){let n=t.removeEventListener;n&&n.call(t,e,i,!1)}function r(i){let r,s;t.nodeName&&(e?(r={})[e]=!0:r=i,g(r,function(t,e){if(i[e])for(s=i[e].length;s--;)n(e,i[e][s].fn)}))}let s="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(s,"hcEvents")){let t=s.hcEvents;if(e){let s=t[e]||[];i?(t[e]=s.filter(function(t){return i!==t.fn}),n(e,i)):(r(t),t[e]=[])}else r(t),delete s.hcEvents}}(t,e,i)}}function h(t,e=0,i){let n=e%2/2,r=i?-1:1;return(Math.round(t*r-n)+n)*r}function d(t,e){let i;for(i in t||(t={}),e)t[i]=e[i];return t}let p=Array.prototype.find?function(t,e){return t.find(e)}:function(t,e){let i,n=t.length;for(i=0;i<n;i++)if(e(t[i],i))return t[i]};function u(t){return c(t)&&"number"==typeof t.nodeType}function c(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function f(t,...e){let i,n=[t,...e],r={},s=function(t,e){return"object"!=typeof t&&(t={}),g(e,function(i,n){if("__proto__"!==n&&"constructor"!==n){let r;!c(i,!0)||(r=i?.constructor,c(i,!0)&&!u(i)&&r?.name&&"Object"!==r.name)||u(i)?t[n]=e[n]:t[n]=s(t[n]||{},i)}}),t};!0===t&&(r=n[1],n=Array.prototype.slice.call(n,2));let o=n.length;for(i=0;i<o;i++)r=s(r,n[i]);return r}function g(t,e,i){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call(i||t[n],t[n],n,t)}function y(){let t=arguments,e=t.length;for(let i=0;i<e;i++){let e=t[i];if(null!=e)return e}}let{sankey:{prototype:{pointClass:m}}}=s().seriesTypes,b=class extends m{constructor(t,e,i){super(t,e,i),this.isNode||(this.dataLabelOnNull=!0,this.formatPrefix="link")}getSum(){return 1}setNodeColumn(){super.setNodeColumn();let t=this,e=t.getFromNode().fromNode;if(null==t.options.column&&0!==t.linksTo.length&&e&&"hanging"===e.options.layout){let i=-1,n;t.options.layout=y(t.options.layout,"hanging"),t.hangsFrom=e,p(e.linksFrom,(e,n)=>{let r=e.toNode===t;return r&&(i=n),r});for(let r=0;r<e.linksFrom.length;++r)(n=e.linksFrom[r]).toNode.id===t.id?r=e.linksFrom.length:i+=function t(e){let i=e.linksFrom.length;return e.linksFrom.forEach(e=>{e.id===e.toNode.linksTo[0].id?i+=t(e.toNode):i--}),i}(n.toNode);t.column=(t.column||0)+i}}};function k(t,e){let i=[];for(let n=0;n<t.length;n++){let r=t[n][1],s=t[n][2];if("number"==typeof r&&"number"==typeof s)if(0===n)i.push(["M",r,s]);else if(n===t.length-1)i.push(["L",r,s]);else if(e){let o=t[n-1],a=t[n+1];if(o&&a){let t=o[1],n=o[2],l=a[1],h=a[2];if("number"==typeof t&&"number"==typeof l&&"number"==typeof n&&"number"==typeof h&&t!==l&&n!==h){let o=t<l?1:-1,a=n<h?1:-1;i.push(["L",r-o*Math.min(Math.abs(r-t),e),s-a*Math.min(Math.abs(s-n),e)],["C",r,s,r,s,r+o*Math.min(Math.abs(r-l),e),s+a*Math.min(Math.abs(s-h),e)])}}}else i.push(["L",r,s])}return i}let x=t.default.SVGElement;var A=e.n(x);let{deg2rad:v}=n();function L(t,e){e=f(!0,{enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);let n=this.renderer.url,r=this.text||this,s=r.textPath,{attributes:o,enabled:a}=e;if(t=t||s&&s.path,s&&s.undo(),t&&a){let e=l(r,"afterModifyTree",e=>{if(t&&a){let s=t.attr("id");s||t.attr("id",s=(0,i.uniqueKey)());let a={x:0,y:0};null!=o.dx&&(a.dx=o.dx,delete o.dx),null!=o.dy&&(a.dy=o.dy,delete o.dy),r.attr(a),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let l=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:d(o,{"text-anchor":o.textAnchor,href:`${n}#${s}`}),children:l}}});r.textPath={path:t,undo:e}}else r.attr({dx:0,dy:0}),delete r.textPath;return this.added&&(r.textCache="",this.renderer.buildText(r)),this}function O(t){let e=t.bBox,i=this.element?.querySelector("textPath");if(i){let t=[],{b:n,h:r}=this.renderer.fontMetrics(this.element),s=r-n,o=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),a=i.innerHTML.replace(o,"").split(/<tspan class="highcharts-br"[^>]*>/),l=a.length,h=(t,e)=>{let{x:r,y:o}=e,a=(i.getRotationOfChar(t)-90)*v,l=Math.cos(a),h=Math.sin(a);return[[r-s*l,o-s*h],[r+n*l,o+n*h]]};for(let e=0,n=0;n<l;n++){let r=a[n].length;for(let s=0;s<r;s+=5)try{let r=e+s+n,[o,a]=h(r,i.getStartPositionOfChar(r));0===s?(t.push(a),t.push(o)):(0===n&&t.unshift(a),n===l-1&&t.push(o))}catch{break}e+=r-1;try{let r=e+n,s=i.getEndPositionOfChar(r),[o,a]=h(r,s);t.unshift(a),t.unshift(o)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}function P(t){let e=t.labelOptions,i=t.point,n=e[i.formatPrefix+"TextPath"]||e.textPath;n&&!e.useHTML&&(this.setTextPath(i.getDataLabelPath?.(this)||i.graphic,n),i.dataLabelPath&&!n.enabled&&(i.dataLabelPath=i.dataLabelPath.destroy()))}let{sankey:w}=s().seriesTypes;({compose:function(t){l(t,"afterGetBBox",O),l(t,"beforeAddingDataLabel",P);let e=t.prototype;e.setTextPath||(e.setTextPath=L)}}).compose(A());class M extends w{alignDataLabel(t,e,i){let n=t.shapeArgs,r=e.text;if(i.useHTML&&n){var s,o,a;let t=this.options.borderWidth+2*this.options.dataLabels.padding,i=n.width||0,l=n.height||0;this.chart.inverted&&(i=l,l=n.width||0),l-=t,i-=t,r.foreignObject?.attr({x:0,y:0,width:i,height:l}),s=r.element.parentNode,o={width:i+"px",height:l+"px"},d(s.style,o),a=r.element,d(a.style,{left:0,top:0,width:"100%",height:"100%",overflow:"hidden"}),e.getBBox=()=>({width:i,height:l,x:0,y:0}),e.width=i,e.height=l}super.alignDataLabel.apply(this,arguments)}createNode(t){let e=super.createNode.call(this,t);return e.getSum=()=>1,e}pointAttribs(t,e){let i=w.prototype.pointAttribs.call(this,t,e),n=t.isNode?t.level:t.fromNode.level,r=this.mapOptionsToLevel[n||0]||{},s=t.options,o=r.states&&r.states[e]||{},a=y(o.borderRadius,s.borderRadius,r.borderRadius,this.options.borderRadius),l=y(o.linkColor,s.linkColor,r.linkColor,this.options.linkColor,o.link&&o.link.color,s.link&&s.link.color,r.link&&r.link.color,this.options.link&&this.options.link.color),h=y(o.linkLineWidth,s.linkLineWidth,r.linkLineWidth,this.options.linkLineWidth,o.link&&o.link.lineWidth,s.link&&s.link.lineWidth,r.link&&r.link.lineWidth,this.options.link&&this.options.link.lineWidth),d=y(o.linkOpacity,s.linkOpacity,r.linkOpacity,this.options.linkOpacity,o.link&&o.link.linkOpacity,s.link&&s.link.linkOpacity,r.link&&r.link.linkOpacity,this.options.link&&this.options.link.linkOpacity);if(t.isNode)"number"==typeof a&&!isNaN(a)&&a<1/0&&a>-1/0&&(i.r=a);else i.stroke=l,i["stroke-width"]=h,i.opacity=d,delete i.fill;return i}translateLink(t){let e=this.chart,i=this.options,n=t.fromNode,r=t.toNode,s=y(i.linkLineWidth,i.link.lineWidth,0),o=y(i.link.offset,.5),a=y(t.options.link&&t.options.link.type,i.link.type);if(n.shapeArgs&&r.shapeArgs){let l=i.hangingIndent,d="right"===i.hangingSide,p=r.options.offset,u=/%$/.test(p)&&parseInt(p,10),c=e.inverted,f=h((n.shapeArgs.x||0)+(n.shapeArgs.width||0),s),g=h((n.shapeArgs.y||0)+(n.shapeArgs.height||0)/2,s),m=h(r.shapeArgs.x||0,s),b=h((r.shapeArgs.y||0)+(r.shapeArgs.height||0)/2,s),x;if(c&&(f-=n.shapeArgs.width||0,m+=r.shapeArgs.width||0),x=this.colDistance?h(m+(c?1:-1)*(this.colDistance-this.nodeWidth)/2,s):h((m+f)/2,s),u&&(u>=50||u<=-50)&&(x=m=h(m+(c?-.5:.5)*(r.shapeArgs.width||0),s),b=r.shapeArgs.y||0,u>0&&(b+=r.shapeArgs.height||0)),r.hangsFrom===n&&(e.inverted?(g=d?h((n.shapeArgs.y||0)+l/2,s):h((n.shapeArgs.y||0)+(n.shapeArgs.height||0)-l/2,s),b=d?(r.shapeArgs.y||0)+l/2:(r.shapeArgs.y||0)+(r.shapeArgs.height||0)):g=h((n.shapeArgs.y||0)+l/2,s),x=m=h((r.shapeArgs.x||0)+(r.shapeArgs.width||0)/2,s)),t.plotX=x,t.plotY=(g+b)/2,t.shapeType="path","straight"===a)t.shapeArgs={d:[["M",f,g],["L",m,b]]};else if("curved"===a){let e=Math.abs(m-f)*o*(c?-1:1);t.shapeArgs={d:[["M",f,g],["C",f+e,g,m-e,b,m,b]]}}else t.shapeArgs={d:k([["M",f,g],["L",x,g],["L",x,b],["L",m,b]],y(i.linkRadius,i.link.radius))};t.dlBox={x:(f+m)/2,y:(g+b)/2,height:s,width:0}}}translateNode(t,e){super.translateNode(t,e);let i=this.chart,n=this.options,r=Math.max(Math.round(t.getSum()*this.translationFactor),n.minLinkWidth||0),s="right"===n.hangingSide,o=n.hangingIndent||0,a=n.hangingIndentTranslation,l=n.minNodeLength||10,h=Math.round(this.nodeWidth),d=t.shapeArgs,p=i.inverted?-1:1,u=t.hangsFrom;if(u)if("cumulative"===a)for(d.height-=o,i.inverted&&!s&&(d.y-=p*o);u;)d.y+=(s?1:p)*o,u=u.hangsFrom;else if("shrink"===a)for(;u&&d.height>o+l;)d.height-=o,(!i.inverted||s)&&(d.y+=o),u=u.hangsFrom;else d.height-=o,(!i.inverted||s)&&(d.y+=o);t.nodeHeight=i.inverted?d.width:d.height,t.shapeArgs&&!t.hangsFrom&&(t.shapeArgs=f(t.shapeArgs,{x:(t.shapeArgs.x||0)+h/2-(t.shapeArgs.width||0)/2,y:(t.shapeArgs.y||0)+r/2-(t.shapeArgs.height||0)/2}))}drawDataLabels(){let t=this.options.dataLabels;if(t.linkTextPath&&t.linkTextPath.enabled)for(let t of this.points)t.options.dataLabels=f(t.options.dataLabels,{useHTML:!1});super.drawDataLabels()}}M.defaultOptions=f(w.defaultOptions,{borderColor:"#666666",borderRadius:3,link:{color:"#666666",lineWidth:1,radius:10,type:"orthogonal"},borderWidth:1,dataLabels:{nodeFormatter:function(){let t={width:"100%",height:"100%",display:"flex","flex-direction":"row","align-items":"center","justify-content":"center"},e={"max-height":"100%","border-radius":"50%"},i={width:"100%",padding:0,"text-align":"center","white-space":"normal"};function n(t){return Object.keys(t).reduce(function(e,i){return e+i+":"+t[i]+";"},'style="')+'"'}let{description:r,image:s,title:o}=this.point;s&&(e["max-width"]="30%",i.width="70%"),this.series.chart.renderer.forExport&&(t.display="block",i.position="absolute",i.left=s?"30%":0,i.top=0);let a="<div "+n(t)+">";return s&&(a+='<img src="'+s+'" '+n(e)+">"),a+="<div "+n(i)+">",this.point.name&&(a+="<h4 "+n({margin:0})+">"+this.point.name+"</h4>"),o&&(a+="<p "+n({margin:0})+">"+(o||"")+"</p>"),r&&(a+="<p "+n({opacity:.75,margin:"5px"})+">"+r+"</p>"),a+="</div></div>"},style:{fontWeight:"normal",fontSize:"0.9em",textAlign:"left"},useHTML:!0,linkTextPath:{attributes:{startOffset:"95%",textAnchor:"end"}}},hangingIndent:20,hangingIndentTranslation:"inherit",hangingSide:"left",minNodeLength:10,nodeWidth:50,tooltip:{nodeFormat:"{point.name}<br>{point.title}<br>{point.description}"}}),d(M.prototype,{pointClass:b}),s().registerSeriesType("organization",M);let N=n();export{N as default};