(function(l){typeof module==="object"&&module.exports?module.exports=l:l(Highcharts)})(function(l){function q(d,b,a,k,c,e){d=(e-b)*(a-d)-(k-b)*(c-d);return d>0?!0:d<0?!1:!0}function r(d,b,a,k,c,e,f,h){return q(d,b,c,e,f,h)!==q(a,k,c,e,f,h)&&q(d,b,a,k,c,e)!==q(d,b,a,k,f,h)}function u(d,b,a,k,c,e,f,h){return r(d,b,d+a,b,c,e,f,h)||r(d+a,b,d+a,b+k,c,e,f,h)||r(d,b+k,d+a,b+k,c,e,f,h)||r(d,b,d,b+k,c,e,f,h)}function v(d){var b=this;d.call(b);clearTimeout(b.seriesLabelTimer);b.seriesLabelTimer=setTimeout(function(){b.boxesToAvoid=
[];s(b.series,function(a){var d=a.options.label;if(d.enabled&&a.visible&&(a.graph||a.area))a.interpolatedPoints=a.getPointsOnGraph(),s(d.boxesToAvoid||[],function(a){b.boxesToAvoid.push(a)})});s(b.series,function(a){function d(a,b,c){return a>l&&a<=l+p-c.width&&b>=i&&b<=i+n-c.height}var c,e,f,h=[],j,o,l=(c=b.inverted)?a.yAxis.pos:a.xAxis.pos,i=c?a.xAxis.pos:a.yAxis.pos,p=b.inverted?a.yAxis.len:a.xAxis.len,n=b.inverted?a.xAxis.len:a.yAxis.len,g=a.interpolatedPoints;if(a.visible&&g){if(!a.labelBySeries)a.labelBySeries=
b.renderer.label(a.name,0,-9999,"connector").css(z({color:a.color},a.options.label.styles)).attr({padding:0,opacity:0,stroke:a.color,"stroke-width":1}).add(a.group).animate({opacity:1},{duration:200});c=a.labelBySeries.getBBox();c.width=Math.round(c.width);for(o=g.length-1;o>0;o-=1)e=g[o].chartX+m,f=g[o].chartY-c.height-m,d(e,f,c)&&(j=a.checkClearPoint(e,f,c)),j&&h.push(j),e=g[o].chartX+m,f=g[o].chartY+m,d(e,f,c)&&(j=a.checkClearPoint(e,f,c)),j&&h.push(j),e=g[o].chartX-c.width-m,f=g[o].chartY+m,d(e,
f,c)&&(j=a.checkClearPoint(e,f,c)),j&&h.push(j),e=g[o].chartX-c.width-m,f=g[o].chartY-c.height-m,d(e,f,c)&&(j=a.checkClearPoint(e,f,c)),j&&h.push(j);if(!h.length)for(e=l+p-c.width;e>=l;e-=16)for(f=i;f<i+n-c.height;f+=16)(j=a.checkClearPoint(e,f,c,!0))&&h.push(j);if(h.length)h.sort(function(a,b){return b.weight-a.weight}),j=h[0],b.boxesToAvoid.push({left:j.x,right:j.x+c.width,top:j.y,bottom:j.y+c.height}),(Math.round(j.x)!==Math.round(a.labelBySeries.x)||Math.round(j.y)!==Math.round(a.labelBySeries.y))&&
a.labelBySeries.attr({x:j.x-l,y:j.y-i,anchorX:j.connectorPoint&&j.connectorPoint.plotX,anchorY:j.connectorPoint&&j.connectorPoint.plotY,opacity:0}).animate({opacity:1});else if(a.labelBySeries)a.labelBySeries=a.labelBySeries.destroy()}})},350)}var m=3,w=l.wrap,s=l.each,z=l.extend,t=l.isNumber,x=l.Series,A=l.SVGRenderer,y=l.Chart;l.setOptions({plotOptions:{series:{label:{enabled:!0,connectorAllowed:!0,connectorNeighbourDistance:24,styles:{fontWeight:"bold"}}}}});A.prototype.symbols.connector=function(d,
b,a,k,c){var e=c&&c.anchorX,c=c&&c.anchorY,f,h,j=a/2;t(e)&&t(c)&&(f=["M",e,c],h=b-c,h<0&&(h=-k-h),h<a&&(j=e<d+a/2?h:a-h),c>b+k?f.push("L",d+j,b+k):c<b?f.push("L",d+j,b):e<d?f.push("L",d,b+k/2):e>d+a&&f.push("L",d+a,b+k/2));return f||[]};x.prototype.getPointsOnGraph=function(){var d=this.points,b,a,k=[],c,e,f,h;e=this.graph||this.area;f=e.element;var j=(b=this.chart.inverted)?this.yAxis.pos:this.xAxis.pos,l=b?this.xAxis.pos:this.yAxis.pos;if(this.getPointSpline&&f.getPointAtLength){e.toD&&(a=e.attr("d"),
e.attr({d:e.toD}));h=f.getTotalLength();for(c=0;c<h;c+=16)b=f.getPointAtLength(c),k.push({chartX:j+b.x,chartY:l+b.y,plotX:b.x,plotY:b.y});a&&e.attr({d:a});b=d[d.length-1];b.chartX=j+b.plotX;b.chartY=l+b.plotY;k.push(b)}else{h=d.length;for(c=0;c<h;c+=1){b=d[c];a=d[c-1];b.chartX=j+b.plotX;b.chartY=l+b.plotY;if(c>0&&(e=Math.abs(b.chartX-a.chartX),f=Math.abs(b.chartY-a.chartY),e=Math.max(e,f),e>16)){e=Math.ceil(e/16);for(f=1;f<e;f+=1)k.push({chartX:a.chartX+(b.chartX-a.chartX)*(f/e),chartY:a.chartY+(b.chartY-
a.chartY)*(f/e),plotX:a.plotX+(b.plotX-a.plotX)*(f/e),plotY:a.plotY+(b.plotY-a.plotY)*(f/e)})}t(b.plotY)&&k.push(b)}}return k};x.prototype.checkClearPoint=function(d,b,a,k){function c(a,b){return!(b.left>a.right||b.right<a.left||b.top>a.bottom||b.bottom<a.top)}var e=Number.MAX_VALUE,f=Number.MAX_VALUE,h,j,l=this.options.label.connectorAllowed,m=this.chart,i,p,n,g;for(n=0;n<m.boxesToAvoid.length;n+=1)if(c(m.boxesToAvoid[n],{left:d,right:d+a.width,top:b,bottom:b+a.height}))return!1;for(n=0;n<m.series.length;n+=
1)if(h=m.series[n],i=h.interpolatedPoints,h.visible&&i){for(g=1;g<i.length;g+=1){if(u(d,b,a.width,a.height,i[g-1].chartX,i[g-1].chartY,i[g].chartX,i[g].chartY))return!1;this===h&&!p&&k&&(p=u(d-16,b-16,a.width+32,a.height+32,i[g-1].chartX,i[g-1].chartY,i[g].chartX,i[g].chartY));this!==h&&(e=Math.min(e,Math.pow(d+a.width/2-i[g].chartX,2)+Math.pow(b+a.height/2-i[g].chartY,2),Math.pow(d-i[g].chartX,2)+Math.pow(b-i[g].chartY,2),Math.pow(d+a.width-i[g].chartX,2)+Math.pow(b-i[g].chartY,2),Math.pow(d+a.width-
i[g].chartX,2)+Math.pow(b+a.height-i[g].chartY,2),Math.pow(d-i[g].chartX,2)+Math.pow(b+a.height-i[g].chartY,2)))}if(l&&this===h&&(k&&!p||e<Math.pow(this.options.label.connectorNeighbourDistance,2))){for(g=1;g<i.length;g+=1)h=Math.min(Math.pow(d+a.width/2-i[g].chartX,2)+Math.pow(b+a.height/2-i[g].chartY,2),Math.pow(d-i[g].chartX,2)+Math.pow(b-i[g].chartY,2),Math.pow(d+a.width-i[g].chartX,2)+Math.pow(b-i[g].chartY,2),Math.pow(d+a.width-i[g].chartX,2)+Math.pow(b+a.height-i[g].chartY,2),Math.pow(d-i[g].chartX,
2)+Math.pow(b+a.height-i[g].chartY,2)),h<f&&(f=h,j=i[g]);p=!0}}return!k||p?{x:d,y:b,weight:e-(j?f:0),connectorPoint:j}:!1};w(y.prototype,"render",v);w(y.prototype,"redraw",v)});
