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