highcharts
Version:
JavaScript charting framework
13 lines • 12.8 kB
JavaScript
!/**
* Highcharts JS v13.0.1 (2026-08-17)
* @module modules/arc-diagram
* @requires highcharts/modules/sankey
*
* Arc diagram module
*
* (c) 2021-2026 Highsoft AS
* Author: Piotr Madej
*
* 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.Series,t._Highcharts.SVGRenderer,t._Highcharts.SVGElement):"function"==typeof define&&define.amd?define("highcharts/modules/arc-diagram",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry,t.Series,t.SVGRenderer,t.SVGElement)}):"object"==typeof exports?exports["highcharts/modules/arc-diagram"]=e(t._Highcharts,t._Highcharts.SeriesRegistry,t._Highcharts.Series,t._Highcharts.SVGRenderer,t._Highcharts.SVGElement):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry,t.Highcharts.Series,t.Highcharts.SVGRenderer,t.Highcharts.SVGElement)}("u"<typeof window?this:window,(t,e,o,s,i)=>(()=>{"use strict";var n,r,a,h={28(t){t.exports=i},540(t){t.exports=s},820(t){t.exports=o},512(t){t.exports=e},944(e){e.exports=t}};let l={};function d(t){let e=l[t];if(void 0!==e)return e.exports;let o=l[t]={exports:{}};return h[t](o,o.exports,d),o.exports}d.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return d.d(e,{a:e}),e},d.d=(t,e)=>{if(Array.isArray(e))for(var o=0;o<e.length;){var s=e[o++],i=e[o++];d.o(t,s)?0===i&&o++:0===i?Object.defineProperty(t,s,{enumerable:!0,value:e[o++]}):Object.defineProperty(t,s,{enumerable:!0,get:i})}else for(var s in e)d.o(e,s)&&!d.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},d.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let p={};d.d(p,{default:()=>F});var c=d(944),u=d.n(c),f=d(512),m=d.n(f);let{series:{prototype:g,prototype:{pointClass:{prototype:y}}}}=m();!function(t){function e(){if(!this.hasDataLabels?.()&&this.nodes)for(let t of this.nodes)t.destroyElements({dataLabel:1})}function o(){return this.data=[].concat(this.points||[],this.nodes),g.destroy.apply(this,arguments)}function s(){this.nodes&&(this.nodes.forEach(t=>{t.destroy()}),this.nodes.length=0),g.setData.apply(this,arguments)}function i(t){let e=arguments,o=this.isNode?this.linksTo.concat(this.linksFrom):[this.fromNode,this.toNode];"select"!==t&&o.forEach(t=>{t&&t.series&&(y.setState.apply(t,e),!t.isNode&&(t.fromNode.graphic&&y.setState.apply(t.fromNode,e),t.toNode&&t.toNode.graphic&&y.setState.apply(t.toNode,e)))}),y.setState.apply(this,e)}function n(t,e,o,s){let i=this.series.options.nodes,n=this.series.options.data,r=n?.length||0,a=n?.[this.index];if(y.update.call(this,t,!this.isNode&&e,o,s),this.isNode){let t=(i||[]).reduce((t,e,o)=>this.id===e.id?o:t,-1),s=(0,c.merge)(i&&i[t]||{},n?.[this.index]||{});n&&(a?n[this.index]=a:n.length=r),i?t>=0?i[t]=s:i.push(s):this.series.options.nodes=[s],(0,c.pick)(e,!0)&&this.series.chart.redraw(o)}}t.compose=function(t,r){let a=t.prototype,h=r.prototype;return a.setNodeState=i,a.setState=i,a.update=n,h.destroy=o,h.setData=s,(0,c.addEvent)(r,"afterUpdate",e),r},t.createNode=function(t){let e=this.pointClass,o=(t,e)=>(0,c.find)(t,t=>t.id===e),s=o(this.nodes,t),i;if(!s){i=this.options.nodes&&o(this.options.nodes,t);let n=new e(this,(0,c.extend)({className:"highcharts-node",isNode:!0,id:t,y:1},i));n.linksTo=[],n.linksFrom=[],n.getSum=function(){let t=0,e=0;return n.linksTo.forEach(e=>{t+=e.weight||0}),n.linksFrom.forEach(t=>{e+=t.weight||0}),Math.max(t,e)},n.offset=function(t,e){let o=0;for(let s=0;s<n[e].length;s++){if(n[e][s]===t)return o;o+=n[e][s].weight}},n.hasShape=function(){let t=0;return n.linksTo.forEach(e=>{e.outgoing&&t++}),!n.linksTo.length||t!==n.linksTo.length},n.index=this.nodes.push(n)-1,s=n}return s.formatPrefix="node",s.name=s.name||s.options.id||"",s.mass=(0,c.pick)(s.options.mass,s.options.marker&&s.options.marker.radius,this.options.marker&&this.options.marker.radius,4),s},t.destroy=o,t.generatePoints=function(){let t=this.chart,e={};g.generatePoints.call(this),this.nodes||(this.nodes=[]),this.colorCounter=0,this.nodes.forEach(t=>{t.linksFrom.length=0,t.linksTo.length=0,t.level=t.options.level}),this.points.forEach(o=>{(0,c.defined)(o.from)&&(e[o.from]||(e[o.from]=this.createNode(o.from)),e[o.from].linksFrom.push(o),o.fromNode=e[o.from],t.styledMode?o.colorIndex=(0,c.pick)(o.options.colorIndex,e[o.from].colorIndex):o.color=o.options.color||e[o.from].color),(0,c.defined)(o.to)&&(e[o.to]||(e[o.to]=this.createNode(o.to)),e[o.to].linksTo.push(o),o.toNode=e[o.to]),o.name=o.name||o.id},this),this.nodeLookup=e},t.setNodeState=i,t.updateNode=n}(r||(r={}));let x=r,{seriesTypes:{sankey:{prototype:{pointClass:k}}}}=m();class b extends k{isValid(){return!0}}(0,c.extend)(b.prototype,{setState:x.setNodeState});var S=a||(a={});S.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,o=e.slice(),s=t.chart,i=t.options.minLinkWidth||0,n,r=0,a,h=(s.plotSizeY||0)-(t.options.borderWidth||0)-(e.length-1)*t.nodePadding;for(;e.length;){for(r=h/e.sankeyColumn.sum(),n=!1,a=e.length;a--;)e[a].getSum()*r<i&&(e.splice(a,1),h=Math.max(0,h-i),n=!0);if(!n)break}for(let t of(e.length=0,o))e.push(t);return r}top(t){let e=this.series,o=e.nodePadding,s=this.points.reduce((s,i)=>(s>0&&(s+=o),s+=Math.max(i.getSum()*t,e.options.minLinkWidth||0)),0);return(0,c.getAlignFactor)(e.options.nodeAlignment||"center")*((e.chart.plotSizeY||0)-s)}left(t){let e=this.series,o=e.chart,s=e.options.equalNodes,i=o.inverted?o.plotHeight:o.plotWidth,n=e.nodePadding,r=this.points.reduce((o,r)=>(o>0&&(o+=n),o+=s?i/r.series.nodes.length-n:Math.max(r.getSum()*t,e.options.minLinkWidth||0)),0);return((o.plotSizeX||0)-Math.round(r))/2}sum(){return this.points.reduce((t,e)=>t+e.getSum(),0)}offset(t,e){let o=this.points,s=this.series,i=s.nodePadding,n=0,r;if(s.is("organization")&&t.hangsFrom)return{absoluteTop:t.hangsFrom.nodeY};for(let a=0;a<o.length;a++){let h=o[a].getSum(),l=Math.max(h*e,s.options.minLinkWidth||0),d=t.options[s.chart.inverted?"offsetHorizontal":"offsetVertical"],p=t.options.offset||0;if(r=h?l+i:0,o[a]===t)return{relativeTop:n+((0,c.defined)(d)?(0,c.relativeLength)(d,l):(0,c.relativeLength)(p,r))};n+=r}}}S.SankeyColumnAdditions=L;let P=a;var v=d(820),N=d.n(v),T=d(540),C=d.n(T),M=d(28),H=d.n(M);let{composed:W,deg2rad:A}=u();n=H(),(0,c.pushUnique)(W,"TextPath")&&((0,c.addEvent)(n,"afterGetBBox",function(t){let e=t.bBox,o=this.element?.querySelector("textPath");if(o){let t=[],{b:s,h:i}=this.renderer.fontMetrics(this.element),n=i-s,r=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),a=o.innerHTML.replace(r,"").split(/<tspan class="highcharts-br"[^>]*>/),h=a.length,l=(t,e)=>{let{x:i,y:r}=e,a=(o.getRotationOfChar(t)-90)*A,h=Math.cos(a),l=Math.sin(a);return[[i-n*h,r-n*l],[i+s*h,r+s*l]]};for(let e=0,s=0;s<h;s++){let i=a[s].length;for(let n=0;n<i;n+=5)try{let i=e+n+s,[r,a]=l(i,o.getStartPositionOfChar(i));0===n?(t.push(a),t.push(r)):(0===s&&t.unshift(a),s===h-1&&t.push(r))}catch{break}e+=i-1;try{let i=e+s,n=o.getEndPositionOfChar(i),[r,a]=l(i,n);t.unshift(a),t.unshift(r)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}),(0,c.addEvent)(n,"beforeAddingDataLabel",function(t){let e=t.labelOptions,o=t.point,s=e[o.formatPrefix+"TextPath"]||e.textPath;s&&!e.useHTML&&(this.setTextPath(o.getDataLabelPath?.(this)||o.graphic,s),o.dataLabelPath&&!s.enabled&&(o.dataLabelPath=o.dataLabelPath.destroy()))}),n.prototype.setTextPath=n.prototype.setTextPath??function(t,e){let o=this.renderer.url,s=this.text||this,i=s.textPath,{attributes:n,enabled:r}=(0,c.merge)({enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);if(t=t||i&&i.path,i?.undo(),t&&r){let e=(0,c.addEvent)(s,"afterModifyTree",e=>{if(t&&r){let i=t.attr("id");i||t.attr("id",i=(0,c.uniqueKey)());let r={x:0,y:0};(0,c.defined)(n.dx)&&(r.dx=n.dx,delete n.dx),(0,c.defined)(n.dy)&&(r.dy=n.dy,delete n.dy),s.attr(r),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let a=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:(0,c.extend)(n,{"text-anchor":n.textAnchor,href:`${o}#${i}`}),children:a}}});s.textPath={path:t,undo:e}}else s.attr({dx:0,dy:0}),delete s.textPath;return this.added&&(s.textCache="",this.renderer.buildText(s)),this});let{prototype:{symbols:w}}=C(),{seriesTypes:{column:E,sankey:O}}=m();class z extends O{createNodeColumns(){let t=this,e=t.chart,o=P.compose([],t);return o.sankeyColumn.maxLength=e.inverted?e.plotHeight:e.plotWidth,o.sankeyColumn.getTranslationFactor=t=>{let s=o.slice(),i=this.options.minLinkWidth||0,n,r=0,a,h,l=0,d=1,p=0,c=(e.plotSizeX||0)-(t.options.marker&&t.options.marker.lineWidth||0)-(o.length-1)*t.nodePadding;for(;o.length;){for(r=c/o.sankeyColumn.sum(),n=!1,a=o.length;a--;){h=o[a].getSum()*r*d;let t=Math.min(e.plotHeight,e.plotWidth);h>t?d=Math.min(t/h,d):h<i&&(o.splice(a,1),c-=i,h=i,n=!0),p+=h*(1-d)/2,l=Math.max(l,h)}if(!n)break}return o.length=0,s.forEach(t=>{t.scale=d,o.push(t)}),o.sankeyColumn.maxRadius=l,o.sankeyColumn.scale=d,o.sankeyColumn.additionalSpace=p,r},o.sankeyColumn.offset=function(s,i){let n=s.series.options.equalNodes,r=t.nodePadding,a=Math.min(e.plotWidth,e.plotHeight,(o.sankeyColumn.maxLength||0)/t.nodes.length-r),h=o.sankeyColumn.additionalSpace||0,l;for(let e=0;e<o.length;e++){let d=o[e].getSum()*(o.sankeyColumn.scale||0),p=n?a:Math.max(d*i,t.options.minLinkWidth||0);if(l=d?p+r:0,o[e]===s)return{relativeLeft:h+(0,c.relativeLength)(s.options.offset||0,l)};h+=l}},t.nodes.forEach(function(t){t.column=0,o.push(t)}),[o]}translateLink(t){let e=t.fromNode,o=t.toNode,s=this.chart,i=this.translationFactor,n=t.options,r=this.options,a=(0,c.pick)(n.linkWeight,r.linkWeight,Math.max((t.weight||0)*i*e.scale,this.options.minLinkWidth||0)),h=t.series.options.centeredLinks,l=e.nodeY,d=(e,o)=>{let s=(e.offset(t,o)||0)*i;return Math.min(e.nodeX+s,e.nodeX+(e.shapeArgs&&e.shapeArgs.height||0)-a)},p=h?e.nodeX+((e.shapeArgs.height||0)-a)/2:d(e,"linksFrom"),u=h?o.nodeX+((o.shapeArgs.height||0)-a)/2:d(o,"linksTo"),f=l;p>u&&([p,u]=[u,p]),r.reversed&&([p,u]=[u,p],f=(s.plotSizeY||0)-f),t.shapeType="path",t.linkBase=[p,p+a,u,u+a];let m=(u+a-p)/Math.abs(u+a-p)*(0,c.pick)(r.linkRadius,Math.min(Math.abs(u+a-p)/2,e.nodeY-Math.abs(a)));t.shapeArgs={d:[["M",p,f],["A",(u+a-p)/2,m,0,0,1,u+a,f],["L",u,f],["A",(u-p-a)/2,m-a,0,0,0,p+a,f],["Z"]]},t.dlBox={x:p+(u-p)/2,y:f-m,height:a,width:0},t.tooltipPos=s.inverted?[(s.plotSizeY||0)-t.dlBox.y-a/2,(s.plotSizeX||0)-t.dlBox.x]:[t.dlBox.x,t.dlBox.y+a/2],t.y=t.plotY=1,t.x=t.plotX=1,t.color||(t.color=e.color)}translateNode(t,e){let o=this.translationFactor,s=this.chart,i=s.inverted?s.plotWidth:s.plotHeight,n=this.options,r=Math.min(s.plotWidth,s.plotHeight,i/t.series.nodes.length-this.nodePadding),a=t.getSum()*(e.sankeyColumn.scale||0),h=n.equalNodes?r:Math.max(a*o,this.options.minLinkWidth||0),l=n.marker?.lineWidth||0,d=e.sankeyColumn.offset(t,o),p=(0,c.crisp)((0,c.pick)(d&&d.absoluteLeft,(e.sankeyColumn.left(o)||0)+(d&&d.relativeLeft||0)),l),u=(0,c.merge)(n.marker,t.options.marker),f=u.symbol,m=u.radius,g=parseInt(n.offset??"100",10)*((s.inverted?s.plotWidth:s.plotHeight)-((0,c.crisp)(this.colDistance*(t.column||0)+(u.lineWidth||0)/2,l)+(e.sankeyColumn.scale||0)*(e.sankeyColumn.maxRadius||0)/2))/100;if(t.sum=a,a){t.nodeX=p,t.nodeY=g;let e=t.options.width||n.width||h,o=t.options.height||n.height||h,i=g;n.reversed&&(i=(s.plotSizeY||0)-g,s.inverted&&(i=(s.plotSizeY||0)-g)),this.mapOptionsToLevel&&(t.dlOptions={...O.getDLOptions({level:this.mapOptionsToLevel[t.level],optionsPoint:t.options}),zIndex:void 0},delete t.dlOptions.zIndex),t.plotX=1,t.plotY=1,t.tooltipPos=s.inverted?[(s.plotSizeY||0)-i-o/2,(s.plotSizeX||0)-p-e/2]:[p+e/2,i+o/2],t.shapeType="path",t.shapeArgs={d:w[f||"circle"](p,i-(m||o)/2,m||e,m||o),width:m||e,height:m||o},t.dlBox={x:p+e/2,y:i,height:0,width:0}}else t.dlOptions={enabled:!1}}drawDataLabels(){if(this.options.dataLabels){let t=this.options.dataLabels.textPath;E.prototype.drawDataLabels.call(this,this.nodes),this.options.dataLabels.textPath=this.options.dataLabels.linkTextPath,E.prototype.drawDataLabels.call(this,this.data),this.options.dataLabels.textPath=t}}pointAttribs(t,e){if(t&&t.isNode){let{...t}=N().prototype.pointAttribs.apply(this,arguments);return t}return super.pointAttribs.apply(this,arguments)}markerAttribs(t){return t.isNode?super.markerAttribs.apply(this,arguments):{}}}z.defaultOptions=(0,c.merge)(O.defaultOptions,{centeredLinks:!1,equalNodes:!1,dataLabels:{linkTextPath:{attributes:{startOffset:"25%"}}},marker:{fillOpacity:1,lineWidth:0,states:{},symbol:"circle"},offset:"100%",reversed:!1}),(0,c.extend)(z.prototype,{orderNodes:!1}),z.prototype.pointClass=b,m().registerSeriesType("arcdiagram",z);let F=u();return p.default})());