highcharts
Version:
JavaScript charting framework
14 lines • 9.91 kB
JavaScript
!/**
* Highcharts JS v12.6.0 (2026-04-13)
* @module highcharts/modules/dependency-wheel
* @requires highcharts
* @requires highcharts/modules/sankey
*
* Dependency wheel module
*
* (c) 2010-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/dependency-wheel",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry,t.SVGElement)}):"object"==typeof exports?exports["highcharts/modules/dependency-wheel"]=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,r)=>(()=>{"use strict";var n,o={28:t=>{t.exports=r},512:t=>{t.exports=e},944:e=>{e.exports=t}},a={};function s(t){var e=a[t];if(void 0!==e)return e.exports;var r=a[t]={exports:{}};return o[t](r,r.exports,s),r.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 r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i={};s.d(i,{default:()=>I});var l=s(944),h=s.n(l),d=s(512),c=s.n(d);let{doc:p,win:u}=h();function f(t,e,r,n={}){let o="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(o,"hcEvents")||(o.hcEvents={});let a=o.hcEvents;h().Point&&t instanceof h().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let s=t.addEventListener;s&&s.call(t,e,r,!!h().supportsPassiveEvents&&{passive:void 0===n.passive?-1!==e.indexOf("touch"):n.passive,capture:!1}),a[e]||(a[e]=[]);let i={fn:r,order:"number"==typeof n.order?n.order:1/0};return a[e].push(i),a[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,r){function n(e,r){let n=t.removeEventListener;n&&n.call(t,e,r,!1)}function o(r){let o,a;t.nodeName&&(e?(o={})[e]=!0:o=r,b(o,function(t,e){if(r[e])for(a=r[e].length;a--;)n(e,r[e][a].fn)}))}let a="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(a,"hcEvents")){let t=a.hcEvents;if(e){let a=t[e]||[];r?(t[e]=a.filter(function(t){return r!==t.fn}),n(e,r)):(o(t),t[e]=[])}else o(t),delete a.hcEvents}}(t,e,r)}}function g(t,e){let r;for(r in t||(t={}),e)t[r]=e[r];return t}function y(t){return m(t)&&"number"==typeof t.nodeType}function m(t,e){let r;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(r=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==r)}function x(t,...e){let r,n=[t,...e],o={},a=function(t,e){return"object"!=typeof t&&(t={}),b(e,function(r,n){if("__proto__"!==n&&"constructor"!==n){let o;!m(r,!0)||(o=r?.constructor,m(r,!0)&&!y(r)&&o?.name&&"Object"!==o.name)||y(r)?t[n]=e[n]:t[n]=a(t[n]||{},r)}}),t};!0===t&&(o=n[1],n=Array.prototype.slice.call(n,2));let s=n.length;for(r=0;r<s;r++)o=a(o,n[r]);return o}function b(t,e,r){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call(r||t[n],t[n],n,t)}function P(t,e,r){return/%$/.test(t)?e*parseFloat(t)/100+(r||0):parseFloat(t)}Array.prototype.find;let{sankey:{prototype:{pointClass:v}}}=c().seriesTypes,M=class extends v{getDataLabelPath(t){var e;let r=this,n=r.series.chart.renderer,o=r.shapeArgs,a=r.angle<0||r.angle>Math.PI,s=o.start||0,i=o.end||0;if(r.dataLabelPath)r.dataLabelPath=r.dataLabelPath.destroy(),delete r.dataLabelPath;else{let n;e=function(t){return r.dataLabelPath&&(r.dataLabelPath=r.dataLabelPath.destroy()),t.call(this)},n=t.destroy,t.destroy=function(){let t=arguments,r=this;return e.apply(this,[function(){return n.apply(r,arguments.length?arguments:t)}].concat([].slice.call(arguments)))}}return r.dataLabelPath=n.arc({open:!0,longArc:Math.abs(Math.abs(s)-Math.abs(i))<Math.PI?0:1}).attr({x:o.x,y:o.y,r:(o.r||0)+parseInt(t.options?.distance||0,10),start:a?s:i,end:a?i:s,clockwise:+a}).add(n.defs),r.dataLabelPath}isValid(){return!0}};var k=n||(n={});k.compose=function(t,e){return t.sankeyColumn=new L(t,e),t};class L{constructor(t,e){this.points=t,this.series=e}getTranslationFactor(t){let e=this.points,r=e.slice(),n=t.chart,o=t.options.minLinkWidth||0,a,s=0,i,l=(n.plotSizeY||0)-(t.options.borderWidth||0)-(e.length-1)*t.nodePadding;for(;e.length;){for(s=l/e.sankeyColumn.sum(),a=!1,i=e.length;i--;)e[i].getSum()*s<o&&(e.splice(i,1),l=Math.max(0,l-o),a=!0);if(!a)break}for(let t of(e.length=0,r))e.push(t);return s}top(t){let e=this.series,r=e.nodePadding,n=this.points.reduce((n,o)=>(n>0&&(n+=r),n+=Math.max(o.getSum()*t,e.options.minLinkWidth||0)),0);return((t="")=>({center:.5,right:1,middle:.5,bottom:1})[t]||0)(e.options.nodeAlignment||"center")*((e.chart.plotSizeY||0)-n)}left(t){let e=this.series,r=e.chart,n=e.options.equalNodes,o=r.inverted?r.plotHeight:r.plotWidth,a=e.nodePadding,s=this.points.reduce((r,s)=>(r>0&&(r+=a),r+=n?o/s.series.nodes.length-a:Math.max(s.getSum()*t,e.options.minLinkWidth||0)),0);return((r.plotSizeX||0)-Math.round(s))/2}sum(){return this.points.reduce((t,e)=>t+e.getSum(),0)}offset(t,e){let r=this.points,n=this.series,o=n.nodePadding,a=0,s;if(n.is("organization")&&t.hangsFrom)return{absoluteTop:t.hangsFrom.nodeY};for(let i=0;i<r.length;i++){let l=r[i].getSum(),h=Math.max(l*e,n.options.minLinkWidth||0),d=t.options[n.chart.inverted?"offsetHorizontal":"offsetVertical"],c=t.options.offset||0;if(s=l?h+o:0,r[i]===t)return{relativeTop:a+(null!=d?P(d,h):P(c,s))};a+=s}}}k.SankeyColumnAdditions=L;let S=n;var T=s(28),O=s.n(T);let{deg2rad:A}=h();function C(t,e){e=x(!0,{enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);let r=this.renderer.url,n=this.text||this,o=n.textPath,{attributes:a,enabled:s}=e;if(t=t||o&&o.path,o&&o.undo(),t&&s){let e=f(n,"afterModifyTree",e=>{if(t&&s){let o=t.attr("id");o||t.attr("id",o=(0,l.uniqueKey)());let s={x:0,y:0};null!=a.dx&&(s.dx=a.dx,delete a.dx),null!=a.dy&&(s.dy=a.dy,delete a.dy),n.attr(s),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let i=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:g(a,{"text-anchor":a.textAnchor,href:`${r}#${o}`}),children:i}}});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 w(t){let e=t.bBox,r=this.element?.querySelector("textPath");if(r){let t=[],{b:n,h:o}=this.renderer.fontMetrics(this.element),a=o-n,s=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),i=r.innerHTML.replace(s,"").split(/<tspan class="highcharts-br"[^>]*>/),l=i.length,h=(t,e)=>{let{x:o,y:s}=e,i=(r.getRotationOfChar(t)-90)*A,l=Math.cos(i),h=Math.sin(i);return[[o-a*l,s-a*h],[o+n*l,s+n*h]]};for(let e=0,n=0;n<l;n++){let o=i[n].length;for(let a=0;a<o;a+=5)try{let o=e+a+n,[s,i]=h(o,r.getStartPositionOfChar(o));0===a?(t.push(i),t.push(s)):(0===n&&t.unshift(i),n===l-1&&t.push(s))}catch{break}e+=o-1;try{let o=e+n,a=r.getEndPositionOfChar(o),[s,i]=h(o,a);t.unshift(i),t.unshift(s)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}function j(t){let e=t.labelOptions,r=t.point,n=e[r.formatPrefix+"TextPath"]||e.textPath;n&&!e.useHTML&&(this.setTextPath(r.getDataLabelPath?.(this)||r.graphic,n),r.dataLabelPath&&!n.enabled&&(r.dataLabelPath=r.dataLabelPath.destroy()))}let{animObject:E}=h(),{deg2rad:H}=h(),{pie:N,sankey:_}=c().seriesTypes;({compose:function(t){f(t,"afterGetBBox",w),f(t,"beforeAddingDataLabel",j);let e=t.prototype;e.setTextPath||(e.setTextPath=C)}}).compose(O());class F extends _{animate(t){if(!t){let t=E(this.options.animation).duration/2/this.nodes.length,e=0;for(let r of this.nodes){let n=r.graphic;n&&(n.attr({opacity:0}),setTimeout(()=>{r.graphic&&r.graphic.animate({opacity:1},{duration:t})},t*e++))}for(let t of this.points){let e=t.graphic;!t.isNode&&e&&e.attr({opacity:0}).animate({opacity:1},this.options.animation)}}}createNode(t){let e=super.createNode(t);return e.getSum=()=>e.linksFrom.concat(e.linksTo).reduce((t,e)=>t+e.weight,0),e.offset=t=>{let r=t=>t.fromNode===e?t.toNode:t.fromNode,n=0,o=e.linksFrom.concat(e.linksTo),a;o.sort((t,e)=>r(t).index-r(e).index);for(let t=0;t<o.length;t++)if(r(o[t]).index>e.index){o=o.slice(0,t).reverse().concat(o.slice(t).reverse()),a=!0;break}a||o.reverse();for(let e=0;e<o.length;e++){if(o[e]===t)return n;n+=o[e].weight}},e}createNodeColumns(){let t=[S.compose([],this)];for(let e of this.nodes)e.column=0,t[0].push(e);return t}getNodePadding(){return this.options.nodePadding/Math.PI}translate(){let t=this.options,e=2*Math.PI/(this.chart.plotHeight+this.getNodePadding()),r=this.getCenter(),n=(t.startAngle-90)*H,o=t.borderRadius,a="object"==typeof o?o.radius:o;for(let o of(super.translate(),this.nodeColumns[0]))if(o.sum){let s=o.shapeArgs,i=r[0],l=r[1],h=r[2]/2,d=h-P(("auto"===t.nodeWidth?20:t.nodeWidth)||0,h),c=n+e*(s.y||0),p=n+e*((s.y||0)+(s.height||0));for(let r of(o.angle=c+(p-c)/2,o.shapeType="arc",o.shapeArgs={x:i,y:l,r:h,innerR:d,start:c,end:p,borderRadius:a},o.dlBox={x:i+Math.cos((c+p)/2)*(h+d)/2,y:l+Math.sin((c+p)/2)*(h+d)/2,width:1,height:1},o.linksFrom))if(r.linkBase){let o,a,s=r.linkBase.map((s,h)=>{let c=e*s,p=Math.cos(n+c)*(d+1),u=Math.sin(n+c)*(d+1);return o=t.curveFactor||0,(a=Math.abs(r.linkBase[3-h]*e-c))>Math.PI&&(a=2*Math.PI-a),(a*=d)<d&&(o*=a/d),{x:i+p,y:l+u,cpX:i+(1-o)*p,cpY:l+(1-o)*u}});r.shapeArgs={d:[["M",s[0].x,s[0].y],["A",d,d,0,0,1,s[1].x,s[1].y],["C",s[1].cpX,s[1].cpY,s[2].cpX,s[2].cpY,s[2].x,s[2].y],["A",d,d,0,0,1,s[3].x,s[3].y],["C",s[3].cpX,s[3].cpY,s[0].cpX,s[0].cpY,s[0].x,s[0].y]]}}}}}F.defaultOptions=x(_.defaultOptions,{center:[null,null],curveFactor:.6,startAngle:0,dataLabels:{textPath:{enabled:!1,attributes:{dy:5}}}}),g(F.prototype,{orderNodes:!1,getCenter:N.prototype.getCenter}),F.prototype.pointClass=M,c().registerSeriesType("dependencywheel",F);let I=h();return i.default})());