UNPKG

highcharts

Version:
13 lines 16 kB
!/** * Highcharts Gantt JS v12.6.0 (2026-04-13) * @module highcharts/modules/pathfinder * @requires highcharts * * Pathfinder * * (c) 2016-2026 Highsoft AS * Author: Øystein Moseng * * 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.Point):"function"==typeof define&&define.amd?define("highcharts/modules/pathfinder",["highcharts/highcharts"],function(t){return e(t,t.Point)}):"object"==typeof exports?exports["highcharts/modules/pathfinder"]=e(t._Highcharts,t._Highcharts.Point):t.Highcharts=e(t.Highcharts,t.Highcharts.Point)}("u"<typeof window?this:window,(t,e)=>(()=>{"use strict";var n,r={260:t=>{t.exports=e},944:e=>{e.exports=t}},i={};function o(t){var e=i[t];if(void 0!==e)return e.exports;var n=i[t]={exports:{}};return r[t](n,n.exports,o),n.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var a={};o.d(a,{default:()=>z});var s=o(944),h=o.n(s);let{doc:c,win:l}=h();function x(t,e,n,r={}){let i="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(i,"hcEvents")||(i.hcEvents={});let o=i.hcEvents;h().Point&&t instanceof h().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let a=t.addEventListener;a&&a.call(t,e,n,!!h().supportsPassiveEvents&&{passive:void 0===r.passive?-1!==e.indexOf("touch"):r.passive,capture:!1}),o[e]||(o[e]=[]);let s={fn:n,order:"number"==typeof r.order?r.order:1/0};return o[e].push(s),o[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,n){function r(e,n){let r=t.removeEventListener;r&&r.call(t,e,n,!1)}function i(n){let i,o;t.nodeName&&(e?(i={})[e]=!0:i=n,d(i,function(t,e){if(n[e])for(o=n[e].length;o--;)r(e,n[e][o].fn)}))}let o="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(o,"hcEvents")){let t=o.hcEvents;if(e){let o=t[e]||[];n?(t[e]=o.filter(function(t){return n!==t.fn}),r(e,n)):(i(t),t[e]=[])}else i(t),delete o.hcEvents}}(t,e,n)}}function M(t){return f(t)&&"number"==typeof t.nodeType}function p(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function f(t,e){return!!t&&"object"==typeof t&&(!e||!p(t))}function y(t,...e){let n,r=[t,...e],i={},o=function(t,e){return"object"!=typeof t&&(t={}),d(e,function(n,r){if("__proto__"!==r&&"constructor"!==r){let i;!f(n,!0)||(i=n?.constructor,f(n,!0)&&!M(n)&&i?.name&&"Object"!==i.name)||M(n)?t[r]=e[r]:t[r]=o(t[r]||{},n)}}),t};!0===t&&(i=r[1],r=Array.prototype.slice.call(r,2));let a=r.length;for(n=0;n<a;n++)i=o(i,r[n]);return i}function d(t,e,n){for(let r in t)Object.hasOwnProperty.call(t,r)&&e.call(n||t[r],t[r],r,t)}function u(){let t=arguments,e=t.length;for(let n=0;n<e;n++){let e=t[n];if(null!=e)return e}}Array.prototype.find;let g=h().deg2rad,m=Math.max,b=Math.min,P=class{constructor(t,e,n){this.init(t,e,n)}init(t,e,n){this.fromPoint=t,this.toPoint=e,this.options=n,this.chart=t.series.chart,this.pathfinder=this.chart.pathfinder}renderPath(t,e){let n=this.chart,r=n.styledMode,i=this.pathfinder,o={},a=this.graphics&&this.graphics.path;i.group||(i.group=n.renderer.g().addClass("highcharts-pathfinder-group").attr({zIndex:-1}).add(n.seriesGroup)),i.group.translate(n.plotLeft,n.plotTop),!(a&&a.renderer)&&(a=n.renderer.path().add(i.group),r||a.attr({opacity:0})),a.attr(e),o.d=t,r||(o.opacity=1),a.animate(o),this.graphics=this.graphics||{},this.graphics.path=a}addMarker(t,e,n){let r,i,o,a,s,h,c,l=this.fromPoint.series.chart,x=l.pathfinder,M=l.renderer,p="start"===t?this.fromPoint:this.toPoint,f=p.getPathfinderAnchorPoint(e);e.enabled&&((c="start"===t?n[1]:n[n.length-2])&&"M"===c[0]||"L"===c[0])&&(h={x:c[1],y:c[2]},i=p.getRadiansToVector(h,f),r=p.getMarkerVector(i,e.radius,f),e.width&&e.height?(a=e.width,s=e.height):a=s=2*e.radius,this.graphics=this.graphics||{},o={x:r.x-a/2,y:r.y-s/2,width:a,height:s,rotation:-i/g,rotationOriginX:r.x,rotationOriginY:r.y},this.graphics[t]?this.graphics[t].animate(o):(this.graphics[t]=M.symbol(e.symbol).addClass("highcharts-point-connecting-path-"+t+"-marker highcharts-color-"+this.fromPoint.colorIndex).attr(o).add(x.group),M.styledMode||this.graphics[t].attr({fill:e.color||this.fromPoint.color,stroke:e.lineColor,"stroke-width":e.lineWidth,opacity:0}).animate({opacity:1},p.series.options.animation)))}getPath(t){let e=this.pathfinder,n=this.chart,r=e.algorithms[t.type],i=e.chartObstacles;return"function"!=typeof r?((0,s.error)('"'+t.type+'" is not a Pathfinder algorithm.'),{path:[],obstacles:[]}):(r.requiresObstacles&&!i&&(i=e.chartObstacles=e.getChartObstacles(t),n.options.connectors.algorithmMargin=t.algorithmMargin,e.chartObstacleMetrics=e.getObstacleMetrics(i)),r(this.fromPoint.getPathfinderAnchorPoint(t.startMarker),this.toPoint.getPathfinderAnchorPoint(t.endMarker),y({chartObstacles:i,lineObstacles:e.lineObstacles||[],obstacleMetrics:e.chartObstacleMetrics,hardBounds:{xMin:0,xMax:n.plotWidth,yMin:0,yMax:n.plotHeight},obstacleOptions:{margin:t.algorithmMargin},startDirectionX:e.getAlgorithmStartDirection(t.startMarker)},t)))}render(){let t=this.fromPoint,e=t.series,n=e.chart,r=n.pathfinder,i={},o=y(n.options.connectors,e.options.connectors,t.options.connectors,this.options);!n.styledMode&&(i.stroke=o.lineColor||t.color,i["stroke-width"]=o.lineWidth,o.dashStyle&&(i.dashstyle=o.dashStyle)),i.class="highcharts-point-connecting-path highcharts-color-"+t.colorIndex,null==(o=y(i,o)).marker.radius&&(o.marker.radius=b(m(Math.ceil((o.algorithmMargin||8)/2)-1,1),5));let a=this.getPath(o),s=a.path;a.obstacles&&(r.lineObstacles=r.lineObstacles||[],r.lineObstacles=r.lineObstacles.concat(a.obstacles)),this.renderPath(s,i),this.addMarker("start",y(o.marker,o.startMarker),s),this.addMarker("end",y(o.marker,o.endMarker),s)}destroy(){this.graphics&&(d(this.graphics,function(t){t.destroy()}),delete this.graphics)}};function v(t,e){let n=[];for(let r=0;r<t.length;r++){let i=t[r][1],o=t[r][2];if("number"==typeof i&&"number"==typeof o)if(0===r)n.push(["M",i,o]);else if(r===t.length-1)n.push(["L",i,o]);else if(e){let a=t[r-1],s=t[r+1];if(a&&s){let t=a[1],r=a[2],h=s[1],c=s[2];if("number"==typeof t&&"number"==typeof h&&"number"==typeof r&&"number"==typeof c&&t!==h&&r!==c){let a=t<h?1:-1,s=r<c?1:-1;n.push(["L",i-a*Math.min(Math.abs(i-t),e),o-s*Math.min(Math.abs(o-r),e)],["C",i,o,i,o,i+a*Math.min(Math.abs(i-h),e),o+s*Math.min(Math.abs(o-c),e)])}}}else n.push(["L",i,o])}return n}let{min:O,max:w,abs:k}=Math;function E(t,e,n){let r=e-1e-7,i=n||0,o=t.length-1,a,s;for(;i<=o;)if((s=r-t[a=o+i>>1].xMin)>0)i=a+1;else{if(!(s<0))return a;o=a-1}return i>0?i-1:0}function A(t,e){let n=E(t,e.x+1)+1;for(;n--;){var r;if(t[n].xMax>=e.x&&(r=t[n],e.x<=r.xMax&&e.x>=r.xMin&&e.y<=r.yMax&&e.y>=r.yMin))return n}return -1}function I(t){let e=[];if(t.length){e.push(["M",t[0].start.x,t[0].start.y]);for(let n=0;n<t.length;++n)e.push(["L",t[n].end.x,t[n].end.y])}return e}function j(t,e){t.yMin=w(t.yMin,e.yMin),t.yMax=O(t.yMax,e.yMax),t.xMin=w(t.xMin,e.xMin),t.xMax=O(t.xMax,e.xMax)}let L=function(t,e,n){let r=[],i=n.chartObstacles,o=A(i,t),a=A(i,e),s,h=u(n.startDirectionX,k(e.x-t.x)>k(e.y-t.y))?"x":"y",c,l,x,M;function p(t,e,n,r,i){let o={x:t.x,y:t.y};return o[e]=n[r||e]+(i||0),o}function f(t,e,n){let r=k(e[n]-t[n+"Min"])>k(e[n]-t[n+"Max"]);return p(e,n,t,n+(r?"Max":"Min"),r?1:-1)}a>-1?(s={start:l=f(i[a],e,h),end:e},M=l):M=e,o>-1&&(l=f(c=i[o],t,h),r.push({start:t,end:l}),l[h]>=t[h]==l[h]>=M[h]&&(x=t[h="y"===h?"x":"y"]<e[h],r.push({start:l,end:p(l,h,c,h+(x?"Max":"Min"),x?1:-1)}),h="y"===h?"x":"y"));let y=r.length?r[r.length-1].end:t;l=p(y,h,M),r.push({start:y,end:l});let d=p(l,h="y"===h?"x":"y",M);return r.push({start:l,end:d}),r.push(s),{path:v(I(r),n.radius),obstacles:r}};function R(t,e,n){let r=u(n.startDirectionX,k(e.x-t.x)>k(e.y-t.y)),i=r?"x":"y",o=[],a=n.obstacleMetrics,s=O(t.x,e.x)-a.maxWidth-10,h=w(t.x,e.x)+a.maxWidth+10,c=O(t.y,e.y)-a.maxHeight-10,l=w(t.y,e.y)+a.maxHeight+10,x,M,p,f=!1,y=n.chartObstacles,d=E(y,h),g=E(y,s);function m(t,e,n){let r,i,o,a,s=t.x<e.x?1:-1;t.x<e.x?(r=t,i=e):(r=e,i=t),t.y<e.y?(a=t,o=e):(a=e,o=t);let h=s<0?O(E(y,i.x),y.length-1):0;for(;y[h]&&(s>0&&y[h].xMin<=i.x||s<0&&y[h].xMax>=r.x);){if(y[h].xMin<=i.x&&y[h].xMax>=r.x&&y[h].yMin<=o.y&&y[h].yMax>=a.y){if(n)return{y:t.y,x:t.x<e.x?y[h].xMin-1:y[h].xMax+1,obstacle:y[h]};return{x:t.x,y:t.y<e.y?y[h].yMin-1:y[h].yMax+1,obstacle:y[h]}}h+=s}return e}function b(t,e,n,r,i){let o=i.soft,a=i.hard,s=r?"x":"y",h={x:e.x,y:e.y},c={x:e.x,y:e.y},l=t[s+"Max"]>=o[s+"Max"],x=t[s+"Min"]<=o[s+"Min"],M=t[s+"Max"]>=a[s+"Max"],p=t[s+"Min"]<=a[s+"Min"],f=k(t[s+"Min"]-e[s]),y=k(t[s+"Max"]-e[s]),d=10>k(f-y)?e[s]<n[s]:y<f;c[s]=t[s+"Min"],h[s]=t[s+"Max"];let u=m(e,c,r)[s]!==c[s],g=m(e,h,r)[s]!==h[s];return d=u?!g||d:!g&&d,d=x?!l||d:!l&&d,d=p?!M||d:!M&&d}if((d=A(y=y.slice(g,d+1),e))>-1){var P,v;let r,i;P=y[d],v=e,r=O(P.xMax-v.x,v.x-P.xMin)<O(P.yMax-v.y,v.y-P.yMin),i=b(P,v,t,r,{soft:n.hardBounds,hard:n.hardBounds}),p=r?{y:v.y,x:P[i?"xMax":"xMin"]+(i?1:-1)}:{x:v.x,y:P[i?"yMax":"yMin"]+(i?1:-1)},o.push({end:e,start:p}),e=p}for(;(d=A(y,e))>-1;)M=e[i]-t[i]<0,(p={x:e.x,y:e.y})[i]=y[d][M?i+"Max":i+"Min"]+(M?1:-1),o.push({end:e,start:p}),e=p;return{path:I(x=(x=function t(e,r,i){let o,a,x,M,p,d,u;if(e.x===r.x&&e.y===r.y)return[];let g=i?"x":"y",P=n.obstacleOptions.margin,v={soft:{xMin:s,xMax:h,yMin:c,yMax:l},hard:n.hardBounds};return(p=A(y,e))>-1?(M=b(p=y[p],e,r,i,v),j(p,n.hardBounds),u=i?{y:e.y,x:p[M?"xMax":"xMin"]+(M?1:-1)}:{x:e.x,y:p[M?"yMax":"yMin"]+(M?1:-1)},(d=A(y,u))>-1&&(j(d=y[d],n.hardBounds),u[g]=M?w(p[g+"Max"]-P+1,(d[g+"Min"]+p[g+"Max"])/2):O(p[g+"Min"]+P-1,(d[g+"Max"]+p[g+"Min"])/2),e.x===u.x&&e.y===u.y?(f&&(u[g]=M?w(p[g+"Max"],d[g+"Max"])+1:O(p[g+"Min"],d[g+"Min"])-1),f=!f):f=!1),a=[{start:e,end:u}]):(o=m(e,{x:i?r.x:e.x,y:i?e.y:r.y},i),a=[{start:e,end:{x:o.x,y:o.y}}],o[i?"x":"y"]!==r[i?"x":"y"]&&(M=b(o.obstacle,o,r,!i,v),j(o.obstacle,n.hardBounds),x={x:i?o.x:o.obstacle[M?"xMax":"xMin"]+(M?1:-1),y:i?o.obstacle[M?"yMax":"yMin"]+(M?1:-1):o.y},i=!i,a=a.concat(t({x:o.x,y:o.y},x,i)))),a=a.concat(t(a[a.length-1].end,r,!i))}(t,e,r)).concat(o.reverse())),obstacles:x}}L.requiresObstacles=!0,R.requiresObstacles=!0;let B={connectors:{type:"straight",radius:0,lineWidth:1,marker:{enabled:!1,align:"center",verticalAlign:"middle",inside:!1,lineWidth:1},startMarker:{symbol:"diamond"},endMarker:{symbol:"arrow-filled"}}},{setOptions:C}=h();function H(t){let e=t.shapeArgs;if(e)return{xMin:e.x||0,xMax:(e.x||0)+(e.width||0),yMin:e.y||0,yMax:(e.y||0)+(e.height||0)};let n=t.graphic&&t.graphic.getBBox();return n?{xMin:t.plotX-n.width/2,xMax:t.plotX+n.width/2,yMin:t.plotY-n.height/2,yMax:t.plotY+n.height/2}:null}!function(t){function e(t){let e,n,r=H(this);switch(t.align){case"right":e="xMax";break;case"left":e="xMin"}switch(t.verticalAlign){case"top":n="yMin";break;case"bottom":n="yMax"}return{x:e?r[e]:(r.xMin+r.xMax)/2,y:n?r[n]:(r.yMin+r.yMax)/2}}function n(t,e){let n;return null==e&&(n=H(this))&&(e={x:(n.xMin+n.xMax)/2,y:(n.yMin+n.yMax)/2}),Math.atan2(e.y-t.y,t.x-e.x)}function r(t,e,n){let r=2*Math.PI,i=H(this),o=i.xMax-i.xMin,a=i.yMax-i.yMin,s=Math.atan2(a,o),h=o/2,c=a/2,l=i.xMin+h,x=i.yMin+c,M={x:l,y:x},p=t,f=1,y=!1,d=1,u=1;for(;p<-Math.PI;)p+=r;for(;p>Math.PI;)p-=r;return f=Math.tan(p),p>-s&&p<=s?(u=-1,y=!0):p>s&&p<=Math.PI-s?u=-1:p>Math.PI-s||p<=-(Math.PI-s)?(d=-1,y=!0):d=-1,y?(M.x+=d*h,M.y+=u*h*f):(M.x+=a/(2*f)*d,M.y+=u*c),n.x!==l&&(M.x=n.x),n.y!==x&&(M.y=n.y),{x:M.x+e*Math.cos(p),y:M.y-e*Math.sin(p)}}t.compose=function(t,i,o){let a=o.prototype;a.getPathfinderAnchorPoint||(t.prototype.callbacks.push(function(t){!1!==t.options.connectors.enabled&&((t.options.pathfinder||t.series.reduce(function(t,e){return e.options&&y(!0,e.options.connectors=e.options.connectors||{},e.options.pathfinder),t||e.options&&e.options.pathfinder},!1))&&(y(!0,t.options.connectors=t.options.connectors||{},t.options.pathfinder),(0,s.error)('WARNING: Pathfinder options have been renamed. Use "chart.connectors" or "series.connectors" instead.')),this.pathfinder=new i(this),this.pathfinder.update(!0))}),a.getMarkerVector=r,a.getPathfinderAnchorPoint=e,a.getRadiansToVector=n,C(B))}}(n||(n={}));let _=n;var W=o(260),X=o.n(W);let S=Math.max,D=Math.min;class T{static compose(t,e){_.compose(t,T,e)}constructor(t){this.init(t)}init(t){this.chart=t,this.connections=[],x(t,"redraw",function(){this.pathfinder.update()})}update(t){let e=this.chart,n=this,r=n.connections;n.connections=[],e.series.forEach(function(t){t.visible&&!t.options.isInternal&&t.points.forEach(function(t){var r;let i,o=t.options;o&&o.dependency&&(o.connect=o.dependency);let a=t.options?.connect?p(r=t.options.connect)?r:[r]:[];t.visible&&!1!==t.isInside&&a.forEach(r=>{let o="string"==typeof r?r:r.to;o&&(i=e.get(o)),i instanceof X()&&i.series.visible&&i.visible&&!1!==i.isInside&&n.connections.push(new P(t,i,"string"==typeof r?{}:r))})})});for(let t=0,e,i,o=r.length,a=n.connections.length;t<o;++t){i=!1;let o=r[t];for(e=0;e<a;++e){let t=n.connections[e];if((o.options&&o.options.type)===(t.options&&t.options.type)&&o.fromPoint===t.fromPoint&&o.toPoint===t.toPoint){t.graphics=o.graphics,i=!0;break}}i||o.destroy()}delete this.chartObstacles,delete this.lineObstacles,n.renderConnections(t)}renderConnections(t){t?this.chart.series.forEach(function(t){let e=function(){let e=t.chart.pathfinder;(e&&e.connections||[]).forEach(function(e){e.fromPoint&&e.fromPoint.series===t&&e.render()}),t.pathfinderRemoveRenderEvent&&(t.pathfinderRemoveRenderEvent(),delete t.pathfinderRemoveRenderEvent)};!1===t.options.animation?e():t.pathfinderRemoveRenderEvent=x(t,"afterAnimate",e)}):this.connections.forEach(function(t){t.render()})}getChartObstacles(t){let e=this.chart.series,n=u(t.algorithmMargin,0),r=[],i;for(let t=0,i=e.length;t<i;++t)if(e[t].visible&&!e[t].options.isInternal)for(let i=0,o=e[t].points.length,a,s;i<o;++i)(s=e[t].points[i]).visible&&(a=function(t){let e=t.shapeArgs;if(e)return{xMin:e.x||0,xMax:(e.x||0)+(e.width||0),yMin:e.y||0,yMax:(e.y||0)+(e.height||0)};let n=t.graphic&&t.graphic.getBBox();return n?{xMin:t.plotX-n.width/2,xMax:t.plotX+n.width/2,yMin:t.plotY-n.height/2,yMax:t.plotY+n.height/2}:null}(s))&&r.push({xMin:a.xMin-n,xMax:a.xMax+n,yMin:a.yMin-n,yMax:a.yMax+n});return r=r.sort(function(t,e){return t.xMin-e.xMin}),null==t.algorithmMargin&&(i=t.algorithmMargin=function(t){let e,n=t.length,r=[];for(let i=0;i<n;++i)for(let o=i+1;o<n;++o)(e=function t(e,n,r){let i=u(r,10),o=e.yMax+i>n.yMin-i&&e.yMin-i<n.yMax+i,a=e.xMax+i>n.xMin-i&&e.xMin-i<n.xMax+i,s=o?e.xMin>n.xMax?e.xMin-n.xMax:n.xMin-e.xMax:1/0,h=a?e.yMin>n.yMax?e.yMin-n.yMax:n.yMin-e.yMax:1/0;return a&&o?i?t(e,n,Math.floor(i/2)):1/0:D(s,h)}(t[i],t[o]))<80&&r.push(e);return r.push(80),S(Math.floor(r.sort(function(t,e){return t-e})[Math.floor(r.length/10)]/2-1),1)}(r),r.forEach(function(t){t.xMin-=i,t.xMax+=i,t.yMin-=i,t.yMax+=i})),r}getObstacleMetrics(t){let e=0,n=0,r,i,o=t.length;for(;o--;)r=t[o].xMax-t[o].xMin,i=t[o].yMax-t[o].yMin,e<r&&(e=r),n<i&&(n=i);return{maxHeight:n,maxWidth:e}}getAlgorithmStartDirection(t){let e="left"!==t.align&&"right"!==t.align,n="top"!==t.verticalAlign&&"bottom"!==t.verticalAlign;return e?!!n&&void 0:!!n||void 0}}function V(t,e,n,r){return[["M",t,e+r/2],["L",t+n,e],["L",t,e+r/2],["L",t+n,e+r]]}function Y(t,e,n,r){return V(t,e,n/2,r)}function q(t,e,n,r){return[["M",t+n,e],["L",t,e+r/2],["L",t+n,e+r],["Z"]]}function G(t,e,n,r){return q(t,e,n/2,r)}T.prototype.algorithms={fastAvoid:R,straight:function(t,e){return{path:[["M",t.x,t.y],["L",e.x,e.y]],obstacles:[{start:t,end:e}]}},simpleConnect:L};let N=h();N.Pathfinder=N.Pathfinder||T,({compose:function(t){let e=t.prototype.symbols;e.arrow=V,e["arrow-filled"]=q,e["arrow-filled-half"]=G,e["arrow-half"]=Y,e["triangle-left"]=q,e["triangle-left-half"]=G}}).compose(N.SVGRenderer),N.Pathfinder.compose(N.Chart,N.Point);let z=h();return a.default})());