deteksi-badan-new/static/plugin/chart/highcharts/js/modules/series-label.js

19 lines
5.2 KiB
JavaScript

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