/** * Highcharts JS v11.2.0 (2023-10-30) * * Sankey diagram module * * (c) 2010-2021 Torstein Honsi * * License: www.highcharts.com/license */!function(o){"object"==typeof module&&module.exports?(o.default=o,module.exports=o):"function"==typeof define&&define.amd?define("highcharts/modules/sankey",["highcharts"],function(t){return o(t),o.Highcharts=t,o}):o("undefined"!=typeof Highcharts?Highcharts:void 0)}(function(o){"use strict";var t=o?o._modules:{};function e(o,t,e,i){o.hasOwnProperty(t)||(o[t]=i.apply(null,e),"function"==typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:t,module:o[t]}})))}e(t,"Series/NodesComposition.js",[t["Core/Series/SeriesRegistry.js"],t["Core/Utilities.js"]],function(o,t){var e,i=o.series,n=i.prototype,r=i.prototype.pointClass.prototype,s=t.defined,a=t.extend,l=t.find,d=t.merge,p=t.pick;return function(o){var e=[];function i(){return this.data=[].concat(this.points||[],this.nodes),n.destroy.apply(this,arguments)}function h(){this.nodes&&(this.nodes.forEach(function(o){o.destroy()}),this.nodes.length=0),n.setData.apply(this,arguments)}function c(o){var t=arguments,e=this.isNode?this.linksTo.concat(this.linksFrom):[this.fromNode,this.toNode];"select"!==o&&e.forEach(function(o){o&&o.series&&(r.setState.apply(o,t),!o.isNode&&(o.fromNode.graphic&&r.setState.apply(o.fromNode,t),o.toNode&&o.toNode.graphic&&r.setState.apply(o.toNode,t)))}),r.setState.apply(this,t)}function u(o,t,e,i){var n=this,s=this.series.options.nodes,a=this.series.options.data,l=a&&a.length||0,h=a&&a[this.index];if(r.update.call(this,o,!this.isNode&&t,e,i),this.isNode){var c=(s||[]).reduce(function(o,t,e){return n.id===t.id?e:o},-1),u=d(s&&s[c]||{},a&&a[this.index]||{});a&&(h?a[this.index]=h:a.length=l),s?c>=0?s[c]=u:s.push(u):this.series.options.nodes=[u],p(t,!0)&&this.series.chart.redraw(e)}}o.compose=function(o,n){if(t.pushUnique(e,o)){var r=o.prototype;r.setNodeState=c,r.setState=c,r.update=u}if(t.pushUnique(e,n)){var s=n.prototype;s.destroy=i,s.setData=h}return n},o.createNode=function(o){var t,e=this.pointClass,i=function(o,t){return l(o,function(o){return o.id===t})},n=i(this.nodes,o);if(!n){t=this.options.nodes&&i(this.options.nodes,o);var r=new e().init(this,a({className:"highcharts-node",isNode:!0,id:o,y:1},t));r.linksTo=[],r.linksFrom=[],r.getSum=function(){var o=0,t=0;return r.linksTo.forEach(function(t){o+=t.weight||0}),r.linksFrom.forEach(function(o){t+=o.weight||0}),Math.max(o,t)},r.offset=function(o,t){for(var e=0,i=0;it&&i.fromNode!==this&&(t=(o=i.fromNode).column)}return{fromNode:o,fromColumn:t}},e.prototype.setNodeColumn=function(){s(this.options.column)||(0===this.linksTo.length?this.column=0:this.column=this.getFromNode().fromColumn+1)},e.prototype.isValid=function(){return this.isNode||"number"==typeof this.weight},e}(r.prototype.pointClass)}),e(t,"Series/Sankey/SankeySeriesDefaults.js",[],function(){return{borderWidth:0,colorByPoint:!0,curveFactor:.33,dataLabels:{enabled:!0,backgroundColor:"none",crop:!1,nodeFormat:void 0,nodeFormatter:function(){return this.point.name},format:void 0,formatter:function(){},inside:!0},inactiveOtherPoints:!0,linkColorMode:"from",linkOpacity:.5,opacity:1,minLinkWidth:0,nodeAlignment:"center",nodeWidth:20,nodePadding:10,showInLegend:!1,states:{hover:{linkOpacity:1,opacity:1},inactive:{linkOpacity:.1,opacity:.1,animation:{duration:50}}},tooltip:{followPointer:!0,headerFormat:'{series.name}
',pointFormat:"{point.fromNode.name} → {point.toNode.name}: {point.weight}
",nodeFormat:"{point.name}: {point.sum}
"}}}),e(t,"Series/Sankey/SankeyColumnComposition.js",[t["Core/Utilities.js"]],function(o){var t,e,i,n=o.defined,r=(o.pushUnique,o.relativeLength);return(t=i||(i={})).compose=function(o,t){return o.sankeyColumn=new e(o,t),o},e=function(){function o(o,t){this.points=o,this.series=t}return o.prototype.getTranslationFactor=function(o){for(var t,e,i=this.points,n=i.slice(),r=o.chart,s=o.options.minLinkWidth||0,a=0,l=(r.plotSizeY||0)-(o.options.borderWidth||0)-(i.length-1)*o.nodePadding;i.length;){for(a=l/i.sankeyColumn.sum(),t=!1,e=i.length;e--;)i[e].getSum()*a0&&(i+=e),i+=Math.max(n.getSum()*o,t.options.minLinkWidth||0)},0);return({top:0,center:.5,bottom:1})[t.options.nodeAlignment||"center"]*((t.chart.plotSizeY||0)-i)},o.prototype.left=function(o){var t=this.series,e=t.chart,i=t.options.equalNodes,n=e.inverted?e.plotHeight:e.plotWidth,r=t.nodePadding,s=this.points.reduce(function(e,s){return e>0&&(e+=r),e+=i?n/s.series.nodes.length-r:Math.max(s.getSum()*o,t.options.minLinkWidth||0)},0);return((e.plotSizeX||0)-Math.round(s))/2},o.prototype.sum=function(){return this.points.reduce(function(o,t){return o+t.getSum()},0)},o.prototype.offset=function(o,t){var e,i=this.points,s=this.series,a=s.nodePadding,l=0;if(s.is("organization")&&o.hangsFrom)return{absoluteTop:o.hangsFrom.nodeY};for(var d=0;d=0&&(c>0||t.visible),t.children=h,t.childrenTotal=c,t.isLeaf=t.visible&&!c,t.val=u,t},updateRootId:function(o){var t,e;return r(o)&&(e=r(o.options)?o.options:{},t=a(o.rootNode,e.rootId,""),r(o.userOptions)&&(o.userOptions.rootId=t),o.rootNode=t),t}}}),e(t,"Series/Sankey/SankeySeries.js",[t["Core/Globals.js"],t["Series/NodesComposition.js"],t["Series/Sankey/SankeyPoint.js"],t["Series/Sankey/SankeySeriesDefaults.js"],t["Core/Series/SeriesRegistry.js"],t["Series/Sankey/SankeyColumnComposition.js"],t["Core/Color/Color.js"],t["Series/TreeUtilities.js"],t["Core/Utilities.js"]],function(o,t,e,i,n,r,s,a,l){var d,p=this&&this.__extends||(d=function(o,t){return(d=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(o,t){o.__proto__=t}||function(o,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=t[e])})(o,t)},function(o,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=o}d(o,t),o.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),h=n.seriesTypes,c=h.column,u=h.line,f=s.parse,m=a.getLevelOptions,v=l.clamp,y=l.extend,g=l.isObject,k=l.merge,C=l.pick,S=l.relativeLength,b=l.stableSort,N=function(o){function e(){var t=null!==o&&o.apply(this,arguments)||this;return t.colDistance=void 0,t.data=void 0,t.group=void 0,t.nodeLookup=void 0,t.nodePadding=void 0,t.nodes=void 0,t.nodeWidth=void 0,t.options=void 0,t.points=void 0,t.translationFactor=void 0,t}return p(e,o),e.getDLOptions=function(o){var t=g(o.optionsPoint)?o.optionsPoint.dataLabels:{};return k({style:{}},g(o.level)?o.level.dataLabels:{},t)},e.prototype.createNodeColumns=function(){for(var o=[],t=0,e=this.nodes;tthis.chart.plotSizeY&&(o=this.chart.plotSizeY/t)}return o},e.prototype.hasData=function(){return!!this.processedXData.length},e.prototype.pointAttribs=function(o,t){if(!o)return{};var e=this,i=o.isNode?o.level:o.fromNode.level,n=e.mapOptionsToLevel[i||0]||{},r=o.options,a=n.states&&n.states[t||""]||{},l=["colorByPoint","borderColor","borderWidth","linkOpacity","opacity"].reduce(function(o,t){return o[t]=C(a[t],r[t],n[t],e.options[t]),o},{}),d=C(a.color,r.color,l.colorByPoint?o.color:n.color);return o.isNode?{fill:d,stroke:l.borderColor,"stroke-width":l.borderWidth,opacity:l.opacity}:{fill:s.parse(d).setOpacity(l.linkOpacity).get()}},e.prototype.drawTracker=function(){c.prototype.drawTracker.call(this,this.points),c.prototype.drawTracker.call(this,this.nodes)},e.prototype.drawPoints=function(){c.prototype.drawPoints.call(this,this.points),c.prototype.drawPoints.call(this,this.nodes)},e.prototype.drawDataLabels=function(){c.prototype.drawDataLabels.call(this,this.points),c.prototype.drawDataLabels.call(this,this.nodes)},e.prototype.translate=function(){this.processedXData||this.processData(),this.generatePoints(),this.nodeColumns=this.createNodeColumns(),this.nodeWidth=S(this.options.nodeWidth,this.chart.plotSizeX);var o=this,t=this.chart,e=this.options,i=this.nodeWidth,n=this.nodeColumns;this.nodePadding=this.getNodePadding(),this.translationFactor=n.reduce(function(t,e){return Math.min(t,e.sankeyColumn.getTranslationFactor(o))},1/0),this.colDistance=(t.plotSizeX-i-e.borderWidth)/Math.max(1,n.length-1),o.mapOptionsToLevel=m({from:1,levels:e.levels,to:n.length-1,defaults:{borderColor:e.borderColor,borderRadius:e.borderRadius,borderWidth:e.borderWidth,color:o.color,colorByPoint:e.colorByPoint,levelIsConstant:!0,linkColor:e.linkColor,linkLineWidth:e.linkLineWidth,linkOpacity:e.linkOpacity,states:e.states}});for(var r=0;rp+y;if(n.inverted&&(m=n.plotSizeY-m,v=(n.plotSizeY||0)-v,y=-y,u=-u,g=p>h),o.shapeType="path",o.linkBase=[m,m+u,v,v+u],g&&"number"==typeof v)o.shapeArgs={d:[["M",p+y,m],["C",p+y+d,m,h-d,v,h,v],["L",h+(c?y:0),v+u/2],["L",h,v+u],["C",h-d,v+u,p+y+d,m+u,p+y,m+u],["Z"]]};else if("number"==typeof v){var k=n.plotHeight-m-u,S=h-20-u,b=h-20,N=p+y,x=N+20,L=x+u,w=m,P=m+u,T=P+20,O=T+k,j=O+20,M=j+u,F=v,W=F+u,_=W+20,D=P-.7*u,z=j+.7*u,I=W-.7*u,Y=h-.7*u,X=N+.7*u;o.shapeArgs={d:[["M",N,w],["C",X,w,L,D,L,T],["L",L,O],["C",L,z,X,M,N,M],["L",h,M],["C",Y,M,S,z,S,O],["L",S,_],["C",S,I,Y,F,h,F],["L",h,W],["C",b,W,b,W,b,_],["L",b,O],["C",b,j,b,j,h,j],["L",N,j],["C",x,j,x,j,x,O],["L",x,T],["C",x,P,x,P,N,P],["Z"]]}}if(o.dlBox={x:p+(h-p+y)/2,y:m+(v-m)/2,height:u,width:0},o.tooltipPos=n.inverted?[n.plotSizeY-o.dlBox.y-u/2,n.plotSizeX-o.dlBox.x]:[o.dlBox.x,o.dlBox.y+u/2],o.y=o.plotY=1,o.x=o.plotX=1,!o.options.color){if("from"===l)o.color=e.color;else if("to"===l)o.color=i.color;else if("gradient"===l){var A=f(e.color).get(),B=f(i.color).get();o.color={linearGradient:{x1:1,x2:0,y1:0,y2:0},stops:[[0,r?A:B],[1,r?B:A]]}}}},e.prototype.translateNode=function(o,t){var i=this.translationFactor,n=this.chart,r=this.options,s=r.borderRadius,a=r.borderWidth,l=void 0===a?0:a,d=o.getSum(),p=Math.max(Math.round(d*i),this.options.minLinkWidth),h=Math.round(this.nodeWidth),c=Math.round(l)%2/2,u=t.sankeyColumn.offset(o,i),f=Math.floor(C(u.absoluteTop,t.sankeyColumn.top(i)+u.relativeTop))+c,m=Math.floor(this.colDistance*o.column+l/2)+S(o.options[n.inverted?"offsetVertical":"offsetHorizontal"]||0,h)+c,y=n.inverted?n.plotSizeX-m:m;if(o.sum=d,d){o.shapeType="roundedRect",o.nodeX=y,o.nodeY=f;var g=y,k=f,b=o.options.width||r.width||h,N=o.options.height||r.height||p,x=v(S("object"==typeof s?s.radius:s||0,b),0,p/2);n.inverted&&(g=y-h,k=n.plotSizeY-f-p,b=o.options.height||r.height||h,N=o.options.width||r.width||p),o.dlOptions=e.getDLOptions({level:this.mapOptionsToLevel[o.level],optionsPoint:o.options}),o.plotX=1,o.plotY=1,o.tooltipPos=n.inverted?[n.plotSizeY-k-N/2,n.plotSizeX-g-b/2]:[g+b/2,k+N/2],o.shapeArgs={x:g,y:k,width:b,height:N,r:x,display:o.hasShape()?"":"none"}}else o.dlOptions={enabled:!1}},e.defaultOptions=k(c.defaultOptions,i),e}(c);return t.compose(e,N),y(N.prototype,{animate:u.prototype.animate,createNode:t.createNode,forceDL:!0,invertible:!0,isCartesian:!1,orderNodes:!0,noSharedTooltip:!0,pointArrayMap:["from","to","weight"],pointClass:e,searchPoint:o.noop}),n.registerSeriesType("sankey",N),N}),e(t,"masters/modules/sankey.src.js",[],function(){})});//# sourceMappingURL=sankey.js.map