highcharts
Version:
JavaScript charting framework
13 lines • 12 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
*/function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.SeriesRegistry,t._Highcharts.SVGElement):"function"==typeof define&&define.amd?define("highcharts/modules/organization",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry,t.SVGElement)}):"object"==typeof exports?exports["highcharts/modules/organization"]=e(t._Highcharts,t._Highcharts.SeriesRegistry,t._Highcharts.SVGElement):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry,t.Highcharts.SVGElement)}("u"<typeof window?this:window,(t,e,i)=>(()=>{"use strict";var n={28:t=>{t.exports=i},512:t=>{t.exports=e},944:e=>{e.exports=t}},r={};function s(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={exports:{}};return n[t](i,i.exports,s),i.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o={};s.d(o,{default:()=>E});var a=s(944),h=s.n(a),l=s(512),d=s.n(l);let{doc:p,win:c}=h();function u(t,e,i,n={}){let r="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(r,"hcEvents")||(r.hcEvents={});let s=r.hcEvents;h().Point&&t instanceof h().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let o=t.addEventListener;o&&o.call(t,e,i,!!h().supportsPassiveEvents&&{passive:void 0===n.passive?-1!==e.indexOf("touch"):n.passive,capture:!1}),s[e]||(s[e]=[]);let a={fn:i,order:"number"==typeof n.order?n.order:1/0};return s[e].push(a),s[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,x(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 g(t,e=0,i){let n=e%2/2,r=i?-1:1;return(Math.round(t*r-n)+n)*r}function f(t,e){let i;for(i in t||(t={}),e)t[i]=e[i];return t}let y=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 m(t){return b(t)&&"number"==typeof t.nodeType}function b(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function k(t,...e){let i,n=[t,...e],r={},s=function(t,e){return"object"!=typeof t&&(t={}),x(e,function(i,n){if("__proto__"!==n&&"constructor"!==n){let r;!b(i,!0)||(r=i?.constructor,b(i,!0)&&!m(i)&&r?.name&&"Object"!==r.name)||m(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 x(t,e,i){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call(i||t[n],t[n],n,t)}function A(){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:v}}}=d().seriesTypes,L=class extends v{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=A(t.options.layout,"hanging"),t.hangsFrom=e,y(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 O(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],h=a[1],l=a[2];if("number"==typeof t&&"number"==typeof h&&"number"==typeof n&&"number"==typeof l&&t!==h&&n!==l){let o=t<h?1:-1,a=n<l?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-h),e),s+a*Math.min(Math.abs(s-l),e)])}}}else i.push(["L",r,s])}return i}var w=s(28),P=s.n(w);let{deg2rad:M}=h();function N(t,e){e=k(!0,{enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);let i=this.renderer.url,n=this.text||this,r=n.textPath,{attributes:s,enabled:o}=e;if(t=t||r&&r.path,r&&r.undo(),t&&o){let e=u(n,"afterModifyTree",e=>{if(t&&o){let r=t.attr("id");r||t.attr("id",r=(0,a.uniqueKey)());let o={x:0,y:0};null!=s.dx&&(o.dx=s.dx,delete s.dx),null!=s.dy&&(o.dy=s.dy,delete s.dy),n.attr(o),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let h=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:f(s,{"text-anchor":s.textAnchor,href:`${i}#${r}`}),children:h}}});n.textPath={path:t,undo:e}}else n.attr({dx:0,dy:0}),delete n.textPath;return this.added&&(n.textCache="",this.renderer.buildText(n)),this}function T(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"[^>]*>/),h=a.length,l=(t,e)=>{let{x:r,y:o}=e,a=(i.getRotationOfChar(t)-90)*M,h=Math.cos(a),l=Math.sin(a);return[[r-s*h,o-s*l],[r+n*h,o+n*l]]};for(let e=0,n=0;n<h;n++){let r=a[n].length;for(let s=0;s<r;s+=5)try{let r=e+s+n,[o,a]=l(r,i.getStartPositionOfChar(r));0===s?(t.push(a),t.push(o)):(0===n&&t.unshift(a),n===h-1&&t.push(o))}catch{break}e+=r-1;try{let r=e+n,s=i.getEndPositionOfChar(r),[o,a]=l(r,s);t.unshift(a),t.unshift(o)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}function S(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}=d().seriesTypes;({compose:function(t){u(t,"afterGetBBox",T),u(t,"beforeAddingDataLabel",S);let e=t.prototype;e.setTextPath||(e.setTextPath=N)}}).compose(P());class j 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,h=n.height||0;this.chart.inverted&&(i=h,h=n.width||0),h-=t,i-=t,r.foreignObject?.attr({x:0,y:0,width:i,height:h}),s=r.element.parentNode,o={width:i+"px",height:h+"px"},f(s.style,o),a=r.element,f(a.style,{left:0,top:0,width:"100%",height:"100%",overflow:"hidden"}),e.getBBox=()=>({width:i,height:h,x:0,y:0}),e.width=i,e.height=h}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=A(o.borderRadius,s.borderRadius,r.borderRadius,this.options.borderRadius),h=A(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),l=A(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=A(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=h,i["stroke-width"]=l,i.opacity=d,delete i.fill;return i}translateLink(t){let e=this.chart,i=this.options,n=t.fromNode,r=t.toNode,s=A(i.linkLineWidth,i.link.lineWidth,0),o=A(i.link.offset,.5),a=A(t.options.link&&t.options.link.type,i.link.type);if(n.shapeArgs&&r.shapeArgs){let h=i.hangingIndent,l="right"===i.hangingSide,d=r.options.offset,p=/%$/.test(d)&&parseInt(d,10),c=e.inverted,u=g((n.shapeArgs.x||0)+(n.shapeArgs.width||0),s),f=g((n.shapeArgs.y||0)+(n.shapeArgs.height||0)/2,s),y=g(r.shapeArgs.x||0,s),m=g((r.shapeArgs.y||0)+(r.shapeArgs.height||0)/2,s),b;if(c&&(u-=n.shapeArgs.width||0,y+=r.shapeArgs.width||0),b=this.colDistance?g(y+(c?1:-1)*(this.colDistance-this.nodeWidth)/2,s):g((y+u)/2,s),p&&(p>=50||p<=-50)&&(b=y=g(y+(c?-.5:.5)*(r.shapeArgs.width||0),s),m=r.shapeArgs.y||0,p>0&&(m+=r.shapeArgs.height||0)),r.hangsFrom===n&&(e.inverted?(f=l?g((n.shapeArgs.y||0)+h/2,s):g((n.shapeArgs.y||0)+(n.shapeArgs.height||0)-h/2,s),m=l?(r.shapeArgs.y||0)+h/2:(r.shapeArgs.y||0)+(r.shapeArgs.height||0)):f=g((n.shapeArgs.y||0)+h/2,s),b=y=g((r.shapeArgs.x||0)+(r.shapeArgs.width||0)/2,s)),t.plotX=b,t.plotY=(f+m)/2,t.shapeType="path","straight"===a)t.shapeArgs={d:[["M",u,f],["L",y,m]]};else if("curved"===a){let e=Math.abs(y-u)*o*(c?-1:1);t.shapeArgs={d:[["M",u,f],["C",u+e,f,y-e,m,y,m]]}}else t.shapeArgs={d:O([["M",u,f],["L",b,f],["L",b,m],["L",y,m]],A(i.linkRadius,i.link.radius))};t.dlBox={x:(u+y)/2,y:(f+m)/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,h=n.minNodeLength||10,l=Math.round(this.nodeWidth),d=t.shapeArgs,p=i.inverted?-1:1,c=t.hangsFrom;if(c)if("cumulative"===a)for(d.height-=o,i.inverted&&!s&&(d.y-=p*o);c;)d.y+=(s?1:p)*o,c=c.hangsFrom;else if("shrink"===a)for(;c&&d.height>o+h;)d.height-=o,(!i.inverted||s)&&(d.y+=o),c=c.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=k(t.shapeArgs,{x:(t.shapeArgs.x||0)+l/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=k(t.options.dataLabels,{useHTML:!1});super.drawDataLabels()}}j.defaultOptions=k(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}"}}),f(j.prototype,{pointClass:L}),d().registerSeriesType("organization",j);let E=h();return o.default})());