highcharts
Version:
JavaScript charting framework
13 lines • 9.16 kB
JavaScript
!/**
* Highcharts JS v12.6.0 (2026-04-13)
* @module highcharts/modules/xrange
* @requires highcharts
*
* X-range series
*
* (c) 2010-2026 Highsoft AS
* Author: Torstein Hønsi, Lars A. V. Cabrera
*
* A commercial license may be required depending on use.
* See www.highcharts.com/license
*/function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.Color,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/xrange",["highcharts/highcharts"],function(t){return e(t,t.Color,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/xrange"]=e(t._Highcharts,t._Highcharts.Color,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.Color,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e,i)=>(()=>{"use strict";var o={512:t=>{t.exports=i},620:t=>{t.exports=e},944:e=>{e.exports=t}},r={};function s(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={exports:{}};return o[t](i,i.exports,s),i.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var a={};s.d(a,{default:()=>H});var n=s(944),l=s.n(n),p=s(620),h=s.n(p),c=s(512),d=s.n(c);let{doc:u,win:f}=l();function y(t,e,i){return t>e?t<i?t:i:e}function g(t,e=0,i){let o=e%2/2,r=i?-1:1;return(Math.round(t*r-o)+o)*r}function x(t,e){let i;for(i in t||(t={}),e)t[i]=e[i];return t}let m=Array.prototype.find?function(t,e){return t.find(e)}:function(t,e){let i,o=t.length;for(i=0;i<o;i++)if(e(t[i],i))return t[i]};function b(t){return A(t)&&"number"==typeof t.nodeType}function v(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function A(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function C(t,...e){let i,o=[t,...e],r={},s=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,i){for(let o in t)Object.hasOwnProperty.call(t,o)&&e.call(i||t[o],t[o],o,t)}(e,function(i,o){if("__proto__"!==o&&"constructor"!==o){let r;!A(i,!0)||(r=i?.constructor,A(i,!0)&&!b(i)&&r?.name&&"Object"!==r.name)||b(i)?t[o]=e[o]:t[o]=s(t[o]||{},i)}}),t};!0===t&&(r=o[1],o=Array.prototype.slice.call(o,2));let a=o.length;for(i=0;i<a;i++)r=s(r,o[i]);return r}function w(){let t=arguments,e=t.length;for(let i=0;i<e;i++){let e=t[i];if(null!=e)return e}}let{column:{prototype:{pointClass:P}}}=d().seriesTypes;class M extends P{static getColorByCategory(t,e){let i=t.options.colors||t.chart.options.colors,o=i?i.length:t.chart.options.chart.colorCount,r=e.y%o,s=i?.[r];return{colorIndex:r,color:s}}resolveColor(){let t=this.series;if(t.options.colorByPoint&&!this.options.color){let e=M.getColorByCategory(t,this);t.chart.styledMode||(this.color=e.color),(void 0===this.options.colorIndex||null===this.options.colorIndex)&&(this.colorIndex=e.colorIndex)}else this.color=this.options.color||t.color}constructor(t,e){super(t,e),this.y||(this.y=0)}applyOptions(t,e){return super.applyOptions(t,e),this.x2=this.series.chart.time.parse(this.x2),this.isNull=!this.isValid?.(),this.formatPrefix=this.isNull?"null":"point",this}setState(){super.setState.apply(this,arguments),this.series.drawPoint(this,this.series.getAnimationVerb())}isValid(){return"number"==typeof this.x&&"number"==typeof this.x2}}x(M.prototype,{ttBelow:!1,tooltipDateKeys:["x","x2"]});let{composed:R,noop:O}=l(),{parse:S}=h(),{column:j}=d().seriesTypes;function X(){let t,e;if(this.isXAxis){for(let i of(t=w(this.dataMax,-Number.MAX_VALUE),this.series)){let o=i.dataTable.getColumn("x2",!0)||i.dataTable.getColumn("end",!0);if(o)for(let i of o)v(i)&&i>t&&(t=i,e=!0)}e&&(this.dataMax=t)}}class _ extends j{static compose(t){0>R.indexOf("Series.XRange")&&R.push("Series.XRange")&&function(t,e,i,o={}){let r="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(r,"hcEvents")||(r.hcEvents={});let s=r.hcEvents;l().Point&&t instanceof l().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let a=t.addEventListener;a&&a.call(t,e,i,!!l().supportsPassiveEvents&&{passive:void 0===o.passive?-1!==e.indexOf("touch"):o.passive,capture:!1}),s[e]||(s[e]=[]);let n={fn:i,order:"number"==typeof o.order?o.order:1/0};s[e].push(n),s[e].sort((t,e)=>t.order-e.order)}(t,"afterGetSeriesExtremes",X)}init(){super.init.apply(this,arguments),this.options.stacking=void 0}getColumnMetrics(){let t=()=>{for(let t of this.chart.series){let e=t.xAxis;t.xAxis=t.yAxis,t.yAxis=e}};t();let e=super.getColumnMetrics();return t(),e}cropData(t,e,i){let o=t.getColumn("x")||[],r=t.getColumn("x2");t.setColumn("x",r,void 0,{silent:!0});let s=super.cropData(t,e,i);return t.setColumn("x",o.slice(s.start,s.end),void 0,{silent:!0}),s}findPointIndex(t){let e,{cropStart:i,points:o}=this,{id:r}=t;if(r){let t=m(o,t=>t.id===r);e=t?t.index:void 0}if(void 0===e){let i=m(o,e=>e.x===t.x&&e.x2===t.x2&&!e.touched);e=i?i.index:void 0}return this.cropped&&v(e)&&v(i)&&e>=i&&(e-=i),e}alignDataLabel(t){let e=t.plotX;t.plotX=w(t.dlBox?.centerX,t.plotX),t.dataLabel&&t.shapeArgs?.width&&t.dataLabel.css({width:`${t.shapeArgs.width}px`}),super.alignDataLabel.apply(this,arguments),t.plotX=e}translatePoint(t){var e,i;let o=this.xAxis,r=this.yAxis,s=this.columnMetrics,a=this.options,n=a.minPointLength||0,l=(t.shapeArgs?.width||0)/2,p=this.pointXOffset=s.offset,h=w(t.x2,t.x+(t.len||0)),c=a.borderRadius,d=this.chart.plotTop,u=this.chart.plotLeft,f=t.plotX,x=o.translate(h,0,0,0,1),m=Math.abs(x-f),b=this.chart.inverted,P=w(a.borderWidth,1),M,R,O=s.offset,S=Math.round(s.width),j,X,_,F;n&&((M=n-m)<0&&(M=0),f-=M/2,x+=M/2),f=Math.max(f,-10),x=y(x,-10,o.len+10),null!=t.options.pointWidth&&(O-=(Math.ceil(t.options.pointWidth)-S)/2,S=Math.ceil(t.options.pointWidth)),a.pointPlacement&&v(t.plotY)&&r.categories&&(t.plotY=r.translate(t.y,0,1,0,1,a.pointPlacement));let H=g(Math.min(f,x),P),I=g(Math.max(f,x),P)-H,L=Math.min((e="object"==typeof c?c.radius:c||0,i=S,/%$/.test(e)?i*parseFloat(e)/100+0:parseFloat(e)),Math.min(I,S)/2),T={x:H,y:g((t.plotY||0)+O,P),width:I,height:S,r:L};t.shapeArgs=T,b?t.tooltipPos[1]+=p+l:t.tooltipPos[0]-=l+p-T.width/2,X=(j=T.x)+T.width,j<0||X>o.len?(j=y(j,0,o.len),_=(X=y(X,0,o.len))-j,t.dlBox=C(T,{x:j,width:X-j,centerX:_?_/2:null})):t.dlBox=null;let B=t.tooltipPos,E=+!!b,N=+!b,D=this.columnMetrics?this.columnMetrics.offset:-s.width/2;b?B[E]+=T.width/2:B[E]=y(B[E]+(o.reversed?-1:0)*T.width,o.left-u,o.left+o.len-u-1),B[N]=y(B[N]+(b?-1:1)*D,r.top-d,r.top+r.len-d-1),(R=t.partialFill??0)&&(A(R)&&(R=R.amount||0),v(R)||(R=0),t.partShapeArgs=C(T),F=Math.max(Math.round(m*R+t.plotX-f),0),t.clipRectArgs={x:o.reversed?T.x+m-F:T.x,y:T.y,width:F,height:T.height}),t.key=t.category||t.name,t.yCategory=r.categories?.[t.y??-1]}translate(){for(let t of(super.translate.apply(this,arguments),this.points))this.translatePoint(t)}drawPoint(t,e){let i=this.options,o=this.chart.renderer,r=t.shapeType,s=t.shapeArgs,a=t.partShapeArgs,n=t.clipRectArgs,l=t.state,p=i.states[l||"normal"]||{},h=void 0===l?"attr":e,c=this.pointAttribs(t,l),d=w(this.chart.options.chart.animation,p.animation),u=t.graphic,f=t.partialFill;if(t.isNull||!1===t.visible)u&&(t.graphic=u.destroy());else if(u?u.rect[e](s):(t.graphic=u=o.g("point").addClass(t.getClassName()).add(t.group||this.group),u.rect=o[r](C(s)).addClass(t.getClassName()).addClass("highcharts-partfill-original").add(u)),a&&(u.partRect?(u.partRect[e](C(a)),u.partialClipRect[e](C(n))):(u.partialClipRect=o.clipRect(n.x,n.y,n.width,n.height),u.partRect=o[r](a).addClass("highcharts-partfill-overlay").add(u).clip(u.partialClipRect))),!this.chart.styledMode&&(u.rect[e](c,d).shadow(i.shadow),a)){A(f)||(f={}),A(i.partialFill)&&(f=C(i.partialFill,f));let e=f.fill||S(c.fill).brighten(-.3).get()||S(t.color||this.color).brighten(-.3).get();c.fill=e,u.partRect[h](c,d).shadow(i.shadow)}}drawPoints(){let t=this.getAnimationVerb();for(let e of this.points)this.drawPoint(e,t)}getAnimationVerb(){return this.chart.pointCount<(this.options.animationLimit||250)?"animate":"attr"}isPointInside(t){let e=t.shapeArgs,i=t.plotX,o=t.plotY;return e?void 0!==i&&void 0!==o&&o>=0&&o<=this.yAxis.len&&(e.x||0)+(e.width||0)>=0&&i<=this.xAxis.len:super.isPointInside.apply(this,arguments)}}_.defaultOptions=C(j.defaultOptions,{colorByPoint:!0,dataLabels:{formatter:function(){let t=this.partialFill;if(A(t)&&(t=t.amount),v(t)&&t>0){var e;return((e=100*t)>1e14?e:parseFloat(e.toPrecision(14)))+"%"}},inside:!0,verticalAlign:"middle",style:{whiteSpace:"nowrap"}},tooltip:{headerFormat:'<span style="font-size: 0.8em">{ucfirst point.x} - {point.x2}</span><br/>',pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.yCategory}</b><br/>'},borderRadius:3,pointRange:0}),x(_.prototype,{pointClass:M,pointArrayMap:["x2","y"],getExtremesFromAll:!0,keysAffectYAxis:["y"],parallelArrays:["x","x2","y"],requireSorting:!1,type:"xrange",animate:d().series.prototype.animate,autoIncrement:O,buildKDTree:O}),d().registerSeriesType("xrange",_);let F=l();_.compose(F.Axis);let H=l();return a.default})());