highcharts
Version:
JavaScript charting framework
13 lines • 8.06 kB
JavaScript
!/**
* Highcharts JS v13.0.1 (2026-08-17)
* @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 s={620(t){t.exports=e},512(t){t.exports=i},944(e){e.exports=t}};let r={};function o(t){let e=r[t];if(void 0!==e)return e.exports;let i=r[t]={exports:{}};return s[t](i,i.exports,o),i.exports}o.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var s=e[i++],r=e[i++];o.o(t,s)?0===r&&i++:0===r?Object.defineProperty(t,s,{enumerable:!0,value:e[i++]}):Object.defineProperty(t,s,{enumerable:!0,get:r})}else for(var s in e)o.o(e,s)&&!o.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let a={};o.d(a,{default:()=>C});var l=o(944),n=o.n(l),p=o(620),h=o.n(p),c=o(512),d=o.n(c);let{column:{prototype:{pointClass:u}}}=d().seriesTypes;class g extends u{static getColorByCategory(t,e){let i=t.chart,s=t.options.colors||i.options.colors,r=s?s.length:i.options.chart.colorCount||1,o=(e.y||0)%r,a=s?.[o];return{colorIndex:o,color:a}}resolveColor(){let t=this.series;if(t.options.colorByPoint&&!this.options.color){let e=g.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,i){super(t,e,i),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}}(0,l.extend)(g.prototype,{ttBelow:!1,tooltipDateKeys:["x","x2"]});let{composed:x,noop:m}=n(),{parse:f}=h(),{column:y}=d().seriesTypes;function b(){let t,e,i=this.chart.time;if(this.isXAxis){for(let s of(t=this.dataMax??-Number.MAX_VALUE,this.series))for(let r of s.dataTable.getColumn("x2",!0)||s.dataTable.getColumn("end",!0)||[])"string"==typeof r&&(r=i.parse(r)),(0,l.isNumber)(r)&&r>t&&(t=r,e=!0);e&&(this.dataMax=t)}}class A extends y{static compose(t){(0,l.pushUnique)(x,"Series.XRange")&&(0,l.addEvent)(t,"afterGetSeriesExtremes",b)}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 s=t.getColumn("x")||[],r=t.getColumn("x2");t.setColumn("x",r,void 0,{silent:!0});let o=super.cropData(t,e,i);return t.setColumn("x",s.slice(o.start,o.end),void 0,{silent:!0}),o}findPointIndex(t){let e,{cropStart:i,points:s}=this,{id:r}=t;if(r){let t=(0,l.find)(s,t=>t.id===r);e=t?t.index:void 0}if(void 0===e){let i=(0,l.find)(s,e=>e.x===t.x&&e.x2===t.x2&&!e.touched);e=i?i.index:void 0}return this.cropped&&(0,l.isNumber)(e)&&(0,l.isNumber)(i)&&e>=i&&(e-=i),e}alignDataLabel(t){let e=t.plotX;t.plotX=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){let e=this.xAxis,i=this.yAxis,s=this.columnMetrics,r=this.options,o=r.minPointLength||0,a=(t.shapeArgs?.width||0)/2,n=this.pointXOffset=s.offset,p=t.x2??t.x+(t.len||0),h=r.borderRadius,c=this.chart.plotTop,d=this.chart.plotLeft,u=t.plotX,g=e.translate(p,0,0,0,1),x=Math.abs(g-u),m=this.chart.inverted,f=r.borderWidth??1,y,b,A=s.offset,w=Math.round(s.width),C,v,M,P;o&&((y=o-x)<0&&(y=0),u-=y/2,g+=y/2),u=Math.max(u,-10),g=(0,l.clamp)(g,-10,e.len+10),(0,l.defined)(t.options.pointWidth)&&(A-=(Math.ceil(t.options.pointWidth)-w)/2,w=Math.ceil(t.options.pointWidth)),r.pointPlacement&&(0,l.isNumber)(t.plotY)&&i.categories&&(t.plotY=i.translate(t.y,0,1,0,1,r.pointPlacement));let R=(0,l.crisp)(Math.min(u,g),f),O=(0,l.crisp)(Math.max(u,g),f)-R,S=Math.min((0,l.relativeLength)("object"==typeof h?h.radius:h||0,w),Math.min(O,w)/2),X={x:R,y:(0,l.crisp)((t.plotY||0)+A,f),width:O,height:w,r:S};t.shapeArgs=X,m?t.tooltipPos[1]+=n+a:t.tooltipPos[0]-=a+n-X.width/2,v=(C=X.x)+X.width,C<0||v>e.len?(C=(0,l.clamp)(C,0,e.len),M=(v=(0,l.clamp)(v,0,e.len))-C,t.dlBox=(0,l.merge)(X,{x:C,width:v-C,centerX:M?M/2:null})):t.dlBox=null;let j=t.tooltipPos,N=+!!m,H=+!m,L=this.columnMetrics?this.columnMetrics.offset:-s.width/2;m?j[N]+=X.width/2:j[N]=(0,l.clamp)(j[N]+(e.reversed?-1:0)*X.width,e.left-d,e.left+e.len-d-1),j[H]=(0,l.clamp)(j[H]+(m?-1:1)*L,i.top-c,i.top+i.len-c-1),(b=t.partialFill??0)&&((0,l.isObject)(b)&&(b=b.amount||0),(0,l.isNumber)(b)||(b=0),t.partShapeArgs=(0,l.merge)(X),P=Math.max(Math.round(x*b+t.plotX-u),0),t.clipRectArgs={x:e.reversed?X.x+x-P:X.x,y:X.y,width:P,height:X.height}),t.key=t.category||t.name,t.yCategory=i.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,s=this.chart.renderer,r=t.shapeType,o=t.shapeArgs,a=t.partShapeArgs,n=t.clipRectArgs,p=t.state,h=i.states?.[p||"normal"]||{},c=void 0===p?"attr":e,d=this.pointAttribs(t,p),u=this.chart.options.chart.animation??h.animation,g=t.graphic,x=t.partialFill;if(t.isNull||!1===t.visible)g&&(t.graphic=g.destroy());else{let h=t.getClassName();if(g?g.rect[e](o):(t.graphic=g=s.g("point").add(t.group||this.group),g.rect=s[r]((0,l.merge)(o)).add(g)),g.addClass(h+(p&&"select"!==p?" highcharts-point-"+p:""),!0),g.rect.addClass(h+" highcharts-partfill-original",!0),a&&(g.partRect?(g.partRect[e]((0,l.merge)(a)),g.partialClipRect[e]((0,l.merge)(n))):(g.partialClipRect=s.clipRect(n.x,n.y,n.width,n.height),g.partRect=s[r](a).addClass("highcharts-partfill-overlay").add(g).clip(g.partialClipRect))),!this.chart.styledMode&&(g.rect[e](d,u).shadow(i.shadow),a)){(0,l.isObject)(x)||(x={}),(0,l.isObject)(i.partialFill)&&(x=(0,l.merge)(i.partialFill,x));let e=x.fill||f(d.fill).brighten(-.3).get()||f(t.color||this.color).brighten(-.3).get();d.fill=e,g.partRect[c](d,u).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,s=t.plotY;return e?void 0!==i&&void 0!==s&&s>=0&&s<=this.yAxis.len&&(e.x||0)+(e.width||0)>=0&&i<=this.xAxis.len:super.isPointInside.apply(this,arguments)}}A.defaultOptions=(0,l.merge)(y.defaultOptions,{colorByPoint:!0,dataLabels:{formatter:function(){let t=this.partialFill;if((0,l.isObject)(t)&&(t=t.amount),(0,l.isNumber)(t)&&t>0)return(0,l.correctFloat)(100*t)+"%"},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}),(0,l.extend)(A.prototype,{pointClass:g,pointArrayMap:["x2","y"],getExtremesFromAll:!0,keysAffectYAxis:["y"],parallelArrays:["x","x2","y"],requireSorting:!1,type:"xrange",animate:d().series.prototype.animate,autoIncrement:m,buildKDTree:m}),d().registerSeriesType("xrange",A);let w=n();A.compose(w.Axis);let C=n();return a.default})());