/*
 Highcharts JS v7.1.3 (2019-08-14)

 (c) 2009-2019 Torstein Honsi

 License: www.highcharts.com/license
*/
(function(l){"object"===typeof module&&module.exports?(l["default"]=l,module.exports=l):"function"===typeof define&&define.amd?define("highcharts/modules/series-label",["highcharts"],function(q){l(q);l.Highcharts=q;return l}):l("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(l){function q(z,l,x,y){z.hasOwnProperty(l)||(z[l]=y.apply(null,x))}l=l?l._modules:{};q(l,"modules/series-label.src.js",[l["parts/Globals.js"],l["parts/Utilities.js"]],function(l,q){function x(c,d,a,k,f,b){c=(b-d)*
(a-c)-(k-d)*(f-c);return 0<c?!0:!(0>c)}function y(c,d,a,k,f,b,g,n){return x(c,d,f,b,g,n)!==x(a,k,f,b,g,n)&&x(c,d,a,k,f,b)!==x(c,d,a,k,g,n)}function z(c,d,a,k,f,b,g,n){return y(c,d,c+a,d,f,b,g,n)||y(c+a,d,c+a,d+k,f,b,g,n)||y(c,d+k,c+a,d+k,f,b,g,n)||y(c,d,c,d+k,f,b,g,n)}function E(c){var d=this,a=l.animObject(d.renderer.globalAnimation).duration;d.labelSeries=[];d.labelSeriesMaxSum=0;l.clearTimeout(d.seriesLabelTimer);d.series.forEach(function(k){var f=k.options.label,b=k.labelBySeries,g=b&&b.closest;
f.enabled&&k.visible&&(k.graph||k.area)&&!k.isSeriesBoosting&&(d.labelSeries.push(k),f.minFontSize&&f.maxFontSize&&(k.sum=k.yData.reduce(function(a,b){return(a||0)+(b||0)},0),d.labelSeriesMaxSum=Math.max(d.labelSeriesMaxSum,k.sum)),"load"===c.type&&(a=Math.max(a,l.animObject(k.options.animation).duration)),g&&(void 0!==g[0].plotX?b.animate({x:g[0].plotX+g[1],y:g[0].plotY+g[2]}):b.attr({opacity:0})))});d.seriesLabelTimer=l.syncTimeout(function(){d.series&&d.labelSeries&&d.drawSeriesLabels()},d.renderer.forExport?
0:a)}var B=q.isNumber;q=l.addEvent;var F=l.extend,A=l.pick,C=l.Series,G=l.SVGRenderer,D=l.Chart;l.setOptions({plotOptions:{series:{label:{enabled:!0,connectorAllowed:!1,connectorNeighbourDistance:24,minFontSize:null,maxFontSize:null,onArea:null,style:{fontWeight:"bold"},boxesToAvoid:[]}}}});G.prototype.symbols.connector=function(c,d,a,k,f){var b=f&&f.anchorX;f=f&&f.anchorY;var g=a/2;if(B(b)&&B(f)){var n=["M",b,f];var h=d-f;0>h&&(h=-k-h);h<a&&(g=b<c+a/2?h:a-h);f>d+k?n.push("L",c+g,d+k):f<d?n.push("L",
c+g,d):b<c?n.push("L",c,d+k/2):b>c+a&&n.push("L",c+a,d+k/2)}return n||[]};C.prototype.getPointsOnGraph=function(){function c(b){var c=Math.round(b.plotX/8)+","+Math.round(b.plotY/8);m[c]||(m[c]=1,a.push(b))}if(this.xAxis||this.yAxis){var d=this.points,a=[],k;var f=this.graph||this.area;var b=f.element;var g=this.chart.inverted,n=this.xAxis;var h=this.yAxis;var l=g?h.pos:n.pos;g=g?n.pos:h.pos;n=A(this.options.label.onArea,!!this.area);var w=h.getThreshold(this.options.threshold),m={};if(this.getPointSpline&&
b.getPointAtLength&&!n&&d.length<this.chart.plotSizeX/16){if(f.toD){var e=f.attr("d");f.attr({d:f.toD})}var v=b.getTotalLength();for(k=0;k<v;k+=16)h=b.getPointAtLength(k),c({chartX:l+h.x,chartY:g+h.y,plotX:h.x,plotY:h.y});e&&f.attr({d:e});h=d[d.length-1];h.chartX=l+h.plotX;h.chartY=g+h.plotY;c(h)}else for(v=d.length,k=0;k<v;k+=1){h=d[k];e=d[k-1];h.chartX=l+h.plotX;h.chartY=g+h.plotY;n&&(h.chartCenterY=g+(h.plotY+A(h.yBottom,w))/2);if(0<k&&(f=Math.abs(h.chartX-e.chartX),b=Math.abs(h.chartY-e.chartY),
f=Math.max(f,b),16<f))for(f=Math.ceil(f/16),b=1;b<f;b+=1)c({chartX:e.chartX+b/f*(h.chartX-e.chartX),chartY:e.chartY+b/f*(h.chartY-e.chartY),chartCenterY:e.chartCenterY+b/f*(h.chartCenterY-e.chartCenterY),plotX:e.plotX+b/f*(h.plotX-e.plotX),plotY:e.plotY+b/f*(h.plotY-e.plotY)});B(h.plotY)&&c(h)}return a}};C.prototype.labelFontSize=function(c,d){return c+this.sum/this.chart.labelSeriesMaxSum*(d-c)+"px"};C.prototype.checkClearPoint=function(c,d,a,k){var f=Number.MAX_VALUE,b=Number.MAX_VALUE,g,l=A(this.options.label.onArea,
!!this.area),h=l||this.options.label.connectorAllowed,q=this.chart,w;for(w=0;w<q.boxesToAvoid.length;w+=1){var m=q.boxesToAvoid[w];var e=c+a.width;var v=d;var u=d+a.height;if(!(c>m.right||e<m.left||v>m.bottom||u<m.top))return!1}for(w=0;w<q.series.length;w+=1)if(v=q.series[w],m=v.interpolatedPoints,v.visible&&m){for(e=1;e<m.length;e+=1){if(m[e].chartX>=c-16&&m[e-1].chartX<=c+a.width+16){if(z(c,d,a.width,a.height,m[e-1].chartX,m[e-1].chartY,m[e].chartX,m[e].chartY))return!1;this===v&&!g&&k&&(g=z(c-
16,d-16,a.width+32,a.height+32,m[e-1].chartX,m[e-1].chartY,m[e].chartX,m[e].chartY))}if((h||g)&&(this!==v||l)){u=c+a.width/2-m[e].chartX;var x=d+a.height/2-m[e].chartY;f=Math.min(f,u*u+x*x)}}if(!l&&h&&this===v&&(k&&!g||f<Math.pow(this.options.label.connectorNeighbourDistance,2))){for(e=1;e<m.length;e+=1)if(g=Math.min(Math.pow(c+a.width/2-m[e].chartX,2)+Math.pow(d+a.height/2-m[e].chartY,2),Math.pow(c-m[e].chartX,2)+Math.pow(d-m[e].chartY,2),Math.pow(c+a.width-m[e].chartX,2)+Math.pow(d-m[e].chartY,
2),Math.pow(c+a.width-m[e].chartX,2)+Math.pow(d+a.height-m[e].chartY,2),Math.pow(c-m[e].chartX,2)+Math.pow(d+a.height-m[e].chartY,2)),g<b){b=g;var p=m[e]}g=!0}}return!k||g?{x:c,y:d,weight:f-(p?b:0),connectorPoint:p}:!1};D.prototype.drawSeriesLabels=function(){var c=this,d=this.labelSeries;c.boxesToAvoid=[];d.forEach(function(a){a.interpolatedPoints=a.getPointsOnGraph();(a.options.label.boxesToAvoid||[]).forEach(function(a){c.boxesToAvoid.push(a)})});c.series.forEach(function(a){function d(a,b,c){var d=
Math.max(h,A(y,-Infinity)),e=Math.min(h+w,A(z,Infinity));return a>d&&a<=e-c.width&&b>=q&&b<=q+m-c.height}if(a.xAxis||a.yAxis){var f=[],b,g,n=a.options.label,h=(g=c.inverted)?a.yAxis.pos:a.xAxis.pos,q=g?a.xAxis.pos:a.yAxis.pos,w=c.inverted?a.yAxis.len:a.xAxis.len,m=c.inverted?a.xAxis.len:a.yAxis.len,e=a.interpolatedPoints,v=A(n.onArea,!!a.area),u=a.labelBySeries,x=!u;var p=n.minFontSize;var r=n.maxFontSize;var t="highcharts-color-"+A(a.colorIndex,"none");if(v&&!g){g=[a.xAxis.toPixels(a.xData[0]),a.xAxis.toPixels(a.xData[a.xData.length-
1])];var y=Math.min.apply(Math,g);var z=Math.max.apply(Math,g)}if(a.visible&&!a.isSeriesBoosting&&e){u||(a.labelBySeries=u=c.renderer.label(a.name,0,-9999,"connector").addClass("highcharts-series-label highcharts-series-label-"+a.index+" "+(a.options.className||"")+t),c.renderer.styledMode||u.css(F({color:v?c.renderer.getContrast(a.color):a.color},a.options.label.style)),p&&r&&u.css({fontSize:a.labelFontSize(p,r)}),u.attr({padding:0,opacity:c.renderer.forExport?1:0,stroke:a.color,"stroke-width":1,
zIndex:3}).add());p=u.getBBox();p.width=Math.round(p.width);for(g=e.length-1;0<g;--g)v?(r=e[g].chartX-p.width/2,t=e[g].chartCenterY-p.height/2,d(r,t,p)&&(b=a.checkClearPoint(r,t,p))):(r=e[g].chartX+3,t=e[g].chartY-p.height-3,d(r,t,p)&&(b=a.checkClearPoint(r,t,p,!0)),b&&f.push(b),r=e[g].chartX+3,t=e[g].chartY+3,d(r,t,p)&&(b=a.checkClearPoint(r,t,p,!0)),b&&f.push(b),r=e[g].chartX-p.width-3,t=e[g].chartY+3,d(r,t,p)&&(b=a.checkClearPoint(r,t,p,!0)),b&&f.push(b),r=e[g].chartX-p.width-3,t=e[g].chartY-p.height-
3,d(r,t,p)&&(b=a.checkClearPoint(r,t,p,!0))),b&&f.push(b);if(n.connectorAllowed&&!f.length&&!v)for(r=h+w-p.width;r>=h;r-=16)for(t=q;t<q+m-p.height;t+=16)(b=a.checkClearPoint(r,t,p,!0))&&f.push(b);if(f.length){if(f.sort(function(a,b){return b.weight-a.weight}),b=f[0],c.boxesToAvoid.push({left:b.x,right:b.x+p.width,top:b.y,bottom:b.y+p.height}),f=Math.sqrt(Math.pow(Math.abs(b.x-u.x),2),Math.pow(Math.abs(b.y-u.y),2)))n={opacity:c.renderer.forExport?1:0,x:b.x,y:b.y},e={opacity:1},10>=f&&(e={x:n.x,y:n.y},
n={}),a.labelBySeries.attr(F(n,{anchorX:b.connectorPoint&&b.connectorPoint.plotX+h,anchorY:b.connectorPoint&&b.connectorPoint.plotY+q})).animate(e,x?.2*l.animObject(a.options.animation).duration:c.renderer.globalAnimation),a.options.kdNow=!0,a.buildKDTree(),a=a.searchPoint({chartX:b.x,chartY:b.y},!0),u.closest=[a,b.x-a.plotX,b.y-a.plotY]}else u&&(a.labelBySeries=u.destroy())}else u&&(a.labelBySeries=u.destroy())}});l.fireEvent(c,"afterDrawSeriesLabels")};q(D,"load",E);q(D,"redraw",E)});q(l,"masters/modules/series-label.src.js",
[],function(){})});
//# sourceMappingURL=series-label.js.map