UNPKG

highcharts

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