UNPKG

highcharts

Version:
26 lines (23 loc) 8.11 kB
/* Highcharts JS v10.0.0 (2022-03-07) X-range series (c) 2010-2021 Torstein Honsi, Lars A. V. Cabrera License: www.highcharts.com/license */ (function(a){"object"===typeof module&&module.exports?(a["default"]=a,module.exports=a):"function"===typeof define&&define.amd?define("highcharts/modules/xrange",["highcharts"],function(h){a(h);a.Highcharts=h;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function h(a,e,g,b){a.hasOwnProperty(e)||(a[e]=b.apply(null,g),"function"===typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:e,module:a[e]}})))}a=a?a._modules:{};h(a,"Series/XRange/XRangePoint.js", [a["Core/Series/Point.js"],a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"]],function(a,e,g){var b=this&&this.__extends||function(){var a=function(c,d){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,d){a.__proto__=d}||function(a,d){for(var c in d)d.hasOwnProperty(c)&&(a[c]=d[c])};return a(c,d)};return function(c,d){function b(){this.constructor=c}a(c,d);c.prototype=null===d?Object.create(d):(b.prototype=d.prototype,new b)}}();g=g.extend;e=function(e){function c(){var a= null!==e&&e.apply(this,arguments)||this;a.options=void 0;a.series=void 0;return a}b(c,e);c.getColorByCategory=function(a,c){var d=a.options.colors||a.chart.options.colors;a=c.y%(d?d.length:a.chart.options.chart.colorCount);return{colorIndex:a,color:d&&d[a]}};c.prototype.resolveColor=function(){var a=this.series;if(a.options.colorByPoint&&!this.options.color){var b=c.getColorByCategory(a,this);a.chart.styledMode||(this.color=b.color);this.options.colorIndex||(this.colorIndex=b.colorIndex)}else this.color|| (this.color=a.color)};c.prototype.init=function(){a.prototype.init.apply(this,arguments);this.y||(this.y=0);return this};c.prototype.setState=function(){a.prototype.setState.apply(this,arguments);this.series.drawPoint(this,this.series.getAnimationVerb())};c.prototype.getLabelConfig=function(){var d=a.prototype.getLabelConfig.call(this),c=this.series.yAxis.categories;d.x2=this.x2;d.yCategory=this.yCategory=c&&c[this.y];return d};c.prototype.isValid=function(){return"number"===typeof this.x&&"number"=== typeof this.x2};return c}(e.seriesTypes.column.prototype.pointClass);g(e.prototype,{ttBelow:!1,tooltipDateKeys:["x","x2"]});return e});h(a,"Series/XRange/XRangeComposition.js",[a["Core/Axis/Axis.js"],a["Core/Utilities.js"]],function(a,e){var g=e.addEvent,b=e.pick;g(a,"afterGetSeriesExtremes",function(){var a=this.series,c;if(this.isXAxis){var d=b(this.dataMax,-Number.MAX_VALUE);a.forEach(function(a){a.x2Data&&a.x2Data.forEach(function(a){a>d&&(d=a,c=!0)})});c&&(this.dataMax=d)}})});h(a,"Series/XRange/XRangeSeries.js", [a["Core/Globals.js"],a["Core/Color/Color.js"],a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"],a["Series/XRange/XRangePoint.js"]],function(a,e,g,b,h){var c=this&&this.__extends||function(){var a=function(c,f){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,a){f.__proto__=a}||function(f,a){for(var q in a)a.hasOwnProperty(q)&&(f[q]=a[q])};return a(c,f)};return function(c,f){function q(){this.constructor=c}a(c,f);c.prototype=null===f?Object.create(f):(q.prototype=f.prototype, new q)}}(),d=e.parse,z=g.series,r=g.seriesTypes.column,A=r.prototype,v=b.clamp,D=b.correctFloat,E=b.defined;e=b.extend;var B=b.find,u=b.isNumber,w=b.isObject,t=b.merge,x=b.pick;b=function(a){function b(){var f=null!==a&&a.apply(this,arguments)||this;f.data=void 0;f.options=void 0;f.points=void 0;return f}c(b,a);b.prototype.init=function(){r.prototype.init.apply(this,arguments);this.options.stacking=void 0};b.prototype.getColumnMetrics=function(){function f(){a.series.forEach(function(a){var f=a.xAxis; a.xAxis=a.yAxis;a.yAxis=f})}var a=this.chart;f();var b=A.getColumnMetrics.call(this);f();return b};b.prototype.cropData=function(a,b,c,d){b=z.prototype.cropData.call(this,this.x2Data,b,c,d);b.xData=a.slice(b.start,b.end);return b};b.prototype.findPointIndex=function(a){var f=this.cropped,b=this.cropStart,c=this.points,C=a.id;if(C)var d=(d=B(c,function(a){return a.id===C}))?d.index:void 0;"undefined"===typeof d&&(d=(d=B(c,function(f){return f.x===a.x&&f.x2===a.x2&&!f.touched}))?d.index:void 0);f&& u(d)&&u(b)&&d>=b&&(d-=b);return d};b.prototype.translatePoint=function(a){var f=this.xAxis,b=this.yAxis,d=this.columnMetrics,c=this.options,e=c.minPointLength||0,k=(a.shapeArgs&&a.shapeArgs.width||0)/2,l=this.pointXOffset=d.offset,m=a.plotX,g=x(a.x2,a.x+(a.len||0)),n=f.translate(g,0,0,0,1);g=Math.abs(n-m);var p=this.chart.inverted,h=x(c.borderWidth,1)%2/2,r=d.offset,y=Math.round(d.width);e&&(e-=g,0>e&&(e=0),m-=e/2,n+=e/2);m=Math.max(m,-10);n=v(n,-10,f.len+10);E(a.options.pointWidth)&&(r-=(Math.ceil(a.options.pointWidth)- y)/2,y=Math.ceil(a.options.pointWidth));c.pointPlacement&&u(a.plotY)&&b.categories&&(a.plotY=b.translate(a.y,0,1,0,1,c.pointPlacement));c=Math.floor(Math.min(m,n))+h;c={x:c,y:Math.floor(a.plotY+r)+h,width:Math.floor(Math.max(m,n))+h-c,height:y,r:this.options.borderRadius};a.shapeArgs=c;p?a.tooltipPos[1]+=l+k:a.tooltipPos[0]-=k+l-c.width/2;k=c.x;l=k+c.width;0>k||l>f.len?(k=v(k,0,f.len),l=v(l,0,f.len),n=l-k,a.dlBox=t(c,{x:k,width:l-k,centerX:n?n/2:null})):a.dlBox=null;k=a.tooltipPos;l=p?1:0;n=p?0:1; d=this.columnMetrics?this.columnMetrics.offset:-d.width/2;k[l]=p?k[l]+c.width/2:k[l]+(f.reversed?-1:0)*c.width;k[n]=v(k[n]+(p?-1:1)*d,0,b.len-1);if(b=a.partialFill)w(b)&&(b=b.amount),u(b)||(b=0),a.partShapeArgs=t(c,{r:this.options.borderRadius}),m=Math.max(Math.round(g*b+a.plotX-m),0),a.clipRectArgs={x:f.reversed?c.x+g-m:c.x,y:c.y,width:m,height:c.height}};b.prototype.translate=function(){A.translate.apply(this,arguments);this.points.forEach(function(a){this.translatePoint(a)},this)};b.prototype.drawPoint= function(a,b){var c=this.options,f=this.chart.renderer,e=a.graphic,g=a.shapeType,k=a.shapeArgs,l=a.partShapeArgs,m=a.clipRectArgs,h=a.partialFill,n=c.stacking&&!c.borderRadius,p=a.state,q=c.states[p||"normal"]||{},r="undefined"===typeof p?"attr":b;p=this.pointAttribs(a,p);q=x(this.chart.options.chart.animation,q.animation);if(a.isNull||!1===a.visible)e&&(a.graphic=e.destroy());else{if(e)e.rect[b](k);else a.graphic=e=f.g("point").addClass(a.getClassName()).add(a.group||this.group),e.rect=f[g](t(k)).addClass(a.getClassName()).addClass("highcharts-partfill-original").add(e); l&&(e.partRect?(e.partRect[b](t(l)),e.partialClipRect[b](t(m))):(e.partialClipRect=f.clipRect(m.x,m.y,m.width,m.height),e.partRect=f[g](l).addClass("highcharts-partfill-overlay").add(e).clip(e.partialClipRect)));this.chart.styledMode||(e.rect[b](p,q).shadow(c.shadow,null,n),l&&(w(h)||(h={}),w(c.partialFill)&&(h=t(c.partialFill,h)),a=h.fill||d(p.fill).brighten(-.3).get()||d(a.color||this.color).brighten(-.3).get(),p.fill=a,e.partRect[r](p,q).shadow(c.shadow,null,n)))}};b.prototype.drawPoints=function(){var a= this,b=a.getAnimationVerb();a.points.forEach(function(c){a.drawPoint(c,b)})};b.prototype.getAnimationVerb=function(){return this.chart.pointCount<(this.options.animationLimit||250)?"animate":"attr"};b.prototype.isPointInside=function(b){var c=b.shapeArgs,d=b.plotX,f=b.plotY;return c?"undefined"!==typeof d&&"undefined"!==typeof f&&0<=f&&f<=this.yAxis.len&&0<=(c.x||0)+(c.width||0)&&d<=this.xAxis.len:a.prototype.isPointInside.apply(this,arguments)};b.defaultOptions=t(r.defaultOptions,{colorByPoint:!0, dataLabels:{formatter:function(){var a=this.point.partialFill;w(a)&&(a=a.amount);if(u(a)&&0<a)return D(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});return b}(r);e(b.prototype,{type:"xrange",parallelArrays:["x","x2","y"],requireSorting:!1,animate:z.prototype.animate,cropShoulder:1, getExtremesFromAll:!0,autoIncrement:a.noop,buildKDTree:a.noop,pointClass:h});g.registerSeriesType("xrange",b);"";return b});h(a,"masters/modules/xrange.src.js",[],function(){})}); //# sourceMappingURL=xrange.js.map