/* Highcharts JS v7.0.3 (2019-02-06) Pathfinder (c) 2016-2019 ystein Moseng License: www.highcharts.com/license */ (function(m){"object"===typeof module&&module.exports?(m["default"]=m,module.exports=m):"function"===typeof define&&define.amd?define(function(){return m}):m("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(m){var H=function(h){function w(e,c,g){g=g||0;var h=e.length-1;c-=1e-7;for(var l,p;g<=h;)if(l=h+g>>1,p=c-e[l].xMin,0p)h=l-1;else return l;return 0=c.x)h=e[g],h=c.x<=h.xMax&&c.x>=h.xMin&&c.y<= h.yMax&&c.y>=h.yMin;if(h)return g}return-1}function x(e){var c=[];if(e.length){c.push("M",e[0].start.x,e[0].start.y);for(var g=0;gr(a[d]-b[d+"Max"]);return h(a,d,b,d+(f?"Max":"Min"),f?1:-1)}var p=[],a,b=z(g.startDirectionX,r(c.x-e.x)>r(c.y-e.y))?"x":"y",d=g.chartObstacles,k=l(d,e);g=l(d,c);var f;-1e[b]===g[b]>f[b]&&(b="y"===b?"x":"y",c=e[b]h?u(w(n,k.x),n.length-1):0;n[c]&&(0h&&n[c].xMax>=f.x);){if(n[c].xMin<=k.x&&n[c].xMax>=f.x&&n[c].yMin<=e.y&&n[c].yMax>=g.y)return d?{y:b.y,x:b.x=c[g+"Max"];var c=b[g+"Min"]<=c[g+"Min"],E=b[g+"Max"]>=e[g+"Max"],e=b[g+"Min"]<=e[g+"Min"],n=r(b[g+"Min"]-a[g]),l=r(b[g+"Max"]-a[g]);d=10>r(n-l)?a[g]r(c.y-e.y)),d=b?"x":"y",k,f,v=[],A=!1,t=g.obstacleMetrics,C=u(e.x,c.x)-t.maxWidth-10,D=m(e.x,c.x)+t.maxWidth+10,F=u(e.y,c.y)-t.maxHeight-10,G=m(e.y,c.y)+t.maxHeight+10,n=g.chartObstacles;k=w(n,C);t=w(n,D);n=n.slice(k,t+1);-1<(t=l(n,c))&&(f=a(n[t],c,e),v.push({end:c,start:f}),c=f);for(;-1<(t=l(n,c));)k=0>c[d]-e[d],f={x:c.x,y:c.y},f[d]=n[t][k?d+"Max":d+"Min"]+(k?1:-1),v.push({end:c,start:f}),c=f;e=p(e,c,b);e=e.concat(v.reverse()); return{path:x(e),obstacles:e}},{requiresObstacles:!0})}}(m);(function(h){h.SVGRenderer.prototype.symbols.arrow=function(h,l,m,q){return["M",h,l+q/2,"L",h+m,l,"L",h,l+q/2,"L",h+m,l+q]};h.SVGRenderer.prototype.symbols["arrow-half"]=function(m,l,x,q){return h.SVGRenderer.prototype.symbols.arrow(m,l,x/2,q)};h.SVGRenderer.prototype.symbols["triangle-left"]=function(h,l,m,q){return["M",h+m,l,"L",h,l+q/2,"L",h+m,l+q,"Z"]};h.SVGRenderer.prototype.symbols["arrow-filled"]=h.SVGRenderer.prototype.symbols["triangle-left"]; h.SVGRenderer.prototype.symbols["triangle-left-half"]=function(m,l,x,q){return h.SVGRenderer.prototype.symbols["triangle-left"](m,l,x/2,q)};h.SVGRenderer.prototype.symbols["arrow-filled-half"]=h.SVGRenderer.prototype.symbols["triangle-left-half"]})(m);(function(h,m){function l(a){var b=a.shapeArgs;return b?{xMin:b.x,xMax:b.x+b.width,yMin:b.y,yMax:b.y+b.height}:(b=a.graphic&&a.graphic.getBBox())?{xMin:a.plotX-b.width/2,xMax:a.plotX+b.width/2,yMin:a.plotY-b.height/2,yMax:a.plotY+b.height/2}:null}function x(a){for(var b= a.length,d=0,k,f,c=[],g=function(b,a,d){d=B(d,10);var f=b.yMax+d>a.yMin-d&&b.yMin-da.xMin-d&&b.xMin-da.xMax?b.xMin-a.xMax:a.xMin-b.xMax:Infinity,e=k?b.yMin>a.yMax?b.yMin-a.yMax:a.yMin-b.yMax:Infinity;return k&&f?d?g(b,a,Math.floor(d/2)):Infinity:p(c,e)};df&&c.push(f);c.push(80);return y(Math.floor(c.sort(function(b,a){return b-a})[Math.floor(c.length/10)]/2-1),1)}function q(a,b,d){this.init(a,b,d)}function u(a){this.init(a)} function w(a){if(a.options.pathfinder||a.series.reduce(function(b,a){a.options&&g(!0,a.options.connectors=a.options.connectors||{},a.options.pathfinder);return b||a.options&&a.options.pathfinder},!1))g(!0,a.options.connectors=a.options.connectors||{},a.options.pathfinder),h.error('WARNING: Pathfinder options have been renamed. Use "chart.connectors" or "series.connectors" instead.')}var r=h.defined,z=h.deg2rad,e=h.extend,c=h.addEvent,g=h.merge,B=h.pick,y=Math.max,p=Math.min;e(h.defaultOptions,{connectors:{type:"straight", lineWidth:1,marker:{enabled:!1,align:"center",verticalAlign:"middle",inside:!1,lineWidth:1},startMarker:{symbol:"diamond"},endMarker:{symbol:"arrow-filled"}}});q.prototype={init:function(a,b,d){this.fromPoint=a;this.toPoint=b;this.options=d;this.chart=a.series.chart;this.pathfinder=this.chart.pathfinder},renderPath:function(a,b,d){var k=this.chart,f=k.styledMode,c=k.pathfinder,g=!k.options.chart.forExport&&!1!==d,e=this.graphics&&this.graphics.path;c.group||(c.group=k.renderer.g().addClass("highcharts-pathfinder-group").attr({zIndex:-1}).add(k.seriesGroup)); c.group.translate(k.plotLeft,k.plotTop);e&&e.renderer||(e=k.renderer.path().add(c.group),f||e.attr({opacity:0}));e.attr(b);a={d:a};f||(a.opacity=1);e[g?"animate":"attr"](a,d);this.graphics=this.graphics||{};this.graphics.path=e},addMarker:function(a,b,d){var c=this.fromPoint.series.chart,f=c.pathfinder,c=c.renderer,g="start"===a?this.fromPoint:this.toPoint,e=g.getPathfinderAnchorPoint(b),h,l;b.enabled&&(d="start"===a?{x:d[4],y:d[5]}:{x:d[d.length-5],y:d[d.length-4]},d=g.getRadiansToVector(d,e),e= g.getMarkerVector(d,b.radius,e),d=-d/z,b.width&&b.height?(h=b.width,l=b.height):h=l=2*b.radius,this.graphics=this.graphics||{},e={x:e.x-h/2,y:e.y-l/2,width:h,height:l,rotation:d,rotationOriginX:e.x,rotationOriginY:e.y},this.graphics[a]?this.graphics[a].animate(e):(this.graphics[a]=c.symbol(b.symbol).addClass("highcharts-point-connecting-path-"+a+"-marker").attr(e).add(f.group),c.styledMode||this.graphics[a].attr({fill:b.color||this.fromPoint.color,stroke:b.lineColor,"stroke-width":b.lineWidth,opacity:0}).animate({opacity:1}, g.series.options.animation)))},getPath:function(a){var b=this.pathfinder,d=this.chart,c=b.algorithms[a.type],f=b.chartObstacles;if("function"!==typeof c)h.error('"'+a.type+'" is not a Pathfinder algorithm.');else return c.requiresObstacles&&!f&&(f=b.chartObstacles=b.getChartObstacles(a),d.options.connectors.algorithmMargin=a.algorithmMargin,b.chartObstacleMetrics=b.getObstacleMetrics(f)),c(this.fromPoint.getPathfinderAnchorPoint(a.startMarker),this.toPoint.getPathfinderAnchorPoint(a.endMarker),g({chartObstacles:f, lineObstacles:b.lineObstacles||[],obstacleMetrics:b.chartObstacleMetrics,hardBounds:{xMin:0,xMax:d.plotWidth,yMin:0,yMax:d.plotHeight},obstacleOptions:{margin:a.algorithmMargin},startDirectionX:b.getAlgorithmStartDirection(a.startMarker)},a))},render:function(){var a=this.fromPoint,b=a.series,d=b.chart,c=d.pathfinder,f=g(d.options.connectors,b.options.connectors,a.options.connectors,this.options),e={};d.styledMode||(e.stroke=f.lineColor||a.color,e["stroke-width"]=f.lineWidth,f.dashStyle&&(e.dashstyle= f.dashStyle));e.class="highcharts-point-connecting-path highcharts-color-"+a.colorIndex;f=g(e,f);r(f.marker.radius)||(f.marker.radius=p(y(Math.ceil((f.algorithmMargin||8)/2)-1,1),5));a=this.getPath(f);d=a.path;a.obstacles&&(c.lineObstacles=c.lineObstacles||[],c.lineObstacles=c.lineObstacles.concat(a.obstacles));this.renderPath(d,e,b.options.animation);this.addMarker("start",g(f.marker,f.startMarker),d);this.addMarker("end",g(f.marker,f.endMarker),d)},destroy:function(){this.graphics&&(h.objectEach(this.graphics, function(a){a.destroy()}),delete this.graphics)}};u.prototype={algorithms:m,init:function(a){this.chart=a;this.connections=[];c(a,"redraw",function(){this.pathfinder.update()})},update:function(a){var b=this.chart,d=this,c=d.connections;d.connections=[];b.series.forEach(function(a){a.visible&&a.points.forEach(function(a){var c,f=a.options&&a.options.connect&&h.splat(a.options.connect);a.visible&&!1!==a.isInside&&f&&f.forEach(function(f){c=b.get("string"===typeof f?f:f.to);c instanceof h.Point&&c.series.visible&& c.visible&&!1!==c.isInside&&d.connections.push(new q(a,c,"string"===typeof f?{}:f))})})});for(var f=0,e,g,l=c.length,m=d.connections.length;fMath.PI;)a-=e;e=Math.tan(a);a>-m&&a<=m?(y=-1,p=!0):a>m&&a<=Math.PI-m?y=-1:a>Math.PI-m||a<=-(Math.PI-m)?(x=-1,p=!0):x=-1;p?(r+=x*g,n+=y*g*e):(r+=h/(2*e)*x,n+=y*q);c.x!==u&&(r=c.x);c.y!==d&&(n=c.y);w.x=r+b*Math.cos(a);w.y=n-b*Math.sin(a);return w}});h.Chart.prototype.callbacks.push(function(a){!1!== a.options.connectors.enabled&&(w(a),this.pathfinder=new u(this),this.pathfinder.update(!0))})})(m,H)}); //# sourceMappingURL=pathfinder.js.map