UNPKG

highcharts

Version:
14 lines 9.14 kB
!/** * Highcharts JS v13.0.1 (2026-08-17) * @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,a)=>(()=>{"use strict";var r,i,o={28(t){t.exports=a},512(t){t.exports=e},944(e){e.exports=t}};let n={};function s(t){let e=n[t];if(void 0!==e)return e.exports;let a=n[t]={exports:{}};return o[t](a,a.exports,s),a.exports}s.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{if(Array.isArray(e))for(var a=0;a<e.length;){var r=e[a++],i=e[a++];s.o(t,r)?0===i&&a++:0===i?Object.defineProperty(t,r,{enumerable:!0,value:e[a++]}):Object.defineProperty(t,r,{enumerable:!0,get:i})}else 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);let h={};s.d(h,{default:()=>A});var l=s(944),d=s.n(l);let{defaultOptions:p}=d(),{noop:c}=d(),g={radius:0,scope:"stack",where:void 0};var u=s(512),f=s.n(u);let{sankey:{prototype:{pointClass:m}}}=f().seriesTypes,y=class extends m{getSumTo(){let t=0;for(let e of this.linksFrom)t+=e.weightTo||e.weight||0;for(let e of this.linksTo)t+=e.weight||0;return t}getDataLabelPath(t){let e=this,a=e.series.chart.renderer,r=e.shapeArgs,i=e.angle<0||e.angle>Math.PI,o=r.start||0,n=r.end||0;return e.dataLabelPath?(e.dataLabelPath=e.dataLabelPath.destroy(),delete e.dataLabelPath):(0,l.wrap)(t,"destroy",function(t){return e.dataLabelPath&&(e.dataLabelPath=e.dataLabelPath.destroy()),t.call(this)}),e.dataLabelPath=a.arc({open:!0,longArc:Math.abs(Math.abs(o)-Math.abs(n))<Math.PI?0:1}).attr({x:r.x,y:r.y,r:(r.r||0)+(0,l.pInt)(t.options?.distance||0),start:i?o:n,end:i?n:o,clockwise:+i}).add(a.defs),e.dataLabelPath}isValid(){return!0}};var x=i||(i={});x.compose=function(t,e){return t.sankeyColumn=new b(t,e),t};class b{constructor(t,e){this.points=t,this.series=e}getTranslationFactor(t){let e=this.points,a=e.slice(),r=t.chart,i=t.options.minLinkWidth||0,o,n=0,s,h=(r.plotSizeY||0)-(t.options.borderWidth||0)-(e.length-1)*t.nodePadding;for(;e.length;){for(n=h/e.sankeyColumn.sum(),o=!1,s=e.length;s--;)e[s].getSum()*n<i&&(e.splice(s,1),h=Math.max(0,h-i),o=!0);if(!o)break}for(let t of(e.length=0,a))e.push(t);return n}top(t){let e=this.series,a=e.nodePadding,r=this.points.reduce((r,i)=>(r>0&&(r+=a),r+=Math.max(i.getSum()*t,e.options.minLinkWidth||0)),0);return(0,l.getAlignFactor)(e.options.nodeAlignment||"center")*((e.chart.plotSizeY||0)-r)}left(t){let e=this.series,a=e.chart,r=e.options.equalNodes,i=a.inverted?a.plotHeight:a.plotWidth,o=e.nodePadding,n=this.points.reduce((a,n)=>(a>0&&(a+=o),a+=r?i/n.series.nodes.length-o:Math.max(n.getSum()*t,e.options.minLinkWidth||0)),0);return((a.plotSizeX||0)-Math.round(n))/2}sum(){return this.points.reduce((t,e)=>t+e.getSum(),0)}offset(t,e){let a=this.points,r=this.series,i=r.nodePadding,o=0,n;if(r.is("organization")&&t.hangsFrom)return{absoluteTop:t.hangsFrom.nodeY};for(let s=0;s<a.length;s++){let h=a[s].getSum(),d=Math.max(h*e,r.options.minLinkWidth||0),p=t.options[r.chart.inverted?"offsetHorizontal":"offsetVertical"],c=t.options.offset||0;if(n=h?d+i:0,a[s]===t)return{relativeTop:o+((0,l.defined)(p)?(0,l.relativeLength)(p,d):(0,l.relativeLength)(c,n))};o+=n}}}x.SankeyColumnAdditions=b;let P=i;var T=s(28),k=s.n(T);let{composed:w,deg2rad:M}=d(),{deg2rad:v}=d(),{pie:L,sankey:S}=f().seriesTypes;r=k(),(0,l.pushUnique)(w,"TextPath")&&((0,l.addEvent)(r,"afterGetBBox",function(t){let e=t.bBox,a=this.element?.querySelector("textPath");if(a){let t=[],{b:r,h:i}=this.renderer.fontMetrics(this.element),o=i-r,n=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),s=a.innerHTML.replace(n,"").split(/<tspan class="highcharts-br"[^>]*>/),h=s.length,l=(t,e)=>{let{x:i,y:n}=e,s=(a.getRotationOfChar(t)-90)*M,h=Math.cos(s),l=Math.sin(s);return[[i-o*h,n-o*l],[i+r*h,n+r*l]]};for(let e=0,r=0;r<h;r++){let i=s[r].length;for(let o=0;o<i;o+=5)try{let i=e+o+r,[n,s]=l(i,a.getStartPositionOfChar(i));0===o?(t.push(s),t.push(n)):(0===r&&t.unshift(s),r===h-1&&t.push(n))}catch{break}e+=i-1;try{let i=e+r,o=a.getEndPositionOfChar(i),[n,s]=l(i,o);t.unshift(s),t.unshift(n)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}),(0,l.addEvent)(r,"beforeAddingDataLabel",function(t){let e=t.labelOptions,a=t.point,r=e[a.formatPrefix+"TextPath"]||e.textPath;r&&!e.useHTML&&(this.setTextPath(a.getDataLabelPath?.(this)||a.graphic,r),a.dataLabelPath&&!r.enabled&&(a.dataLabelPath=a.dataLabelPath.destroy()))}),r.prototype.setTextPath=r.prototype.setTextPath??function(t,e){let a=this.renderer.url,r=this.text||this,i=r.textPath,{attributes:o,enabled:n}=(0,l.merge)({enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);if(t=t||i&&i.path,i?.undo(),t&&n){let e=(0,l.addEvent)(r,"afterModifyTree",e=>{if(t&&n){let i=t.attr("id");i||t.attr("id",i=(0,l.uniqueKey)());let n={x:0,y:0};(0,l.defined)(o.dx)&&(n.dx=o.dx,delete o.dx),(0,l.defined)(o.dy)&&(n.dy=o.dy,delete o.dy),r.attr(n),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let s=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:(0,l.extend)(o,{"text-anchor":o.textAnchor,href:`${a}#${i}`}),children:s}}});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});class N extends S{animate(t){if(!t){let t=(0,l.animObject)(this.options.animation).duration/2/this.nodes.length,e=0;for(let a of this.nodes){let r=a.graphic;r&&(r.attr({opacity:0}),setTimeout(()=>{a.graphic&&a.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=()=>{let t=0;for(let a of e.linksFrom)t+=a.weight||0;for(let a of e.linksTo)t+=a.weightTo||a.weight||0;return t},e.offset=t=>{let a=t=>t.fromNode===e?t.toNode:t.fromNode,r=0,i=e.linksFrom.concat(e.linksTo),o;i.sort((t,e)=>a(t).index-a(e).index);for(let t=0;t<i.length;t++)if(a(i[t]).index>e.index){i=i.slice(0,t).reverse().concat(i.slice(t).reverse()),o=!0;break}o||i.reverse();for(let a=0;a<i.length;a++){if(i[a]===t)return r;let o=i[a].weight||0;r+=i[a].to===e.id&&i[a].weightTo||o}},e}createNodeColumns(){let t=[P.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(){var t;let e=this.options,a=2*Math.PI/(this.chart.plotHeight+this.getNodePadding()),r=this.getCenter(),i=((e.startAngle||0)-90)*v,o=(t=e.borderRadius,!(0,l.isObject)(t)&&(t={radius:t||0}),(0,l.merge)(g,void 0,t)).radius;for(let t of(super.translate(),this.nodeColumns[0]))if(t.sum){let n=t.shapeArgs,s=r[0],h=r[1],d=r[2]/2,p="auto"===e.nodeWidth?20:e.nodeWidth,c=d-(0,l.relativeLength)(p||0,d),g=i+a*(n.y||0),u=i+a*((n.y||0)+(n.height||0));for(let r of(t.angle=g+(u-g)/2,t.shapeType="arc",t.shapeArgs={x:s,y:h,r:d,innerR:c,start:g,end:u,borderRadius:o},t.dlBox={x:s+Math.cos((g+u)/2)*(d+c)/2,y:h+Math.sin((g+u)/2)*(d+c)/2,width:1,height:1},t.linksFrom))if(r.linkBase){let t,o,n=r.linkBase.map((n,l)=>{let d=a*n,p=Math.cos(i+d)*(c+1),g=Math.sin(i+d)*(c+1);return t=e.curveFactor||0,(o=Math.abs(r.linkBase[3-l]*a-d))>Math.PI&&(o=2*Math.PI-o),(o*=c)<c&&(t*=o/c),{x:s+p,y:h+g,cpX:s+(1-t)*p,cpY:h+(1-t)*g}});r.shapeArgs={d:[["M",n[0].x,n[0].y],["A",c,c,0,0,1,n[1].x,n[1].y],["C",n[1].cpX,n[1].cpY,n[2].cpX,n[2].cpY,n[2].x,n[2].y],["A",c,c,0,0,1,n[3].x,n[3].y],["C",n[3].cpX,n[3].cpY,n[0].cpX,n[0].cpY,n[0].x,n[0].y]]}}}}translateLink(t){let e=Math.max((t.weightTo||t.weight||0)*this.translationFactor,this.options.minLinkWidth||0),a=this.getY(t,t.toNode,"linksTo",e);super.translateLink(t,a),t.linkBase[3]=a+e}translateNode(t,e){super.translateNode(t,e),t.sumTo=t.getSumTo()}}N.defaultOptions=(0,l.merge)(S.defaultOptions,{center:[null,null],curveFactor:.6,startAngle:0,dataLabels:{allowOverlap:!0,textPath:{enabled:!1,attributes:{dy:5}}},tooltip:{pointFormat:"{point.fromNode.name} → {point.toNode.name}: <b>{point.weight}</b><br/>{#if point.weightTo}{point.toNode.name} → {point.fromNode.name}: <b>{point.weightTo}</b><br/>{/if}"}}),(0,l.extend)(N.prototype,{orderNodes:!1,pointArrayMap:["from","to","weight","weightTo"],getCenter:L.prototype.getCenter}),N.prototype.pointClass=y,f().registerSeriesType("dependencywheel",N);let A=d();return h.default})());