UNPKG

highcharts

Version:
13 lines 29 kB
!/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/networkgraph * @requires highcharts * * Force directed graph 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.SVGElement,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/networkgraph",["highcharts/highcharts"],function(t){return e(t,t.SVGElement,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/networkgraph"]=e(t._Highcharts,t._Highcharts.SVGElement,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.SVGElement,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e,i)=>(()=>{"use strict";var o,s={28:t=>{t.exports=e},512:t=>{t.exports=i},944:e=>{e.exports=t}},r={};function n(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={exports:{}};return s[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var a={};n.d(a,{default:()=>tl});var h=n(944),l=n.n(h),d=n(28),p=n.n(d);let{doc:c,win:u}=l();function f(t,e,i,o={}){let s="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(s,"hcEvents")||(s.hcEvents={});let r=s.hcEvents;l().Point&&t instanceof l().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let n=t.addEventListener;n&&n.call(t,e,i,!!l().supportsPassiveEvents&&{passive:void 0===o.passive?-1!==e.indexOf("touch"):o.passive,capture:!1}),r[e]||(r[e]=[]);let a={fn:i,order:"number"==typeof o.order?o.order:1/0};return r[e].push(a),r[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,i){function o(e,i){let o=t.removeEventListener;o&&o.call(t,e,i,!1)}function s(i){let s,r;t.nodeName&&(e?(s={})[e]=!0:s=i,k(s,function(t,e){if(i[e])for(r=i[e].length;r--;)o(e,i[e][r].fn)}))}let r="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(r,"hcEvents")){let t=r.hcEvents;if(e){let r=t[e]||[];i?(t[e]=r.filter(function(t){return i!==t.fn}),o(e,i)):(s(t),t[e]=[])}else s(t),delete r.hcEvents}}(t,e,i)}}function m(t){return null!=t}function g(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,o=t.length;for(i=0;i<o;i++)if(e(t[i],i))return t[i]};function b(t){return x(t)&&"number"==typeof t.nodeType}function x(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function v(t,...e){let i,o=[t,...e],s={},r=function(t,e){return"object"!=typeof t&&(t={}),k(e,function(i,o){if("__proto__"!==o&&"constructor"!==o){let s;!x(i,!0)||(s=i?.constructor,x(i,!0)&&!b(i)&&s?.name&&"Object"!==s.name)||b(i)?t[o]=e[o]:t[o]=r(t[o]||{},i)}}),t};!0===t&&(s=o[1],o=Array.prototype.slice.call(o,2));let n=o.length;for(i=0;i<n;i++)s=r(s,o[i]);return s}function k(t,e,i){for(let o in t)Object.hasOwnProperty.call(t,o)&&e.call(i||t[o],t[o],o,t)}function N(){let t=arguments,e=t.length;for(let i=0;i<e;i++){let e=t[i];if(null!=e)return e}}function L(t,e){return 0>t.indexOf(e)&&!!t.push(e)}let{composed:P}=l();function w(){let t,e,i,o,s=this;s.container&&(t=f(s.container,"mousedown",t=>{e&&e(),i&&i(),(o=s.hoverPoint)&&o.series&&o.series.hasDraggableNodes&&o.series.options.draggable&&(o.series.onMouseDown(o,t),e=f(s.container,"mousemove",t=>o&&o.series&&o.series.onMouseMove(o,t)),i=f(s.container.ownerDocument,"mouseup",t=>(e(),i(),o&&o.series&&o.series.onMouseUp(o,t))))})),f(s,"destroy",function(){t()})}let S={compose:function(t){L(P,"DragNodes")&&f(t,"load",w)},onMouseDown:function(t,e){let{panKey:i}=this.chart.options.chart;if(i&&e[`${i}Key`])return;let o=this.chart.pointer?.normalize(e)||e;t.fixedPosition={chartX:o.chartX,chartY:o.chartY,plotX:t.plotX,plotY:t.plotY},t.inDragMode=!0},onMouseMove:function(t,e){if(t.fixedPosition&&t.inDragMode){let i,o,s=this.chart,r=s.pointer?.normalize(e)||e,n=t.fixedPosition.chartX-r.chartX,a=t.fixedPosition.chartY-r.chartY,h=s.graphLayoutsLookup;(Math.abs(n)>5||Math.abs(a)>5)&&(i=t.fixedPosition.plotX-n,o=t.fixedPosition.plotY-a,s.isInsidePlot(i,o)&&(t.plotX=i,t.plotY=o,t.hasDragged=!0,this.redrawHalo(t),h.forEach(t=>{t.restartSimulation()})))}},onMouseUp:function(t){t.fixedPosition&&(t.hasDragged&&(this.layout.enableSimulation?this.layout.start():this.chart.redraw()),t.inDragMode=t.hasDragged=!1,this.options.fixedDraggable||delete t.fixedPosition)},redrawHalo:function(t){t&&this.halo&&this.halo.attr({d:t.haloPath(this.options.states.hover.halo.size)})}},{setAnimation:E}=l(),{composed:M}=l();function T(){this.graphLayoutsLookup&&(this.graphLayoutsLookup.forEach(t=>{t.updateSimulation()}),this.redraw())}function X(){this.graphLayoutsLookup&&(this.graphLayoutsLookup.forEach(t=>{t.updateSimulation(!1)}),this.redraw())}function Y(){this.graphLayoutsLookup&&this.graphLayoutsLookup.forEach(t=>{t.stop()})}function D(){let t,e=!1,i=i=>{i.maxIterations--&&isFinite(i.temperature)&&!i.isStable()&&!i.enableSimulation&&(i.beforeStep&&i.beforeStep(),i.step(),t=!1,e=!0)};if(this.graphLayoutsLookup&&!this.pointer?.hasDragged){for(E(!1,this),this.graphLayoutsLookup.forEach(t=>t.start());!t;)t=!0,this.graphLayoutsLookup.forEach(i);e&&this.series.forEach(t=>{t&&t.layout&&t.render()})}}let F=function(t){L(M,"GraphLayout")&&(f(t,"afterPrint",T),f(t,"beforePrint",X),f(t,"predraw",Y),f(t,"render",D))},O={},C={};var A=n(512),I=n.n(A);let{series:{prototype:R,prototype:{pointClass:{prototype:H}}}}=I();!function(t){function e(){return this.data=[].concat(this.points||[],this.nodes),R.destroy.apply(this,arguments)}function i(){this.nodes&&(this.nodes.forEach(t=>{t.destroy()}),this.nodes.length=0),R.setData.apply(this,arguments)}function o(t){let e=arguments,i=this.isNode?this.linksTo.concat(this.linksFrom):[this.fromNode,this.toNode];"select"!==t&&i.forEach(t=>{t&&t.series&&(H.setState.apply(t,e),!t.isNode&&(t.fromNode.graphic&&H.setState.apply(t.fromNode,e),t.toNode&&t.toNode.graphic&&H.setState.apply(t.toNode,e)))}),H.setState.apply(this,e)}function s(t,e,i,o){let s=this.series.options.nodes,r=this.series.options.data,n=r?.length||0,a=r?.[this.index];if(H.update.call(this,t,!this.isNode&&e,i,o),this.isNode){let t=(s||[]).reduce((t,e,i)=>this.id===e.id?i:t,-1),o=v(s&&s[t]||{},r?.[this.index]||{});r&&(a?r[this.index]=a:r.length=n),s?t>=0?s[t]=o:s.push(o):this.series.options.nodes=[o],N(e,!0)&&this.series.chart.redraw(i)}}t.compose=function(t,r){let n=t.prototype,a=r.prototype;return n.setNodeState=o,n.setState=o,n.update=s,a.destroy=e,a.setData=i,r},t.createNode=function(t){let e=this.pointClass,i=(t,e)=>y(t,t=>t.id===e),o=i(this.nodes,t),s;if(!o){s=this.options.nodes&&i(this.options.nodes,t);let r=new e(this,g({className:"highcharts-node",isNode:!0,id:t,y:1},s));r.linksTo=[],r.linksFrom=[],r.getSum=function(){let t=0,e=0;return r.linksTo.forEach(e=>{t+=e.weight||0}),r.linksFrom.forEach(t=>{e+=t.weight||0}),Math.max(t,e)},r.offset=function(t,e){let i=0;for(let o=0;o<r[e].length;o++){if(r[e][o]===t)return i;i+=r[e][o].weight}},r.hasShape=function(){let t=0;return r.linksTo.forEach(e=>{e.outgoing&&t++}),!r.linksTo.length||t!==r.linksTo.length},r.index=this.nodes.push(r)-1,o=r}return o.formatPrefix="node",o.name=o.name||o.options.id||"",o.mass=N(o.options.mass,o.options.marker&&o.options.marker.radius,this.options.marker&&this.options.marker.radius,4),o},t.destroy=e,t.generatePoints=function(){let t=this.chart,e={};R.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(i=>{m(i.from)&&(e[i.from]||(e[i.from]=this.createNode(i.from)),e[i.from].linksFrom.push(i),i.fromNode=e[i.from],t.styledMode?i.colorIndex=N(i.options.colorIndex,e[i.from].colorIndex):i.color=i.options.color||e[i.from].color),m(i.to)&&(e[i.to]||(e[i.to]=this.createNode(i.to)),e[i.to].linksTo.push(i),i.toNode=e[i.to]),i.name=i.name||i.id},this),this.nodeLookup=e},t.setNodeState=o,t.updateNode=s}(o||(o={}));let j=o,{series:{prototype:B,prototype:{pointClass:G}}}=I();class _ extends G{destroy(){return this.isNode&&this.linksFrom.concat(this.linksTo).forEach(function(t){t.destroyElements&&t.destroyElements()}),this.series.layout.removeElementFromCollection(this,this.series.layout[this.isNode?"nodes":"links"]),G.prototype.destroy.apply(this,arguments)}getDegree(){let t=this.isNode?this.linksFrom.length+this.linksTo.length:0;return 0===t?1:t}getLinkAttributes(){let t=this.series.options.link,e=this.options;return{"stroke-width":N(e.width,t.width),stroke:e.color||t.color,dashstyle:e.dashStyle||t.dashStyle,opacity:N(e.opacity,t.opacity,1)}}getLinkPath(){let t=this.fromNode,e=this.toNode;return t.plotX>e.plotX&&(t=this.toNode,e=this.fromNode),[["M",t.plotX||0,t.plotY||0],["L",e.plotX||0,e.plotY||0]]}getMass(){let t=this.fromNode.mass,e=this.toNode.mass,i=t+e;return{fromNode:1-t/i,toNode:1-e/i}}constructor(t,e,i){super(t,e,i),this.series.options.draggable&&!this.series.chart.styledMode&&(f(this,"mouseOver",function(){var t;t=this.series.chart.container,g(t.style,{cursor:"move"})}),f(this,"mouseOut",function(){var t;t=this.series.chart.container,g(t.style,{cursor:"default"})}))}isValid(){return!this.isNode||m(this.id)}redrawLink(){let t,e=this.getLinkPath();if(this.graphic){this.shapeArgs={d:e},this.series.chart.styledMode||(t=this.series.pointAttribs(this),this.graphic.attr(t),(this.dataLabels||[]).forEach(function(e){e&&e.attr({opacity:t.opacity})})),this.graphic.animate(this.shapeArgs);let i=e[0],o=e[1];"M"===i[0]&&"L"===o[0]&&(this.plotX=(i[1]+o[1])/2,this.plotY=(i[2]+o[2])/2)}}remove(t,e){let i=this.series,o=i.options.nodes||[],s,r=o.length;if(this.isNode){for(i.points=[],[].concat(this.linksFrom).concat(this.linksTo).forEach(function(t){(s=t.fromNode.linksFrom.indexOf(t))>-1&&t.fromNode.linksFrom.splice(s,1),(s=t.toNode.linksTo.indexOf(t))>-1&&t.toNode.linksTo.splice(s,1),B.removePoint.call(i,i.data.indexOf(t),!1,!1)}),i.points=i.data.slice(),i.nodes.splice(i.nodes.indexOf(this),1);r--;)if(o[r].id===this.options.id){i.options.nodes.splice(r,1);break}this&&this.destroy(),i.isDirty=!0,i.isDirtyData=!0,t&&i.chart.redraw(t)}else i.removePoint(i.data.indexOf(this),t,e)}renderLink(){let t;!this.graphic&&(this.graphic=this.series.chart.renderer.path(this.getLinkPath()).addClass(this.getClassName(),!0).add(this.series.group),this.series.chart.styledMode||(t=this.series.pointAttribs(this),this.graphic.attr(t),(this.dataLabels||[]).forEach(function(e){e&&e.attr({opacity:t.opacity})})))}}g(_.prototype,{setState:j.setNodeState});let q={attractive:function(t,e,i,o){let s=t.getMass(),r=i.x/o*e,n=i.y/o*e;t.fromNode.fixedPosition||(t.fromNode.dispX-=r*s.fromNode/t.fromNode.degree,t.fromNode.dispY-=n*s.fromNode/t.fromNode.degree),t.toNode.fixedPosition||(t.toNode.dispX+=r*s.toNode/t.toNode.degree,t.toNode.dispY+=n*s.toNode/t.toNode.degree)},attractiveForceFunction:function(t,e){return t*t/e},barycenter:function(){let t=this.options.gravitationalConstant,e=this.barycenter.xFactor,i=this.barycenter.yFactor;this.nodes.forEach(function(o){if(!o.fixedPosition){let s=o.getDegree(),r=s*(1+s/2);o.dispX+=(e-o.plotX)*t*r/o.degree,o.dispY+=(i-o.plotY)*t*r/o.degree}})},getK:function(t){return Math.pow(t.box.width*t.box.height/t.nodes.length,.3)},integrate:function(t,e){e.dispX+=e.dispX*t.options.friction,e.dispY+=e.dispY*t.options.friction;let i=e.temperature=t.vectorLength({x:e.dispX,y:e.dispY});0!==i&&(e.plotX+=e.dispX/i*Math.min(Math.abs(e.dispX),t.temperature),e.plotY+=e.dispY/i*Math.min(Math.abs(e.dispY),t.temperature))},repulsive:function(t,e,i,o){t.dispX+=i.x/o*e/t.degree,t.dispY+=i.y/o*e/t.degree},repulsiveForceFunction:function(t,e){return e*e/t}};class K{constructor(t){this.body=!1,this.isEmpty=!1,this.isInternal=!1,this.nodes=[],this.box=t,this.boxSize=Math.min(t.width,t.height)}divideBox(){let t=this.box.width/2,e=this.box.height/2;this.nodes[0]=new K({left:this.box.left,top:this.box.top,width:t,height:e}),this.nodes[1]=new K({left:this.box.left+t,top:this.box.top,width:t,height:e}),this.nodes[2]=new K({left:this.box.left+t,top:this.box.top+e,width:t,height:e}),this.nodes[3]=new K({left:this.box.left,top:this.box.top+e,width:t,height:e})}getBoxPosition(t){let e=t.plotX<this.box.left+this.box.width/2,i=t.plotY<this.box.top+this.box.height/2;return e?3*!i:i?1:2}insert(t,e){let i;this.isInternal?this.nodes[this.getBoxPosition(t)].insert(t,e-1):(this.isEmpty=!1,this.body?e?(this.isInternal=!0,this.divideBox(),!0!==this.body&&(this.nodes[this.getBoxPosition(this.body)].insert(this.body,e-1),this.body=!0),this.nodes[this.getBoxPosition(t)].insert(t,e-1)):((i=new K({top:t.plotX||NaN,left:t.plotY||NaN,width:.1,height:.1})).body=t,i.isInternal=!1,this.nodes.push(i)):(this.isInternal=!1,this.body=t))}updateMassAndCenter(){let t=0,e=0,i=0;if(this.isInternal){for(let o of this.nodes)o.isEmpty||(t+=o.mass,e+=o.plotX*o.mass,i+=o.plotY*o.mass);e/=t,i/=t}else this.body&&(t=this.body.mass,e=this.body.plotX,i=this.body.plotY);this.mass=t,this.plotX=e,this.plotY=i}}let z=class{constructor(t,e,i,o){this.box={left:t,top:e,width:i,height:o},this.maxDepth=25,this.root=new K(this.box),this.root.isInternal=!0,this.root.isRoot=!0,this.root.divideBox()}calculateMassAndCenter(){this.visitNodeRecursive(null,null,function(t){t.updateMassAndCenter()})}insertNodes(t){for(let e of t)this.root.insert(e,this.maxDepth)}visitNodeRecursive(t,e,i){let o;if(t||(t=this.root),t===this.root&&e&&(o=e(t)),!1!==o){for(let s of t.nodes){if(s.isInternal){if(e&&(o=e(s)),!1===o)continue;this.visitNodeRecursive(s,e,i)}else s.body&&e&&e(s.body);i&&i(s)}t===this.root&&i&&i(t)}}},U={attractive:function(t,e,i){let o=t.getMass(),s=-i.x*e*this.diffTemperature,r=-i.y*e*this.diffTemperature;t.fromNode.fixedPosition||(t.fromNode.plotX-=s*o.fromNode/t.fromNode.degree,t.fromNode.plotY-=r*o.fromNode/t.fromNode.degree),t.toNode.fixedPosition||(t.toNode.plotX+=s*o.toNode/t.toNode.degree,t.toNode.plotY+=r*o.toNode/t.toNode.degree)},attractiveForceFunction:function(t,e){return(e-t)/t},barycenter:function(){let t=this.options.gravitationalConstant||0,e=(this.barycenter.xFactor-(this.box.left+this.box.width)/2)*t,i=(this.barycenter.yFactor-(this.box.top+this.box.height)/2)*t;this.nodes.forEach(function(t){t.fixedPosition||(t.plotX-=e/t.mass/t.degree,t.plotY-=i/t.mass/t.degree)})},getK:function(t){return Math.pow(t.box.width*t.box.height/t.nodes.length,.5)},integrate:function(t,e){let i=-t.options.friction,o=t.options.maxSpeed,s=e.prevX,r=e.prevY,n=(e.plotX+e.dispX-s)*i,a=(e.plotY+e.dispY-r)*i,h=Math.abs,l=h(n)/(n||1),d=h(a)/(a||1),p=l*Math.min(o,Math.abs(n)),c=d*Math.min(o,Math.abs(a));e.prevX=e.plotX+e.dispX,e.prevY=e.plotY+e.dispY,e.plotX+=p,e.plotY+=c,e.temperature=t.vectorLength({x:p,y:c})},repulsive:function(t,e,i){let o=e*this.diffTemperature/t.mass/t.degree;t.fixedPosition||(t.plotX+=i.x*o,t.plotY+=i.y*o)},repulsiveForceFunction:function(t,e){return(e-t)/t*(e>t)}},{win:V}=l();class ${constructor(){this.box={},this.currentStep=0,this.initialRendering=!0,this.links=[],this.nodes=[],this.series=[],this.simulation=!1}static compose(t){F(t),O.euler=q,O.verlet=U,C["reingold-fruchterman"]=$}init(t){this.options=t,this.nodes=[],this.links=[],this.series=[],this.box={x:0,y:0,width:0,height:0},this.setInitialRendering(!0),this.integration=O[t.integration],this.enableSimulation=t.enableSimulation,this.attractiveForce=N(t.attractiveForce,this.integration.attractiveForceFunction),this.repulsiveForce=N(t.repulsiveForce,this.integration.repulsiveForceFunction),this.approximation=t.approximation}updateSimulation(t){this.enableSimulation=N(t,this.options.enableSimulation)}start(){let t=this.series,e=this.options;this.currentStep=0,this.forces=t[0]&&t[0].forces||[],this.chart=t[0]&&t[0].chart,this.initialRendering&&(this.initPositions(),t.forEach(function(t){t.finishedAnimating=!0,t.render()})),this.setK(),this.resetSimulation(e),this.enableSimulation&&this.step()}step(){let t=this.series;for(let t of(this.currentStep++,"barnes-hut"===this.approximation&&(this.createQuadTree(),this.quadTree.calculateMassAndCenter()),this.forces||[]))this[t+"Forces"](this.temperature);if(this.applyLimits(),this.temperature=this.coolDown(this.startTemperature,this.diffTemperature,this.currentStep),this.prevSystemTemperature=this.systemTemperature,this.systemTemperature=this.getSystemTemperature(),this.enableSimulation){for(let e of t)e.chart&&e.render();this.maxIterations--&&isFinite(this.temperature)&&!this.isStable()?(this.simulation&&V.cancelAnimationFrame(this.simulation),this.simulation=V.requestAnimationFrame(()=>this.step())):(this.simulation=!1,this.series.forEach(t=>{!function(t,e,i,o){if(i=i||{},c?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==l())){let o=c.createEvent("Events");o.initEvent(e,!0,!0),i=g(o,i),t.dispatchEvent?t.dispatchEvent(i):t.fireEvent(e,i)}else if(t.hcEvents){i.target||g(i,{preventDefault:function(){i.defaultPrevented=!0},target:t,type:e});let o=[],s=t,r=!1;for(;s.hcEvents;)Object.hasOwnProperty.call(s,"hcEvents")&&s.hcEvents[e]&&(o.length&&(r=!0),o.unshift.apply(o,s.hcEvents[e])),s=Object.getPrototypeOf(s);r&&o.sort((t,e)=>t.order-e.order),o.forEach(e=>{!1===e.fn.call(t,i,t)&&i.preventDefault()})}}(t,"afterSimulation")}))}}stop(){this.simulation&&V.cancelAnimationFrame(this.simulation)}setArea(t,e,i,o){this.box={left:t,top:e,width:i,height:o}}setK(){this.k=this.options.linkLength||this.integration.getK(this)}addElementsToCollection(t,e){for(let i of t)-1===e.indexOf(i)&&e.push(i)}removeElementFromCollection(t,e){let i=e.indexOf(t);-1!==i&&e.splice(i,1)}clear(){this.nodes.length=0,this.links.length=0,this.series.length=0,this.resetSimulation()}resetSimulation(){this.forcedStop=!1,this.systemTemperature=0,this.setMaxIterations(),this.setTemperature(),this.setDiffTemperature()}restartSimulation(){this.simulation?this.resetSimulation():(this.setInitialRendering(!1),this.enableSimulation?this.start():this.setMaxIterations(1),this.chart&&this.chart.redraw(),this.setInitialRendering(!0))}setMaxIterations(t){this.maxIterations=N(t,this.options.maxIterations)}setTemperature(){this.temperature=this.startTemperature=Math.sqrt(this.nodes.length)}setDiffTemperature(){this.diffTemperature=this.startTemperature/(this.options.maxIterations+1)}setInitialRendering(t){this.initialRendering=t}createQuadTree(){this.quadTree=new z(this.box.left,this.box.top,this.box.width,this.box.height),this.quadTree.insertNodes(this.nodes)}initPositions(){let t=this.options.initialPositions;if("function"==typeof t)for(let e of(t.call(this),this.nodes))m(e.prevX)||(e.prevX=e.plotX),m(e.prevY)||(e.prevY=e.plotY),e.dispX=0,e.dispY=0;else"circle"===t?this.setCircularPositions():this.setRandomPositions()}setCircularPositions(){let t,e=this.box,i=this.nodes,o=2*Math.PI/(i.length+1),s=i.filter(function(t){return 0===t.linksTo.length}),r={},n=this.options.initialPositionRadius,a=t=>{for(let e of t.linksFrom||[])r[e.toNode.id]||(r[e.toNode.id]=!0,h.push(e.toNode),a(e.toNode))},h=[];for(let t of s)h.push(t),a(t);if(h.length)for(let t of i)-1===h.indexOf(t)&&h.push(t);else h=i;for(let i=0,s=h.length;i<s;++i)(t=h[i]).plotX=t.prevX=N(t.plotX,e.width/2+n*Math.cos(i*o)),t.plotY=t.prevY=N(t.plotY,e.height/2+n*Math.sin(i*o)),t.dispX=0,t.dispY=0}setRandomPositions(){let t,e=this.box,i=this.nodes,o=i.length+1,s=t=>{let e=t*t/Math.PI;return e-Math.floor(e)};for(let r=0,n=i.length;r<n;++r)(t=i[r]).plotX=t.prevX=N(t.plotX,e.width*s(r)),t.plotY=t.prevY=N(t.plotY,e.height*s(o+r)),t.dispX=0,t.dispY=0}force(t,...e){this.integration[t].apply(this,e)}barycenterForces(){this.getBarycenter(),this.force("barycenter")}getBarycenter(){let t=0,e=0,i=0;for(let o of this.nodes)e+=o.plotX*o.mass,i+=o.plotY*o.mass,t+=o.mass;return this.barycenter={x:e,y:i,xFactor:e/t,yFactor:i/t},this.barycenter}barnesHutApproximation(t,e){let i,o,s=this.getDistXY(t,e),r=this.vectorLength(s);return t!==e&&0!==r&&(e.isInternal?e.boxSize/r<this.options.theta&&0!==r?(o=this.repulsiveForce(r,this.k),this.force("repulsive",t,o*e.mass,s,r),i=!1):i=!0:(o=this.repulsiveForce(r,this.k),this.force("repulsive",t,o*e.mass,s,r))),i}repulsiveForces(){if("barnes-hut"===this.approximation)for(let t of this.nodes)this.quadTree.visitNodeRecursive(null,e=>this.barnesHutApproximation(t,e));else{let t,e,i;for(let o of this.nodes)for(let s of this.nodes)o===s||o.fixedPosition||(i=this.getDistXY(o,s),0!==(e=this.vectorLength(i))&&(t=this.repulsiveForce(e,this.k),this.force("repulsive",o,t*s.mass,i,e)))}}attractiveForces(){let t,e,i;for(let o of this.links)o.fromNode&&o.toNode&&(t=this.getDistXY(o.fromNode,o.toNode),0!==(e=this.vectorLength(t))&&(i=this.attractiveForce(e,this.k),this.force("attractive",o,i,t,e)))}applyLimits(){for(let t of this.nodes)t.fixedPosition||(this.integration.integrate(this,t),this.applyLimitBox(t,this.box),t.dispX=0,t.dispY=0)}applyLimitBox(t,e){var i,o,s,r,n,a;let h=t.radius;i=t.plotX,o=e.left+h,s=e.width-h,t.plotX=i>o?i<s?i:s:o,r=t.plotY,n=e.top+h,a=e.height-h,t.plotY=r>n?r<a?r:a:n}coolDown(t,e,i){return t-e*i}isStable(){return 1e-5>Math.abs(this.systemTemperature-this.prevSystemTemperature)||this.temperature<=0}getSystemTemperature(){let t=0;for(let e of this.nodes)t+=e.temperature;return t}vectorLength(t){return Math.sqrt(t.x*t.x+t.y*t.y)}getDistR(t,e){let i=this.getDistXY(t,e);return this.vectorLength(i)}getDistXY(t,e){let i=t.plotX-e.plotX,o=t.plotY-e.plotY;return{x:i,y:o,absX:Math.abs(i),absY:Math.abs(o)}}}let{animObject:Q}=l(),{deg2rad:W}=l();function J(t,e){e=v(!0,{enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);let i=this.renderer.url,o=this.text||this,s=o.textPath,{attributes:r,enabled:n}=e;if(t=t||s&&s.path,s&&s.undo(),t&&n){let e=f(o,"afterModifyTree",e=>{if(t&&n){let s=t.attr("id");s||t.attr("id",s=(0,h.uniqueKey)());let n={x:0,y:0};m(r.dx)&&(n.dx=r.dx,delete r.dx),m(r.dy)&&(n.dy=r.dy,delete r.dy),o.attr(n),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:g(r,{"text-anchor":r.textAnchor,href:`${i}#${s}`}),children:a}}});o.textPath={path:t,undo:e}}else o.attr({dx:0,dy:0}),delete o.textPath;return this.added&&(o.textCache="",this.renderer.buildText(o)),this}function Z(t){let e=t.bBox,i=this.element?.querySelector("textPath");if(i){let t=[],{b:o,h:s}=this.renderer.fontMetrics(this.element),r=s-o,n=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),a=i.innerHTML.replace(n,"").split(/<tspan class="highcharts-br"[^>]*>/),h=a.length,l=(t,e)=>{let{x:s,y:n}=e,a=(i.getRotationOfChar(t)-90)*W,h=Math.cos(a),l=Math.sin(a);return[[s-r*h,n-r*l],[s+o*h,n+o*l]]};for(let e=0,o=0;o<h;o++){let s=a[o].length;for(let r=0;r<s;r+=5)try{let s=e+r+o,[n,a]=l(s,i.getStartPositionOfChar(s));0===r?(t.push(a),t.push(n)):(0===o&&t.unshift(a),o===h-1&&t.push(n))}catch{break}e+=s-1;try{let s=e+o,r=i.getEndPositionOfChar(s),[n,a]=l(s,r);t.unshift(a),t.unshift(n)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}function tt(t){let e=t.labelOptions,i=t.point,o=e[i.formatPrefix+"TextPath"]||e.textPath;o&&!e.useHTML&&(this.setTextPath(i.getDataLabelPath?.(this)||i.graphic,o),i.dataLabelPath&&!o.enabled&&(i.dataLabelPath=i.dataLabelPath.destroy()))}let{noop:te}=l(),{series:ti,seriesTypes:{column:{prototype:to},line:{prototype:ts}}}=I(),{initDataLabels:tr,initDataLabelsDefer:tn}={initDataLabels:function(){let t=this.options.dataLabels;if(!this.dataLabelsGroup){let e=this.initDataLabelsGroup(0,t);return!this.chart.styledMode&&t?.style&&e.css(t.style),e.attr({opacity:0}),this.visible&&(this.options.animation&&t?.animation?e.animate({opacity:1},t.animation):e.attr({opacity:1}),e.show()),e}return this.dataLabelsGroup.attr({opacity:1,...this.getPlotBox("data-labels")}),this.dataLabelsGroup},initDataLabelsDefer:function(){let t=this.options.dataLabels;if(t?.defer&&this.options.layoutAlgorithm?.enableSimulation){var e,i;e=()=>{this.deferDataLabels=!1},(i=t?Q(t.animation).defer:0)>0?setTimeout(e,i,void 0):e.call(0,void 0)}else this.deferDataLabels=!1}};({compose:function(t){f(t,"afterGetBBox",Z),f(t,"beforeAddingDataLabel",tt);let e=t.prototype;e.setTextPath||(e.setTextPath=J)}}).compose(p());class ta extends ti{constructor(){super(...arguments),this.deferDataLabels=!0}static compose(t){S.compose(t),$.compose(t)}deferLayout(){let t=this.options.layoutAlgorithm,e=this.chart.options.chart,i,o=this.chart.graphLayoutsStorage,s=this.chart.graphLayoutsLookup;this.visible&&(o||(this.chart.graphLayoutsStorage=o={},this.chart.graphLayoutsLookup=s=[]),(i=o[t.type])||(t.enableSimulation=m(e.forExport)?!e.forExport:t.enableSimulation,o[t.type]=i=new C[t.type],i.init(t),s.splice(i.index,0,i)),this.layout=i,i.setArea(0,0,this.chart.plotWidth,this.chart.plotHeight),i.addElementsToCollection([this],i.series),i.addElementsToCollection(this.nodes,i.nodes),i.addElementsToCollection(this.points,i.links))}destroy(){this.layout&&this.layout.removeElementFromCollection(this,this.layout.series),j.destroy.call(this)}drawDataLabels(){let t;if(this.deferDataLabels)return;let e=this.options.dataLabels;e?.textPath&&(t=e.textPath),ti.prototype.drawDataLabels.call(this,this.nodes),e?.linkTextPath&&(e.textPath=e.linkTextPath),ti.prototype.drawDataLabels.call(this,this.data),e?.textPath&&(e.textPath=t)}generatePoints(){let t,e;for(j.generatePoints.apply(this,arguments),this.options.nodes&&this.options.nodes.forEach(function(t){this.nodeLookup[t.id]||(this.nodeLookup[t.id]=this.createNode(t.id))},this),e=this.nodes.length-1;e>=0;e--)(t=this.nodes[e]).degree=t.getDegree(),t.radius=N(t.marker&&t.marker.radius,this.options.marker&&this.options.marker.radius,0),t.key=t.name,this.nodeLookup[t.id]||t.remove();this.data.forEach(function(t){t.formatPrefix="link"}),this.indexateNodes()}getPointsCollection(){return this.nodes||[]}indexateNodes(){this.nodes.forEach(function(t,e){t.index=e})}init(t,e){return super.init(t,e),tn.call(this),f(this,"updatedData",()=>{this.layout&&this.layout.stop()}),f(this,"afterUpdate",()=>{this.nodes.forEach(t=>{t&&t.series&&t.resolveColor()})}),f(this,"afterSimulation",function(){this.deferDataLabels=!1,this.drawDataLabels()}),this}markerAttribs(t,e){let i=ti.prototype.markerAttribs.call(this,t,e);return m(t.plotY)||(i.y=0),i.x=(t.plotX||0)-(i.width||0)/2,i}pointAttribs(t,e){let i=e||t&&t.state||"normal",o=this.options.states[i],s=ti.prototype.pointAttribs.call(this,t,i);return t&&!t.isNode&&(s=t.getLinkAttributes(),o&&(s={stroke:o.linkColor||s.stroke,dashstyle:o.linkDashStyle||s.dashstyle,opacity:N(o.linkOpacity,s.opacity),"stroke-width":o.linkColor||s["stroke-width"]})),s}render(){let t=this.points,e=this.chart.hoverPoint,i=[];this.points=this.nodes,ts.render.call(this),this.points=t,t.forEach(function(t){t.fromNode&&t.toNode&&(t.renderLink(),t.redrawLink())}),e&&e.series===this&&this.redrawHalo(e),this.chart.hasRendered&&!this.options.dataLabels.allowOverlap&&(this.nodes.concat(this.points).forEach(function(t){t.dataLabel&&i.push(t.dataLabel)}),this.chart.hideOverlappingLabels(i))}setState(t,e){e?(this.points=this.nodes.concat(this.data),ti.prototype.setState.apply(this,arguments),this.points=this.data):ti.prototype.setState.apply(this,arguments),this.layout.simulation||t||this.render()}translate(){this.generatePoints(),this.deferLayout(),this.nodes.forEach(function(t){t.isInside=!0,t.linksFrom.forEach(function(t){t.shapeType="path",t.y=1})})}}ta.defaultOptions=v(ti.defaultOptions,{stickyTracking:!1,inactiveOtherPoints:!0,marker:{enabled:!0,states:{inactive:{opacity:.3,animation:{duration:50}}}},states:{inactive:{linkOpacity:.3,animation:{duration:50}}},dataLabels:{formatter:function(){return String(this.key??"")},linkFormatter:function(){return this.fromNode.name+"<br>"+this.toNode.name},linkTextPath:{enabled:!0},textPath:{enabled:!1},style:{transition:"opacity 2000ms"},defer:!0,animation:{defer:1e3}},link:{color:"rgba(100, 100, 100, 0.5)",width:1},draggable:!0,layoutAlgorithm:{initialPositions:"circle",initialPositionRadius:1,enableSimulation:!1,theta:.5,maxSpeed:10,approximation:"none",type:"reingold-fruchterman",integration:"euler",maxIterations:1e3,gravitationalConstant:.0625,friction:-.981},showInLegend:!1}),g(ta.prototype,{pointClass:_,animate:void 0,directTouch:!0,drawGraph:void 0,forces:["barycenter","repulsive","attractive"],hasDraggableNodes:!0,isCartesian:!1,noSharedTooltip:!0,pointArrayMap:["from","to"],requireSorting:!1,trackerGroups:["group","markerGroup","dataLabelsGroup"],initDataLabels:tr,buildKDTree:te,createNode:j.createNode,drawTracker:to.drawTracker,onMouseDown:S.onMouseDown,onMouseMove:S.onMouseMove,onMouseUp:S.onMouseUp,redrawHalo:S.redrawHalo}),I().registerSeriesType("networkgraph",ta);let th=l();ta.compose(th.Chart);let tl=l();return a.default})());