xrange.js
5.91 KB
/*
Highcharts JS v7.2.0 (2019-09-03)
X-range series
(c) 2010-2019 Torstein Honsi, Lars A. V. Cabrera
License: www.highcharts.com/license
*/
(function(b){"object"===typeof module&&module.exports?(b["default"]=b,module.exports=b):"function"===typeof define&&define.amd?define("highcharts/modules/xrange",["highcharts"],function(d){b(d);b.Highcharts=d;return b}):b("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(b){function d(q,b,d,m){q.hasOwnProperty(b)||(q[b]=m.apply(null,d))}b=b?b._modules:{};d(b,"modules/xrange.src.js",[b["parts/Globals.js"],b["parts/Utilities.js"]],function(b,d){var q=d.defined,m=d.isNumber,u=d.isObject;
d=b.addEvent;var x=b.color,y=b.seriesTypes.column,A=b.correctFloat,r=b.merge,v=b.pick,B=b.seriesType,C=b.Axis,w=b.Point,D=b.Series;B("xrange","column",{colorByPoint:!0,dataLabels:{formatter:function(){var a=this.point.partialFill;u(a)&&(a=a.amount);if(m(a)&&0<a)return A(100*a)+"%"},inside:!0,verticalAlign:"middle"},tooltip:{headerFormat:'<span style="font-size: 10px">{point.x} - {point.x2}</span><br/>',pointFormat:'<span style="color:{point.color}">\u25cf</span> {series.name}: <b>{point.yCategory}</b><br/>'},
borderRadius:3,pointRange:0},{type:"xrange",parallelArrays:["x","x2","y"],requireSorting:!1,animate:b.seriesTypes.line.prototype.animate,cropShoulder:1,getExtremesFromAll:!0,autoIncrement:b.noop,buildKDTree:b.noop,getColumnMetrics:function(){function a(){c.series.forEach(function(a){var c=a.xAxis;a.xAxis=a.yAxis;a.yAxis=c})}var c=this.chart;a();var g=y.prototype.getColumnMetrics.call(this);a();return g},cropData:function(a,c,g,b){c=D.prototype.cropData.call(this,this.x2Data,c,g,b);c.xData=a.slice(c.start,
c.end);return c},findPointIndex:function(a){var c=this.data,g=this.points,z=a.id,e;if(z)var f=(e=b.find(c,function(a){return a.id===z}))?e.index:void 0;void 0===f&&(f=(e=b.find(c,function(c){return c.x===a.x&&c.x2===a.x2&&!(g[f]&&g[f].touched)}))?e.index:void 0);this.cropped&&f>=this.cropStart&&(f-=this.cropStart);return f},translatePoint:function(a){var c=this.xAxis,g=this.yAxis,b=this.columnMetrics,e=this.options,f=e.minPointLength||0,d=a.plotX,k=v(a.x2,a.x+(a.len||0)),h=c.translate(k,0,0,0,1);
k=Math.abs(h-d);var p=this.chart.inverted,t=v(e.borderWidth,1)%2/2,l=b.offset,n=Math.round(b.width);f&&(f-=k,0>f&&(f=0),d-=f/2,h+=f/2);d=Math.max(d,-10);h=Math.min(Math.max(h,-10),c.len+10);q(a.options.pointWidth)&&(l-=(Math.ceil(a.options.pointWidth)-n)/2,n=Math.ceil(a.options.pointWidth));e.pointPlacement&&m(a.plotY)&&g.categories&&(a.plotY=g.translate(a.y,0,1,0,1,e.pointPlacement));a.shapeArgs={x:Math.floor(Math.min(d,h))+t,y:Math.floor(a.plotY+l)+t,width:Math.round(Math.abs(h-d)),height:n,r:this.options.borderRadius};
e=a.shapeArgs.x;f=e+a.shapeArgs.width;0>e||f>c.len?(e=Math.min(c.len,Math.max(0,e)),f=Math.max(0,Math.min(f,c.len)),h=f-e,a.dlBox=r(a.shapeArgs,{x:e,width:f-e,centerX:h?h/2:null})):a.dlBox=null;p?(a.tooltipPos[1]+=k/2*(c.reversed?1:-1),a.tooltipPos[0]+=b.width/2,a.tooltipPos[1]=Math.max(Math.min(a.tooltipPos[1],c.len-1),0),a.tooltipPos[0]=Math.max(Math.min(a.tooltipPos[0],g.len-1),0)):(a.tooltipPos[0]+=k/2*(c.reversed?-1:1),a.tooltipPos[1]-=b.width/2,a.tooltipPos[0]=Math.max(Math.min(a.tooltipPos[0],
c.len-1),0),a.tooltipPos[1]=Math.max(Math.min(a.tooltipPos[1],g.len-1),0));if(b=a.partialFill)u(b)&&(b=b.amount),m(b)||(b=0),g=a.shapeArgs,a.partShapeArgs={x:g.x,y:g.y,width:g.width,height:g.height,r:this.options.borderRadius},d=Math.max(Math.round(k*b+a.plotX-d),0),a.clipRectArgs={x:c.reversed?g.x+k-d:g.x,y:g.y,width:d,height:g.height}},translate:function(){y.prototype.translate.apply(this,arguments);this.points.forEach(function(a){this.translatePoint(a)},this)},drawPoint:function(a,b){var c=this.options,
d=this.chart.renderer,e=a.graphic,f=a.shapeType,m=a.shapeArgs,k=a.partShapeArgs,h=a.clipRectArgs,p=a.partialFill,t=c.stacking&&!c.borderRadius,l=a.state,n=c.states[l||"normal"]||{},q=void 0===l?"attr":b;l=this.pointAttribs(a,l);n=v(this.chart.options.chart.animation,n.animation);if(a.isNull)e&&(a.graphic=e.destroy());else{if(e)e.rect[b](m);else a.graphic=e=d.g("point").addClass(a.getClassName()).add(a.group||this.group),e.rect=d[f](r(m)).addClass(a.getClassName()).addClass("highcharts-partfill-original").add(e);
k&&(e.partRect?(e.partRect[b](r(k)),e.partialClipRect[b](r(h))):(e.partialClipRect=d.clipRect(h.x,h.y,h.width,h.height),e.partRect=d[f](k).addClass("highcharts-partfill-overlay").add(e).clip(e.partialClipRect)));this.chart.styledMode||(e.rect[b](l,n).shadow(c.shadow,null,t),k&&(u(p)||(p={}),u(c.partialFill)&&(p=r(p,c.partialFill)),a=p.fill||x(l.fill).brighten(-.3).get()||x(a.color||this.color).brighten(-.3).get(),l.fill=a,e.partRect[q](l,n).shadow(c.shadow,null,t)))}},drawPoints:function(){var a=
this,b=a.getAnimationVerb();a.points.forEach(function(c){a.drawPoint(c,b)})},getAnimationVerb:function(){return this.chart.pointCount<(this.options.animationLimit||250)?"animate":"attr"}},{resolveColor:function(){var a=this.series;if(a.options.colorByPoint&&!this.options.color){var b=a.options.colors||a.chart.options.colors;var d=this.y%(b?b.length:a.chart.options.chart.colorCount);b=b&&b[d];a.chart.styledMode||(this.color=b);this.options.colorIndex||(this.colorIndex=d)}else this.color||(this.color=
a.color)},init:function(){w.prototype.init.apply(this,arguments);this.y||(this.y=0);return this},setState:function(){w.prototype.setState.apply(this,arguments);this.series.drawPoint(this,this.series.getAnimationVerb())},getLabelConfig:function(){var a=w.prototype.getLabelConfig.call(this),b=this.series.yAxis.categories;a.x2=this.x2;a.yCategory=this.yCategory=b&&b[this.y];return a},tooltipDateKeys:["x","x2"],isValid:function(){return"number"===typeof this.x&&"number"===typeof this.x2}});d(C,"afterGetSeriesExtremes",
function(){var a=this.series,b;if(this.isXAxis){var d=v(this.dataMax,-Number.MAX_VALUE);a.forEach(function(a){a.x2Data&&a.x2Data.forEach(function(a){a>d&&(d=a,b=!0)})});b&&(this.dataMax=d)}});""});d(b,"masters/modules/xrange.src.js",[],function(){})});
//# sourceMappingURL=xrange.js.map