realchart 1.4.30 → 1.4.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gauge.js +2 -2
- package/gauge.mjs +2 -2
- package/heatmap.js +1 -1
- package/heatmap.mjs +1 -1
- package/ie/gauge.ie.js +2 -2
- package/ie/heatmap.ie.js +1 -1
- package/ie/index.ie.js +2 -2
- package/ie/pictogram.ie.js +2 -2
- package/ie/split.ie.js +2 -2
- package/ie/treemap.ie.js +2 -2
- package/ie/vector.ie.js +2 -2
- package/ie/wordcloud.ie.js +2 -2
- package/index.d.ts +302 -464
- package/index.js +2 -2
- package/index.mjs +2 -2
- package/package.json +1 -1
- package/pictogram.js +2 -2
- package/pictogram.mjs +2 -2
- package/split.d.ts +1 -1
- package/split.js +2 -2
- package/split.mjs +2 -2
- package/treemap.js +2 -2
- package/treemap.mjs +2 -2
- package/vector.js +2 -2
- package/vector.mjs +2 -2
- package/wordcloud.js +2 -2
- package/wordcloud.mjs +2 -2
package/gauge.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* RealChart Gauge v1.4.
|
|
3
|
+
* RealChart Gauge v1.4.32
|
|
4
4
|
* Copyright (C) 2023-2026 WooriTech Inc.
|
|
5
5
|
* All Rights Reserved.
|
|
6
6
|
*/
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RealChartGauge={},e.RealChart)}(this,function(e,t){"use strict";function i(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,Object.freeze(t)}var s=i(t);class a extends t.GaugeItem{constructor(e){super(e),this.gauge=e}getRanges(e){if(!e){const t=this.gauge.calcedMinMax();e={minValue:t.min,maxValue:t.max}}let i=e.minValue,s=e.maxValue;if(!(s>i)&&(s=t.maxv(i,t.pickNum(this.gauge.options.value,i)),this._ranges))for(let e=0;e<this._ranges.length;e++){const i=t.pickNum(this._ranges[e].toValue,NaN);isNaN(i)||(s=t.maxv(s,i))}return t.buildValueRanges(this._ranges,i,s,!1,!0)||[]}getRange(e,t){const i=this.$_internalRanges(e);if(i)for(let e=0,s=i.length;e<s;e++){const a=i[e];if(t>=a.fromValue&&(t<a.toValue||e===s-1&&t<=a.toValue))return a}}_doApply(e){const t=this;var i;super._doApply(e),(i=e.ranges)!==t._ranges&&(t._ranges=i,t._runRanges=null)}$_internalRanges(e){return this._runRanges||(this._runRanges=t.buildValueRanges(this._ranges,e.minValue,e.maxValue,this._op.rangeInclusive)||[]),this._runRanges}}a.defaults=t.extend(t.ChartItem.defaults,{rangeInclusive:!0});class n extends a{getSegmentThickness(e){return t.calcPercent(this._segmentThicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"segmentThickness")}}n.defaults=t.extend(a.defaults,{segmentGap:0});class l extends a{getThickness(e){return t.calcPercent(this._thicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"thickness")}}l.defaults=t.extend(a.defaults,{thickness:"100%",stroked:!1});class r extends t.GaugeItem{}r.defaults=t.extend(t.ChartItem.defaults,{visible:!1});class h extends t.GaugeItem{getExtents(e){return{radius:t.calcPercent(this._radiusDim,e,0),length:t.calcPercent(this._lengthDim,e,0),offset:t.calcPercent(this._offsetDim,e,0)}}_doApply(e){super._doApply(e),this._setDims(e,"radius","length","offset")}}h.defaults=t.extend(t.ChartItem.defaults,{visible:!1,radius:3,length:"100%",offset:0});class o extends t.GaugeItem{getRadius(e){return t.calcPercent(this._radiusDim,e,0)}_doApply(e){super._doApply(e),this._setDim(e,"radius")}}o.defaults=t.extend(t.ChartItem.defaults,{visible:!1,radius:5});class c extends t.GaugeScale{_getStepMultiples(e){return[1,2,2.5,5,10]}}c.defaults=t.extend(t.GaugeScale.defaults,{visible:!1,stepPixels:72});class u extends t.CircularGauge{_doInit(e){super._doInit(e),e.band=(this._band=new t.GaugeRangeBand(this)).init(),e.scale=(this._scale=new c(this)).init(),e.rim=(this._rim=new n(this)).init(),e.valueRim=(this._valueRim=new l(this)).init(),e.hand=(this._hand=new h(this)).init(),e.pin=(this._pin=new o(this)).init()}get band(){return this._band}get scale(){return this._scale}get rim(){return this._rim}get valueRim(){return this._valueRim}get hand(){return this._hand}get pin(){return this._pin}getExtents(e){const i=super.getExtents(e),s=this.scale,a=this.band;let n=i.radius;const l=n-i.inner;if(a.visible)switch(i.bandThick=a.getThickness(l),a.options.position){case"inside":i.band=n-(l-i.bandThick)/2;break;case"opposite":i.band=i.inner-a.options.gap,i.inner=i.band-i.bandThick;break;default:i.band=n+=i.bandThick+a.options.gap}if(i.scaleTick=t.maxv(1,s.tick.options.length||0),i.scaleLabel=16,"opposite"===s.options.position)i.scale=t.maxv(i.inner-s.options.gap,0),i.inner=i.scale-i.scaleTick-i.scaleLabel;else i.scale=n+s.options.gap;return i}}u.type=t.CircleGaugeType;class d extends t.CircularGaugeGroup{_gaugesType(){return"circle"}}d.type=t.CircleGaugeGroupType,d.gaugeType=t.CircleGaugeType,d.defaults=t.extend(t.CircularGaugeGroup.defaults,{innerRadius:"50%"});class g extends t.ValueGaugeView{}class _ extends t.ScaleView{setExtents(e,t){this._center=e,this._exts=t}_createLine(e,i){return new t.ArcElement(e,i)}_doMeasure(e,t,i,s,a){const n=t._steps.length-(360===t.gauge.options.sweepAngle?1:0);return this._line.setVis(t.line.visible)&&this._line.internalSetStyleOrClass(t.line._style),this._tickContainer.setVis(t.tick.visible)&&(this._tickContainer.internalSetStyleOrClass(t.tick._style),this._ticks.prepare(n)),this._labelContainer.setVis(t.label.visible)&&(this._labelContainer.internalSetStyleOrClass(t.label._style),this._labels.prepare(n)),{width:i,height:s}}_doLayout(e){const i=this.model,s=i._steps,a=i.gauge,n=a.options,l="opposite"===i.options.position?-1:1,r=a.getProps(),h=this._center.x,o=this._center.y,c=this._exts.scale,u=c+this.model.tick.options.length*l,d=r._sweepRad,g=r._startRad,_=n.maxValue-n.minValue,p=n.clockwise;let b,w,m,x;if(this._line.visible&&this._line.setArc(h,o,c,g,p?d:-d,p),this._tickContainer.visible&&this._ticks.forEach((e,a,n)=>{const l=i.getRate(s[a])*(p?d:-d)+g;b=h+t.cos(l)*c,w=o+t.sin(l)*c,m=h+t.cos(l)*u,x=o+t.sin(l)*u,e.setLine(b,w,m,x)}),this._labelContainer.visible){this._labels.get(0).setText(String(n.maxValue));const e=u+.2*this._labels.get(0).getBBox().height*l;this._labels.forEach((a,r)=>{const c=i.getRate(s[r])*(p?d:-d)+g;a.setText(String(t.fixnum(n.minValue+i.getRate(s[r])*_))),a.setContrast(null).layout("center");const u=a.getBBox();m=h+t.cos(c)*(e+u.width/2*l)-u.width/2,x=o+t.sin(c)*(e+u.height/2*l)-u.height/2,a.trans(m,x)})}}}class p extends t.ChartElement{constructor(e){super(e,"rct-circle-gauge-rim"),this._sectorViews=new t.ElementPool(this,t.SectorElement,"rct-circle-gauge-rim")}setExtents(e,t){this._center=e,this._exts=t}_doLayout(e){const i=this.model,s=i.gauge,a=s.options,n=s.getProps(),l=i.getRanges(),r=this._center.x,h=this._center.y,o=this._exts.radius,c=1-i.getSegmentThickness(this._exts.radiusThick)/o,u=a.clockwise,d=n._sweepRad;let g=n._startRad;if(0===l.length){const e=this._sectorViews.prepare(1).get(0);return e.internalSetStyleOrClass(i._style),void e.setSector({cx:r,cy:h,rx:o,ry:o,innerRadius:c,start:g,angle:d,clockwise:u})}const _=t.pickNum(i.options.segmentGap,0),p=_>0?_/o:0,b=p*(l.length-1),w=t.maxv(0,d-b),m=l.reduce((e,t)=>e+(t.toValue-t.fromValue),0);this._sectorViews.prepare(l.length).forEach((e,t)=>{const i=m>0?(l[t].toValue-l[t].fromValue)/m*w:0;e.setSector({cx:r,cy:h,rx:o,ry:o,innerRadius:c,start:g,angle:i,clockwise:u}),e.internalClearStyleAndClass(),e.setFill(l[t].color),l[t].style&&e.addStyleOrClass(l[t].style),g+=u?i+p:-(i+p)})}}let b=class extends t.ChartElement{constructor(e){super(e,"rct-circle-gauge-band"),this._sectorViews=new t.ElementPool(this,t.SectorElement),this.add(this._labelContainer=new t.LayerElement(e,"rct-circle-gauge-band-tick-labels")),this._labels=new t.ElementPool(this._labelContainer,t.TextElement)}setExtends(e,t){this._center=e,this._exts=t}_doLayout(e){const t=this.model,i=t.gauge,s=i.getProps(),a=this._center.x,n=this._center.y,l=this._exts.band,r=i.options.clockwise,h=1-this._exts.bandThick/l,o=t.getRanges(),c=s._sweepRad;let u=s._startRad;const d=o.reduce((e,t)=>e+(t.toValue-t.fromValue),0);this._sectorViews.prepare(o.length).forEach((e,t)=>{const i=d>0?(o[t].toValue-o[t].fromValue)/d*c:0;e.setSector({cx:a,cy:n,rx:l,ry:l,innerRadius:h,start:u,angle:i,clockwise:r}),e.internalClearStyleAndClass(),e.setFill(o[t].color),o[t].style&&e.addStyleOrClass(o[t].style),u+=r?i:-i})}};class w extends t.PathElement{render(e,i){const s=e.getRadius(i);return s!==this._radius&&(this._radius=s,this.setPath((new t.PathBuilder).circle(0,0,s).end())),this.internalSetStyleOrClass(e._style),this}}class m extends t.PathElement{render(e,i){const s=e.getExtents(i);if(s.radius!==this._radius||s.length!==this._length||s.offset!==this._offset){const e=this._radius=s.radius,i=this._offset=s.offset;if(this._length=s.length,this._radius>0&&this._length>0){const s=new t.PathBuilder;s.move(-e,i).line(0,-this._length+i).line(e,i),this.setPath(s.end())}else this.setPath("")}return this.internalSetStyleOrClass(e._style),this}}class x extends g{constructor(e){super(e,"rct-circle-gauge")}_doInitContents(e,i){i.add(this._rimView=new p(e)),i.add(this._valueView=new t.SectorElement(e,"rct-circle-gauge-value")),i.add(this._innerView=new t.SectorElement(e,"rct-circle-gauge-inner")),i.add(this._textView=new t.TextElement(e,"rct-circle-gauge-label")),i.add(this._handContainer=new t.LayerElement(e,void 0)),i.add(this._scaleView=new _(e)),i.add(this._bandView=new b(e))}_backgroundView(){return this._rimView}_prepareGauge(e,t){this._rimView.setVis(t.rim.visible),this._scaleView.setVis(t.scale.visible),this._bandView.setVis(t.band.visible),this._valueView.setVis(t.valueRim.visible),t.hand.visible?(this._handView||this._handContainer.add(this._handView=new m(e,"rct-circle-gauge-hand")),this._handView.visible=!0):this._handView&&(this._handView.visible=!1),t.pin.visible?(this._pinView||this._handContainer.add(this._pinView=new w(e,"rct-circle-gauge-pin")),this._pinView.visible=!0):this._pinView&&(this._pinView.visible=!1),this._textView.setVis(t.labelVisible())&&this._textView.setStyleOrClass(t.label._style)}_renderGauge(e,i){const s=this.model,a=s.getCenter(e,i),n=s.getExtents(t.minv(e,i));this.$_renderBackground(s,a,n),this._renderValue()}_renderValue(){const e=this.model,i=e.options,s=e.scale,a=e.getProps(),n=e.getValue(),l=s.getRate(t.pickNum(n,0)),r=this._center,h=this._exts,o=e.valueRim.getThickness(h.radiusThick),c=this._textView;if(this._valueView.visible){const s=e.valueRim,c=s.options,u=s.getRange(i,n),d=h.value+(c.stroked?0:o/2),g=this._valueView;g.setStyleOrClass(s._style),u&&(g.setStyle(c.stroked?"stroke":"fill",u.color),u.style&&g.addStyleOrClass(u.style)),c.stroked&&(g.setFill("none"),g.setStyle("strokeWidth",t.pixel(o))),g.setBoolData("stroked",c.stroked),g.setSectorEx({cx:r.x,cy:r.y,rx:d,ry:d,innerRadius:(d-o)/d,start:a._startRad,angle:a._sweepRad*l,clockwise:i.clockwise},c.stroked)}if(this._handView){const i=(a._handRad+a._sweepRad*l)*t.RAD_DEG;this._handView.render(e.hand,h.radius).transp(r).rotate(e.options.clockwise?i:-i)}if(c.visible){const t=e.label;if(t.setText(e.getLabel(t,t.options.animatable?n:i.value)),c.text=t.options.text,c.setBoolData("grouped",!!e._group),t.buildSvg(c,null,NaN,NaN,e,t._domain),e._group)this.$_layoutGroupedLabel(e,c,h);else{const e=c.getBBox(),i=t.getOffset(this.width,this.height);c.trans(r.x+i.x,r.y-e.height/2+i.y)}}}$_renderBackground(e,t,i){const s=e.getProps();this._center=t,this._exts=i,e.scale.buildSteps(i.scale*s._sweepRad,NaN),this._rimView.visible&&(this._rimView.measure(this.doc,e.rim,this.width,this.height,0),this._rimView.setExtents(t,i),this._rimView.layout()),this._scaleView.visible&&(this._scaleView.setStyleOrClass(e.scale._style),this._scaleView.measure(this.doc,e.scale,this.width,this.height,0),this._scaleView.setExtents(t,i),this._scaleView.layout()),this._bandView.visible&&(this._bandView.setStyleOrClass(e.band._style),this._bandView.measure(this.doc,e.band,this.width,this.height,0),this._bandView.setExtends(t,i),this._bandView.layout()),this._innerView.setStyleOrClass(e.options.innerStyle);let a=i.inner;const n=getComputedStyle(this._innerView.dom),l=parseFloat(n.strokeWidth);l>1&&(a-=l/2),this._innerView.setSector({cx:t.x,cy:t.y,rx:a,ry:a,innerRadius:0,start:0,angle:2*Math.PI,clockwise:!0}),this._pinView&&this._pinView.render(e.pin,a).trans(t.x,t.y)}$_layoutGroupedLabel(e,i,s){const a=i.getBBox(),n=this._center,l=+e._group.options.labelGap||0;i.anchor=t.TextAnchor.END,i.trans(n.x-l,n.y-s.radius+(s.radius-s.inner-a.height)/2)}}class y extends t.GaugeGroupView{constructor(e){super(e,"rct-circle-gauge-group")}_createPool(e){return new t.ElementPool(e,x)}_doRenderGauges(e,i,s,a){const n=this.doc,l=this.model,r=l.props.getCenter(s,a),h=l.props.getExtents(t.minv(s,a));l.setChildExtents(h),s=a=2*h.radius,i.forEach((e,t)=>{e.measure(n,l.getVisible(t),s,a,0),e.resize(s,a),e.layout()}),e.trans(r.x-h.radius,r.y-h.radius)}}class V extends t.GaugeScale{}class v extends t.GaugeLabel{getWidth(e){return t.calcPercent(this._widthDim,e)}getHeight(e){return t.calcPercent(this._heightDim,e)}getMaxWidth(e){return t.calcPercent(this._maxWidthDim,e)}getMaxHeight(e){return t.calcPercent(this._maxHeightDim,e)}getGap(e){return t.calcPercent(this._gapDim,e,0)}_doApply(e){super._doApply(e),this._setDims(e,"width","height","maxWidth","maxHeight","gap")}}v.defaults=t.extend(t.GaugeLabel.defaults,{maxWidth:"30%",maxHeight:"30%",gap:10});class f extends t.ValueGauge{_doInit(e){super._doInit(e),e.scale=(this._scale=new V(this)).init()}get label(){return this._label}get scale(){return this._scale}_createLabel(){return new v(this.chart)}isVertical(){return this._group?this._group.options.vertical:this._op.vertical}scaleVisible(){return!this._group&&this._scale.visible}calcedMinMax(){return this._scale.range()}_doPrepareRender(e){super._doPrepareRender(e),this._label._prepareRender()}}f.defaults=t.extend(t.ValueGauge.defaults,{reversed:!1});class k extends t.GaugeItem{constructor(){super(...arguments),this._args={gauge:null,value:NaN}}getStyle(e,t){if(this._op.styleCallback){this._args.gauge=e,this._args.value=t;return this._op.styleCallback(this._args)}}}class C extends f{_doInit(e){super._doInit(e),e.valueBar=(this._valueBar=new k(this)).init(),e.band=(this._band=new t.GaugeRangeBand(this)).init()}get valueBar(){return this._valueBar}get band(){return this._band}}C.type=t.LinearGaugeType;class S extends t.ChartItem{}S.defaults=t.extend(t.ChartItem.defaults,{opposite:!1,gap:10});class E extends v{}E.defaults=t.extend(v.defaults,{gap:10});class R extends t.GaugeGroup{_doInit(e){super._doInit(e),e.label=(this._label=new E(this.chart)).init(),e.itemLabel=(this._itemLabel=new S(this.chart)).init(),e.scale=(this._scale=new V(this)).init()}get label(){return this._label}get itemLabel(){return this._itemLabel}get scale(){return this._scale}calcedMinMax(){return this.scale.range()}}R.defaults=t.extend(t.GaugeGroup.defaults,{vertical:!1,itemGap:10});class L extends R{_doInit(e){super._doInit(e),e.band=(this._band=new t.GaugeRangeBand(this)).init()}get band(){return this._band}_gaugesType(){return"linear"}_doPrepareRender(e){super._doPrepareRender(e),this.band.visible&&this.band._prepareRender()}}L.type=t.LinearGaugeGroupType,L.gaugeType=t.LinearGaugeType;class G extends t.ScaleView{_createLine(e,i){return new t.LineElement(e,i)}_doMeasure(e,i,s,a,n){const l=i.options,r=i._reversed,h=i._vertical,o=i.label,c=i.tick,u=i._steps,d=u.length;let g=h?l.gap:s,_=h?a:l.gap;if(this._tickContainer.setVis(c.visible)&&(this._tickContainer.setStyleOrClass(c._style),this._ticks.prepare(d)),h?g+=c.options.length:_+=c.options.length,this._labelContainer.setVis(o.visible)&&(this._labels.prepare(d,t=>{t.setModel(e,o,null,null)}),d>0))if(h){let e=0;this._labels.forEach((i,s)=>{i.setText(o.getText(u[r?s:d-1-s])),e=t.maxv(i.getBBox().width)}),g+=e}else{let e=0;this._labels.forEach((i,s)=>{i.setText(o.getText(u[r?d-1-s:s])),e=t.maxv(i.getBBox().height)}),_+=e}return{width:g,height:_}}_doLayout(){const e=this.model;e._vertical?this.$_layoutVert(e,this.width,this.height):this.$_layoutHorz(e,this.width,this.height)}$_layoutHorz(e,t,i){const s=e.options,a=this._line,n=e.tick,l=e._steps;l.length;const r="opposite"===s.position,h=r?-n.options.length:n.options.length;let o,c=r?i-s.gap:s.gap;if(a.setVis(e.line.visible)&&(a.setStyleOrClass(e.line._style),a.setHLine(c,0,t)),this._tickContainer.setVis(n.visible)&&this._ticks.forEach((i,s)=>{o=e.getRate(l[s])*t,i.setVLine(o,c,c+h)}),this._labelContainer.visible){const i=this._labelContainer.textAlign()||"center";let s=Number.MIN_SAFE_INTEGER;c=r?0:c+h,this._labels.forEach((a,n)=>{a.layout(i);const r=a.getBBox();o=e.getRate(l[n])*t,a.setVis(o-r.width/2>s)&&(a.trans(o-r.width/2,c),s=o+r.width/2)})}}$_layoutVert(e,t,i){const s=e.options,a=this._line,n=e.tick,l=e._steps;this.height,l.length;const r="opposite"===s.position,h=r?n.options.length:-n.options.length;let o,c=r?s.gap:t-s.gap;if(a.setVis(e.line.visible)&&(a.setStyleOrClass(e.line._style),a.setVLine(c,0,i)),this._tickContainer.setVis(n.visible)&&this._ticks.forEach((t,s)=>{o=e.getRate(l[s])*i,t.setHLine(o,c,c+h)}),this._labelContainer.visible){const a=this._labelContainer.textAlign()||(r?"left":"right");c=r?c+h:t-s.gap+h,this._labels.forEach((t,s)=>{t.layout(a);const n=t.getBBox(),h=r?c:c-n.width;o=e.getRate(l[s])*i,t.trans(h,o-n.height/2)})}}}class B extends t.ValueGaugeView{_measureLabelSize(e,i,s){const a=e.label,n=this.labelView();return a.setText(e.getLabel(a,e.options.value)),n.text=a.options.text,a.buildSvg(n,null,i,s,e,a._domain),t.rectToSize(n.getBBox())}_renderGauge(e,i){const s=this.model,a=t.pickNum(s._runValue,s.options.value);this._measureGauge(s,s.label,this.labelView(),a,s.isVertical(),e,i),this._renderValue()}_renderValue(){const e=this.model,i=e.label,s=e.scale,a=this.labelView(),n=t.pickNum(e._runValue,e.options.value),l=t.assignObj({},this._rBand);if(this._renderScale(l),this.background().setRect(l),l.height>0&&this._renderBand(e,l,n),"top"!==i._runPos&&"bottom"!==i._runPos||(this._rLabel.height=l.height),this._renderLabel(e,i,a,n),!this._vertical&&("left"===i._runPos||"right"===i._runPos)&&s.visible&&"opposite"===s.options.position){const e=a.getBBox();a.ty+e.height>this.height&&a.transY(t.maxv(0,this.height-e.height))}}_measureGauge(e,i,s,a,n,l,r){const h=this._rBand=t.createRect(0,0,l,r);if(this._vertical=e._group instanceof R?e._group.options.vertical:n,i.visible){const n=i._runPos=t.pickProp(i.options.position,this._vertical?"top":"left"),o=i._runVert="top"===n||"bottom"===n,c=e._group?e._group.itemLabel.options.gap:i._runGap=i.getGap(o?r:l);let u=o?l:i.getWidth(l),d=o?i.getHeight(r):r;const g=o?l:i.getMaxWidth(l),_=o?i.getMaxHeight(r):r,p=this._rLabel=t.createRect(0,0,l,r);s.setStyleOrClass(i._style),i.setText(e.getLabel(i,i.options.animatable?a:e.options.value)),s.text=i.options.text,i.buildSvg(s,null,t.pickNum(u,g),t.pickNum(d,_),e,i._domain);const b=s.getBBox();switch(o?(p.height=t.pickNum(d,b.height),h.height=t.maxv(0,h.height-(p.height+c))):(p.width=t.pickNum(u,b.width),this._wLabel=e._group?e._group._labelWidth:p.width,h.width=t.maxv(0,h.width-(this._wLabel+c))),n){case"top":h.y=p.height+c;break;case"bottom":p.y=h.height+c;break;case"right":p.x=h.width+c;break;default:h.x=this._wLabel+c}}else this._rLabel=null}_renderLabel(e,i,s,a){if(s.visible){const e=this._rLabel,a=s.getBBox();let n=e.x,l=e.y;switch(i._runPos){case"top":case"bottom":n+=e.width/2;break;case"right":n=this.width-e.width,s.anchor=t.TextAnchor.START,l+=t.maxv(0,(e.height-a.height)/2);break;default:s.anchor=t.TextAnchor.END,n+=this._wLabel,l+=t.maxv(0,(e.height-a.height)/2)}s.trans(n,l)}}_renderScale(e){const i=this.model,s=i.label,a=i.scale,n=this.scaleView(),l=this._vertical?e.height:e.width;let r,h;if(a._vertical=this._vertical,a._reversed=i.options.reversed,isNaN(i._runValue)&&a.buildSteps(l,i.options.value),n.setVis(i.scaleVisible())){const i=n.measure(this.doc,a,e.width,e.height,1);this._vertical?(r=0,h=e.y,e.width=t.maxv(0,e.width-i.width),"opposite"===a.options.position?r=e.x+e.width:(s._runVert||(r=e.x),e.x+=i.width)):(r=e.x,e.height=t.maxv(0,e.height-i.height),"opposite"===a.options.position?s._runVert?(h=e.y,e.y+=i.height):(this._rLabel.y=e.y+=i.height,h=e.y-i.height):h=e.y+e.height),n.resizeByMeasured().layout().trans(r,h)}}}class T extends t.ChartElement{constructor(e){super(e,"rct-linear-gauge-band"),this._thick=0,this._gap=0,this._labelGap=3,this._barViews=new t.ElementPool(this,t.RectElement),this.add(this._labelContainer=new t.LayerElement(e,"rct-linear-gauge-band-tick-labels")),this._labels=new t.ElementPool(this._labelContainer,t.TextElement)}_doMeasure(e,i,s,a,n){const l=i.gauge,r=this._vertical=l instanceof C?l.isVertical():l.options.vertical,h="inside"===i.options.position,o=this._thick=h?r?s:a:i.getThickness(r?s:a)+(this._gap=t.pickNum(i.options.gap,0));let c=r?o:s,u=r?a:o;const d=this._ranges=i.getRanges();if(this._labelContainer.setVis(i.tickLabel.visible&&d.length>0)){const e=[d[0].fromValue].concat(d.map(e=>e.toValue));if(this._labelContainer.setStyleOrClass(i.tickLabel._style),this._labels.prepare(d.length+1),r){let i=0;this._labels.forEach((s,a)=>{s.text=String(e[a]),i=t.maxv(s.getBBox().width)}),c+=i+this._labelGap}else{let i=0;this._labels.forEach((s,a)=>{s.text=String(e[a]),i=t.maxv(s.getBBox().height)}),u+=i}}return{width:c,height:u}}_doLayout(e){const t=this.model,i=t.gauge,s=i.scale,a=s._max-s._min;this._labelContainer.setVis(this.$_layoutBars(i,a,this._ranges)&&this._labelContainer.visible&&"inside"!==t.options.position)&&this.$_layoutLabels(i,a,this._ranges)}$_layoutBars(e,t,i){if(this._barViews.prepare(i.length),!this._barViews.isEmpty&&t>0){const e=this._vertical,s="inside"===this.model.options.position,a="opposite"===this.model.options.position,n=this.width,l=this.height,r=e?l:n,h=this._thick;let o=0;return this._barViews.prepare(i.length).forEach((c,u)=>{const d=i[u],g=r*(d.toValue-d.fromValue)/t;if(e){const e=s||a?0:n-h;c.setBounds(e,l-o-g,h,g)}else{const e=a?l-h:0;c.setBounds(o,e,g,this._thick)}c.internalClearStyleAndClass(),c.setFill(d.color),d.style&&c.addStyleOrClass(d.style),o+=g}),!0}}$_layoutLabels(e,i,s){const a="opposite"===this.model.options.position;if(this._vertical){const e=this.height,n=a?t.TextAnchor.START:t.TextAnchor.END,l=a?this._thick+this._labelGap:this.width-this._thick-this._labelGap;let r=this._labels.get(0);r.anchor=n,r.trans(l,e-r.getBBox().height/2);for(let t=1;t<=s.length;t++){const a=e-e*s[t-1].toValue/i;r=this._labels.get(t),r.anchor=n,r.trans(l,a-r.getBBox().height/2)}}else{const e=this.width,t=a?0:this._thick;this._labels.get(0).trans(0,t);for(let a=1;a<=s.length;a++){const n=e*s[a-1].toValue/i;this._labels.get(a).trans(n,t)}}}}class P extends B{constructor(e){super(e,"rct-linear-gauge")}_doInitContents(e,i){i.add(this._background=new t.RectElement(e,"rct-linear-gauge-background")),i.add(this._bandView=new T(e)),i.add(this._scaleView=new G(e)),i.add(this._valueView=new t.RectElement(e,"rct-linear-gauge-value")),i.add(this._labelView=new t.TextElement(e))}_backgroundView(){return this._background}labelView(){return this._labelView}scaleView(){return this._scaleView}background(){return this._background}_prepareGauge(e,t){}_renderScale(e){const t=this.model.band,i=this._bandView;if(super._renderScale(e),i.setVis(t.visible)){const s=+t.options.gap||0,a=i.measure(this.doc,t,e.width,e.height,1);i.resizeByMeasured().layout(),this._vertical?"inside"===t.options.position?i.trans(e.x,e.y):"opposite"===t.options.position?(i.trans(e.x+e.width-a.width,e.y),e.width-=a.width+s):(i.trans(e.x,e.y),e.width-=a.width+s,e.x+=a.width+s):"inside"===t.options.position?i.trans(e.x,e.y):"opposite"===t.options.position?(i.trans(e.x,e.y),e.height-=a.height+s,e.y+=a.height+s):(i.trans(e.x,e.y+e.height-a.height),e.height-=a.height+s)}}_renderBand(e,i,s){const a=this._valueView,n=e.options.reversed,l=e.valueBar,r=e._group?e._group.scale:e.scale;if(a.setVis(!t.isEmptyRect(i)&&l.visible&&!r.isEmpty()&&!isNaN(e.options.value)))if(a.setStyleOrClass(l._style),a.internalSetStyleOrClass(l.getStyle(e,s)),this._vertical){const e=i.height*r.getRate(s),t=n?i.y:i.y+i.height-e;a.setBounds(i.x,t,i.width,e)}else{const e=i.width*r.getRate(s),t=n?i.x+i.width-e:i.x;a.setBounds(t,i.y,e,i.height)}}}class I extends t.GaugeGroupView{constructor(e,t){super(e,t)}_doInitContents(e,i){super._doInitContents(e,i),i.insertFirst(this._scaleView=new G(e)),i.insertFirst(this._textView=new t.TextElement(e,"rct-linear-gauge-group-label"))}_prepareGauge(e,t){this._textView.setVis(t.label.visible)&&this._textView.setStyleOrClass(t.label._style),this._scaleView.setVis(t.scale.visible)&&this._scaleView.setStyleOrClass(t.scale._style),super._prepareGauge(e,t)}_doRenderGauges(e,i,s,a){const n=this.model,l=n.options,r=this._textView,h=t.createRect(0,0,s,a);if(r.visible){r.text=n.label.options.text,n.label.buildSvg(r,null,NaN,NaN,n,null);const e=this._textView.getBBox().height+n.label.getGap(a);h.y+=e,h.height-=e,r.trans(this.width/2,0)}n._labelWidth=n._labelHeight=0,this._gaugeViews.forEach((e,i)=>{const l=e._measureLabelSize(n.get(i),s,a);n._labelWidth=t.maxv(n._labelWidth,l.width),n._labelHeight=t.maxv(n._labelHeight,l.height)});const o=t.copyObj(h),c=n.itemLabel.options.gap;l.vertical?(o.height-=n._labelHeight+c,n.itemLabel.options.opposite||(o.y+=n._labelHeight+c)):(o.width-=n._labelWidth+c,n.itemLabel.options.opposite||(o.x+=n._labelWidth+c)),this._renderScale(n,h,o),l.vertical?this.$_layoutVert(this.doc,n,i,h):this.$_layoutHorz(this.doc,n,i,h)}_renderScale(e,t,i){const s=this._scaleView,a=e.scale,n=e.options.vertical,l=n?t.height:t.width,r=[];let h,o;if(this._gaugeViews.forEach((t,i)=>{r.push(e.get(i).getValue())}),a.buildGroupSteps(l,r),a._vertical=n,s.setVis(a.visible)){const e=s.measure(this.doc,a,i.width,i.height,1);if(n){const s=e.width;i.width-=s,t.width-=s,o=i.y,"opposite"===a.options.position?h=i.x+i.width:(h=i.x,i.x+=s,t.x+=s)}else{const s=e.height;i.height-=s,t.height-=s,h=i.x,"opposite"===a.options.position?(o=i.y,i.y+=s,t.y+=s):o=i.y+i.height}s.resizeByMeasured().layout().trans(h,o)}}$_layoutVert(e,t,i,s){const a=s.height,n=(s.width-t.options.itemGap*(i.count-1))/i.count,l=s.y;let r=s.x;i.forEach((i,s)=>{i.measure(e,t.get(s),n,a,0),i.resize(n,a),i.layout(),i.trans(r,l),r+=n+t.options.itemGap})}$_layoutHorz(e,t,i,s){const a=t.options.itemGap,n=s.width,l=(s.height-a*(i.count-1))/i.count,r=s.x;let h=s.y;i.forEach((i,s)=>{i.measure(e,t.get(s),n,l,0),i.resize(n,l),i.layout(),i.trans(r,h),h+=l+a})}}class N extends I{constructor(e){super(e,"rct-linear-gauge-group")}_doInitContents(e,t){super._doInitContents(e,t),t.insertChild(this._bandView=new T(e),this._scaleView)}_createPool(e){return new t.ElementPool(e,P)}_renderScale(e,t,i){super._renderScale(e,t,i);const s=this._bandView,a=e.band;let n,l;if(s.setVis(a.visible)){const r=+a.options.gap||0,h=s.measure(this.doc,a,i.width,i.height,1);if(e.options.vertical){const e=h.width+r;i.width-=e,t.width-=e,l=i.y,"opposite"===a.options.position?n=i.x+i.width+r:(n=i.x,i.x+=e,t.x+=e)}else{const e=h.height+r;i.height-=e,t.height-=e,n=i.x,"opposite"===a.options.position?(l=i.y,i.y+=e,t.y+=e):l=i.y+i.height+r}s.resizeByMeasured().layout().trans(n,l)}}}class O extends t.GaugeLabel{getText(e){return this._getText(null,e,t.absv(e)>1e3,!0)}}O.defaults=t.extend(t.GaugeLabel.defaults,{visible:!1,position:"outside",offset:4});class D extends t.GaugeLabel{getText(e){return this._getText(null,e,t.absv(e)>1e3,!0)}}D.defaults=t.extend(t.GaugeLabel.defaults,{visible:!1,offset:4});class A extends t.ChartItem{constructor(e){super(e.chart),this.gauge=e}get toValueLabel(){return this._toValueLabel}_doInit(e){super._doInit(e),e.toValueLabel=(this._toValueLabel=new D(this.chart)).init()}getRanges(){var e;return null===(e=this.$_internalRanges())||void 0===e?void 0:e.slice(0)}_doApply(e){const t=this;var i;super._doApply(e),(i=e.ranges)!==t._ranges&&(t._ranges=i,t._runRanges=null)}$_internalRanges(){if(!this._runRanges){const e=this.gauge.options;this._runRanges=t.buildValueRanges(this._ranges,e.minValue,e.maxValue,this._op.rangeInclusive)}return this._runRanges}}A.defaults=t.extend(t.ChartItem.defaults,{vertical:!0,rangeInclusive:!0});class H extends t.GaugeItem{get label(){return this._label}_doInit(e){super._doInit(e),e.label=(this._label=new O(this.chart)).init()}}H.defaults=t.extend(t.ChartItem.defaults,{visible:!0});class M extends k{get label(){return this._label}_doInit(e){super._doInit(e),e.label=(this._label=new O(this.chart)).init()}}class $ extends f{_doInit(e){super._doInit(e),e.band=(this._band=new A(this)).init(),e.targetBar=(this._targetBar=new H(this)).init(),e.valueBar=(this._valueBar=new M(this)).init()}get band(){return this._band}get targetBar(){return this._targetBar}get valueBar(){return this._valueBar}getRanges(e,i,s){return t.buildValueRanges(this._op.ranges,e,i,t.pickProp(s,this._op.rangeInclusive))}getParam(e){return"targetValue"===e?this._op.targetValue:super.getParam(e)}}$.type=t.BulletGaugeType,$.defaults=t.extend(f.defaults,{rangeInclusive:!0});class z extends R{getRanges(e,i,s){return t.buildValueRanges(this._op.ranges,e,i,t.pickProp(s,this._op.rangeInclusive))}_gaugesType(){return"bullet"}}z.type=t.BulletGaugeGroupType,z.gaugeType=t.BulletGaugeType,z.defaults=t.extend(R.defaults,{rangeInclusive:!0});class F extends B{constructor(e){super(e,"rct-bullet-gauge")}_doInitContents(e,i){i.add(this._background=new t.RectElement(e,"rct-bullet-gauge-background")),i.add(this._barContainer=new t.LayerElement(e,void 0)),this._barViews=new t.ElementPool(this._barContainer,t.RectElement),i.add(this._valueView=new t.RectElement(e,"rct-bullet-gauge-value")),i.add(this._targetView=new t.RectElement(e,"rct-bullet-gauge-target")),i.add(this._scaleView=new G(e)),i.add(this._labelView=new t.TextElement(e)),i.add(this._valueLabelView=new t.TextElement(e,"rct-bullet-gauge-value-label")),i.add(this._targetLabelView=new t.TextElement(e,"rct-bullet-gauge-target-label")),this._bandLabelViews=new t.ElementPool(i,t.TextElement)}_backgroundView(){return this._background}labelView(){return this._labelView}scaleView(){return this._scaleView}background(){return this._background}_prepareGauge(e,t){}_renderBand(e,i,s){const a=e.options,n=e._group,l=e.options.reversed,r=this._vertical,h=n?n.scale:e.scale,o=this._valueView,c=this._targetView;if(this._barContainer.setVis(!t.isEmptyRect(i)&&!h.isEmpty())){const s=e.getRanges(h._min,h._max,!1)||(null==n?void 0:n.getRanges(h._min,h._max,!1));if(s){this._barContainer.setRect(i),this._barViews.prepare(s.length),r?this._barViews.forEach((e,t)=>{const a=s[t],n=i.height*h.getRate(a.toValue-a.fromValue),r=i.height*h.getRate(a.fromValue);e.setBounds(0,l?r:i.height-r-n,i.width,n),e.internalClearStyleAndClass(),e.setFill(a.color),a.style&&e.addStyleOrClass(a.style)}):this._barViews.forEach((e,t)=>{const a=s[t],n=i.width*h.getRate(a.toValue-a.fromValue),r=i.width*h.getRate(a.fromValue);e.setBounds(l?i.width-n-r:r,0,n,i.height),e.internalClearStyleAndClass(),e.setFill(a.color),a.style&&e.addStyleOrClass(a.style)});const a=e.band.toValueLabel;if(a.visible){const e=t.pickNum(a.options.offset,4);this._bandLabelViews.prepare(s.length,e=>{e.internalClearStyleAndClass(),e.setStyleOrClass(a._style)}),this._bandLabelViews.forEach((t,n)=>{const o=s[n].toValue;t.text=a.getText(o);const c=t.getBBox();if(r){const s=l?i.y+i.height*h.getRate(o):i.y+i.height*(1-h.getRate(o)),a=c.width/2;t.trans(i.x+i.width+e+a,s-c.height/2)}else{const s=l?i.x+i.width*(1-h.getRate(o)):i.x+i.width*h.getRate(o);t.trans(s-c.width/2,i.y-e-c.height)}})}else this._bandLabelViews.prepare(0)}}if(o.setVis(e.valueBar.visible&&!h.isEmpty()&&!isNaN(s)))if(o.setStyleOrClass(e.valueBar._style),s<a.targetValue&&e.valueBar.options.belowStyle&&o.internalSetStyleOrClass(e.valueBar.options.belowStyle),o.internalSetStyleOrClass(e.valueBar.getStyle(e,s)),r){const e=i.height*h.getRate(s),t=l?i.y:i.y+i.height-e;o.setBounds(i.x+i.width/3,t,i.width/3,e)}else{const e=i.width*h.getRate(s),t=l?i.x+i.width-e:i.x;o.setBounds(t,i.y+i.height/3,e,i.height/3)}const u=e.valueBar.label;if(this._valueLabelView.setVis(u.visible&&o.visible)){const e=u.options.position||"outside",a=t.pickNum(u.options.offset,4);this._valueLabelView.setStyleOrClass(u._style),this._valueLabelView.text=u.getText(s);const n=this._valueLabelView.getBBox();if(r){const t=i.height*h.getRate(s),r=l?i.y:i.y+i.height-t,o=l?r+t:r;if("inside"===e){const e=l?o-n.height-a:o+a;this._valueLabelView.trans(i.x+i.width/2,e)}else{const e=l?o+a:o-a-n.height;this._valueLabelView.trans(i.x+i.width/2,e)}}else{const t=i.width*h.getRate(s),r=l?i.x+i.width-t:i.x,o=l?r:r+t,c=i.y+i.height/2,u=n.width/2;if("inside"===e){const e=l?o+a+u:o-a-u;this._valueLabelView.trans(e,c-n.height/2)}else{const e=l?o-a-u:o+a+u;this._valueLabelView.trans(e,c-n.height/2)}}}if(c.setVis(e.targetBar.visible&&!h.isEmpty()&&!isNaN(a.targetValue)))if(c.setStyleOrClass(e.targetBar._style),r&&i.width>10){let e=i.height*h.getRate(a.targetValue);e=l?i.y+e:i.y+i.height-e,c.setBounds(i.x+5,e-1,i.width-10,3)}else if(!r&&i.height>10){let e=i.width*h.getRate(a.targetValue);e=l?i.x+i.width-e:i.x+e,c.setBounds(e-1,i.y+5,3,i.height-10)}const d=e.targetBar.label;if(this._targetLabelView.setVis(d.visible&&c.visible)){const e=d.options.position||"outside",s=t.pickNum(d.options.offset,4);this._targetLabelView.setStyleOrClass(d._style),this._targetLabelView.text=d.getText(a.targetValue);const n=this._targetLabelView.getBBox();if(r){const t=h.getRate(a.targetValue),r=l?i.y+i.height*t:i.y+i.height*(1-t),o=r-n.height/2,c=n.width/2;if("inside"===e){const e=i.x+i.width/2;l?this._targetLabelView.trans(e,r-s-n.height):this._targetLabelView.trans(e,r+s)}else this._targetLabelView.trans(i.x+i.width+s+c,o)}else{const t=h.getRate(a.targetValue),r=l?i.x+i.width*(1-t):i.x+i.width*t;if("inside"===e){const e=n.width/2,t=i.y+i.height/2,a=l?r+s+e:r-s-e;this._targetLabelView.trans(a,t-n.height/2)}else this._targetLabelView.trans(r,i.y-s-n.height)}}}}class W extends I{constructor(e){super(e,"rct-bullet-gauge-group")}_createPool(e){return new t.ElementPool(e,F)}}class j extends t.GaugeItem{getThickness(e){return t.calcPercent(this._thicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"thickness")}}j.defaults=t.extend(t.ChartItem.defaults,{thickness:7});class Y extends t.GaugeItem{getLength(e){return t.calcPercent(this._lengthDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"length")}}Y.defaults=t.extend(t.ChartItem.defaults,{thickness:7,length:"60%"});class X extends Y{}X.defaults=t.extend(Y.defaults,{thickness:5,length:"85%"});class U extends Y{}U.defaults=t.extend(Y.defaults,{thickness:2,length:"95%",animatable:!1,duration:200});class q extends t.GaugeItem{constructor(e,t){super(e),this.length=t}}class J extends t.GaugeItem{}J.defaults=t.extend(t.ChartItem.defaults,{step:1,offset:1});class K extends t.GaugeItem{constructor(e,t){super(e),this.raidus=t}}class Q extends t.ChartText{constructor(e){super(e.chart)}}Q.defaults=t.extend(t.ChartText.defaults,{text:"RealChart Clock<br>ver1.0",position:"top"});class Z extends t.Gauge{_doInit(e){super._doInit(e),e.rim=(this.rim=new j(this)).init(),e.hourHand=(this.hourHand=new Y(this)).init(),e.minuteHand=(this.minuteHand=new X(this)).init(),e.secondHand=(this.secondHand=new U(this)).init(),e.tick=(this.tick=new q(this,10)).init(),e.minorTick=(this.minorTick=new q(this,5)).init(),e.tickLabel=(this.tickLabel=new J(this)).init(),e.pin=(this.pin=new K(this,5)).init(),e.label=(this.label=new Q(this)).init()}getTime(){const e=this._op;return e.time instanceof this.chart.win.Date?e.time:t.isString(e.time)?new Date(e.time):isNaN(e.time)?void 0:new Date(e.time)}getExtents(e,i){const s=t.minv(e,i);return{cx:t.calcPercent(this._centerXDim,e,e/2),cy:t.calcPercent(this._centerYDim,i,i/3),rd:t.calcPercent(this._radiusDim,s,s/2)}}_doApply(e){const i=this;var s,a,n;super._doApply(e),s=e.centerX,a=e.centerY,n=e.radius,(i._centerXDim||s!==i._centerX)&&(i._centerXDim=t.parsePercentSize(t.pickProp(i._centerX=s,t.CircularGauge.DEF_CENTER),!0)),i._centerYDim&&a===i._centerY||(i._centerYDim=t.parsePercentSize(t.pickProp(i._centerY=a,t.CircularGauge.DEF_CENTER),!0)),i._radiusDim&&n===i._radius||(i._radiusDim=t.parsePercentSize(t.pickProp(i._radius=n,t.CircularGauge.DEF_RADIUS),!0))}}Z.type=t.ClockGaugeType,Z.defaults=t.extend(t.Gauge.defaults,{centerX:"50%",centerY:"50%",radius:"40%",active:!0});class ee extends t.RcAnimation{constructor(e){super(),this.view=e}_doUpdate(e){return this.view._secRate=e,this.view.$_renderHands(this.view.model,this.view._exts),!0}}class te extends t.GaugeView{constructor(e){super(e,"rct-clock-gauge"),this._rimThick=0,this._secRate=1}_doInitContents(e,i){i.add(this._faceView=new t.CircleElement(e,"rct-clock-gauge-face")),i.add(this._rimView=new t.SectorElement(e,"rct-clock-gauge-rim")),i.add(this._labelView=new t.TextElement(e,"rct-clock-gauge-label")),this._labelView.layout=t.TextLayout.MIDDLE,i.add(this._tickContainer=new t.LayerElement(e,"rct-clock-gauge-ticks")),i.add(this._tickLabelContainer=new t.LayerElement(e,"rct-clock-gauge-tick-labels")),i.add(this._hourView=new t.PathElement(e,"rct-clock-gauge-hour")),i.add(this._minuteView=new t.PathElement(e,"rct-clock-gauge-minute")),i.add(this._secondView=new t.PathElement(e,"rct-clock-gauge-second")),i.add(this._pinView=new t.CircleElement(e,"rct-clock-gauge-pin")),this._tickViews=new t.ElementPool(this._tickContainer,t.LineElement,"rct-clock-gauge-tick"),this._minorTickViews=new t.ElementPool(this._tickContainer,t.LineElement,"rct-clock-gauge-minor-tick"),this._tickLabelViews=new t.ElementPool(this._tickLabelContainer,t.TextElement,"rct-clock-gauge-tick-label")}_prepareGauge(e,i){this._tickViews.prepare(i.tick.visible?12:0),this._minorTickViews.prepare(i.minorTick.visible?48:0);const s=Math.round(12/t.maxv(1,Math.floor(i.tickLabel.options.step)||1));this._tickLabelViews.prepare(i.tickLabel.visible?s:0,e=>{e.layout=t.TextLayout.MIDDLE})}_renderGauge(e,i){const s=this.model,a=this._exts=s.getExtents(e,i);this._secRate=1,this.$_renderFace(s,a),this.$_renderHands(s,a),s.options.active&&!s.getTime()?this._runner||(this._runner=setInterval(()=>{const e=this._prevSec;this.$_renderHands(this.model,this._exts),t.absv(e-this._prevSec)>=1&&this._secondView.visible&&s.chart.animatable()&&s.secondHand.options.animatable&&this.$_moveSecond(e)},1e3)):this._runner&&(clearInterval(this._runner),this._runner=void 0)}$_renderFace(e,i){const s=this._labelView,a=this._rimView,n=this._minorTickViews,l=this._tickLabelViews,r=this._pinView,{cx:h,cy:o,rd:c}=i,u=this._rimThick=e.rim.getThickness(c);this._faceView.setCircle(h,o,c),a.setVis(e.rim.visible)&&(a.internalSetStyleOrClass(e.rim._style),a.setSector({cx:h,cy:o,rx:c,ry:c,innerRadius:1-u/c,start:0,angle:2*Math.PI,clockwise:!0}));const d=c-(a.visible?u:0);let g=d-e.tick.length,_=t.ORG_ANGLE,p=t.PI_2/12;if(this._tickViews.forEach((i,s)=>{i.setLine(h+t.cos(_)*d,o+t.sin(_)*d,h+t.cos(_)*g,o+t.sin(_)*g),i.internalSetStyleOrClass(e.tick._style),_+=p}),!n.isEmpty){let i=0;g=d-e.minorTick.length,_=t.ORG_ANGLE,p=t.PI_2/60,n.forEach(s=>{i%5==0&&(_+=p,i++),s.setLine(h+t.cos(_)*d,o+t.sin(_)*d,h+t.cos(_)*g,o+t.sin(_)*g),s.internalSetStyleOrClass(e.minorTick._style),_+=p,i++})}if(!l.isEmpty){const i=12/l.count,s=t.PI_2/12*i;_=t.ORG_ANGLE,l.get(0).text="12",g=d-(e.tick.length+e.tickLabel.options.offset||0),g-=.5*l.get(0).getBBox().height,l.forEach((a,n,l)=>{a.text=String(0===n?12:n*i),a.trans(h+t.cos(_)*g,o+t.sin(_)*g),a.internalSetStyleOrClass(e.tickLabel._style),_+=s})}r.setVis(e.pin.visible)&&(r.setCircle(h,o,e.pin.raidus),r.setStyleOrClass(e.pin._style)),s.setVis(e.label.visible)&&(s.internalSetStyleOrClass(e.label._style),e.label.buildSvg(s,null,NaN,NaN,null,null),"bottom"===e.label.options.position?s.trans(h,o+g/2):s.trans(h,o-g/2))}$_getNow(){const e=this.model.options.timezone;let t=this.model.getTime()||new Date;if(!isNaN(e)){const i=t.getMinutes()+(t.getTimezoneOffset()+e);t.setMinutes(i)}return t}$_renderHands(e,i){const s=this.$_getNow(),a=s.getHours(),n=s.getMinutes(),l=s.getSeconds(),{cx:r,cy:h,rd:o}=i,c=new t.PathBuilder;let u,d,g,_;u=e.hourHand,d=this._hourView,d.setVis(u.visible)&&(_=t.PI_2*(a/12+n/60/12+l/60/60/12),g=u.getLength(o-this._rimThick),c.rect(-u.options.thickness/2,-g,u.options.thickness,g),d.internalSetStyleOrClass(u._style),d.setPath(c.close(!0)).trans(r,h).rotate(_*t.RAD_DEG)),u=e.minuteHand,d=this._minuteView,d.setVis(u.visible)&&(_=t.PI_2*(n/60+l/60/60),g=u.getLength(o-this._rimThick),c.rect(-u.options.thickness/2,-g,u.options.thickness,g),d.internalSetStyleOrClass(u._style),d.setPath(c.close(!0)).trans(r,h).rotate(_*t.RAD_DEG)),u=e.secondHand,d=this._secondView,d.setVis(u.visible)&&(_=this._secRate<1?t.PI_2*(this._aniSec+this._secRate)/60:t.PI_2*l/60,g=u.getLength(o-this._rimThick),c.rect(-u.options.thickness/2,-g,u.options.thickness,g),d.internalSetStyleOrClass(u._style),d.setPath(c.close(!0)).trans(r,h).rotate(_*t.RAD_DEG),this._prevSec=l)}$_moveSecond(e){if(!isNaN(e)){this._aniSec=e;const t=new ee(this);t.duration=this.model.secondHand.options.duration||200,t.start()}}}function ie(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Gauge.register($,u,Z,C),e.GaugeGroup.register(z,d,L),e.GaugeView.register([u,x],[C,P],[$,F],[Z,te],[d,y],[L,N],[z,W]))}ie(s),e.BulletGauge=$,e.CircleGauge=u,e.ClockGauge=Z,e.LinearGauge=C,e.default=ie,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
7
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RealChartGauge={},e.RealChart)}(this,function(e,t){"use strict";function s(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}}),t.default=e,Object.freeze(t)}var i=s(t);class a extends t.GaugeItem{constructor(e){super(e),this.gauge=e}getRanges(e){if(!e){const t=this.gauge.calcedMinMax();e={minValue:t.min,maxValue:t.max}}let s=e.minValue,i=e.maxValue;if(!(i>s)&&(i=t.maxv(s,t.pickNum(this.gauge.prop("value"),s)),this._ranges))for(let e=0;e<this._ranges.length;e++){const s=t.pickNum(this._ranges[e].toValue,NaN);isNaN(s)||(i=t.maxv(i,s))}return t.buildValueRanges(this._ranges,s,i,!1,!0)||[]}getRange(e,t){const s=this.$_internalRanges(e);if(s)for(let e=0,i=s.length;e<i;e++){const a=s[e];if(t>=a.fromValue&&(t<a.toValue||e===i-1&&t<=a.toValue))return a}}_doApply(e){const t=this;var s;super._doApply(e),(s=e.ranges)!==t._ranges&&(t._ranges=s,t._runRanges=null)}$_internalRanges(e){return this._runRanges||(this._runRanges=t.buildValueRanges(this._ranges,e.minValue,e.maxValue,this.prop("rangeInclusive"))||[]),this._runRanges}}a.defaults=t.extend(t.ChartItem.defaults,{rangeInclusive:!0});class l extends a{getSegmentThickness(e){return t.calcPercent(this._segmentThicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"segmentThickness")}}l.defaults=t.extend(a.defaults,{segmentGap:0});class n extends a{getThickness(e){return t.calcPercent(this._thicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"thickness")}}n.defaults=t.extend(a.defaults,{thickness:"100%",stroked:!1});class r extends t.GaugeItem{}r.defaults=t.extend(t.ChartItem.defaults,{visible:!1});class h extends t.GaugeItem{getExtents(e){return{radius:t.calcPercent(this._radiusDim,e,0),length:t.calcPercent(this._lengthDim,e,0),offset:t.calcPercent(this._offsetDim,e,0)}}_doApply(e){super._doApply(e),this._setDims(e,"radius","length","offset")}}h.defaults=t.extend(t.ChartItem.defaults,{visible:!1,radius:3,length:"100%",offset:0});class o extends t.GaugeItem{getRadius(e){return t.calcPercent(this._radiusDim,e,0)}_doApply(e){super._doApply(e),this._setDim(e,"radius")}}o.defaults=t.extend(t.ChartItem.defaults,{visible:!1,radius:5});class c extends t.GaugeScale{_getStepMultiples(e){return[1,2,2.5,5,10]}}c.defaults=t.extend(t.GaugeScale.defaults,{visible:!1,stepPixels:72});class d extends t.CircularGauge{_doInit(e){super._doInit(e),this._band=this._addChild("band",new t.GaugeRangeBand(this)),this._scale=this._addChild("scale",new c(this)),this._rim=this._addChild("rim",new l(this)),this._valueRim=this._addChild("valueRim",new n(this)),this._hand=this._addChild("hand",new h(this)),this._pin=this._addChild("pin",new o(this))}get band(){return this._band}get scale(){return this._scale}get rim(){return this._rim}get valueRim(){return this._valueRim}get hand(){return this._hand}get pin(){return this._pin}getExtents(e){const s=super.getExtents(e),i=this.scale,a=this.band;let l=s.radius;const n=l-s.inner;if(a.visible)switch(s.bandThick=a.getThickness(n),a.prop("position")){case"inside":s.band=l-(n-s.bandThick)/2;break;case"opposite":s.band=s.inner-a.prop("gap"),s.inner=s.band-s.bandThick;break;default:s.band=l+=s.bandThick+a.prop("gap")}if(s.scaleTick=t.maxv(1,i.tick.num("length")),s.scaleLabel=16,"opposite"===i.prop("position"))s.scale=t.maxv(s.inner-i.prop("gap"),0),s.inner=s.scale-s.scaleTick-s.scaleLabel;else s.scale=l+i.prop("gap");return s}}d.type=t.CircleGaugeType;class u extends t.CircularGaugeGroup{_gaugesType(){return"circle"}}u.type=t.CircleGaugeGroupType,u.gaugeType=t.CircleGaugeType,u.defaults=t.extend(t.CircularGaugeGroup.defaults,{innerRadius:"50%"});class g extends t.ValueGaugeView{}class _ extends t.ScaleView{setExtents(e,t){this._center=e,this._exts=t}_createLine(e,s){return new t.ArcElement(e,s)}_doMeasure(e,t,s,i,a){const l=t._steps.length-(360===t.gauge.prop("sweepAngle")?1:0);return this._line.setVis(t.line.visible)&&this._line.internalSetStyleOrClass(t.line._style),this._tickContainer.setVis(t.tick.visible)&&(this._tickContainer.internalSetStyleOrClass(t.tick._style),this._ticks.prepare(l)),this._labelContainer.setVis(t.label.visible)&&(this._labelContainer.internalSetStyleOrClass(t.label._style),this._labels.prepare(l)),{width:s,height:i}}_doLayout(e){const s=this.model,i=s._steps,a=s.gauge,l="opposite"===s.prop("position")?-1:1,n=a.getProps(),r=this._center.x,h=this._center.y,o=this._exts.scale,c=o+this.model.tick.prop("length")*l,d=n._sweepRad,u=n._startRad,g=a.prop("maxValue")-a.prop("minValue"),_=a.prop("clockwise");let p,b,w,m;if(this._line.visible&&this._line.setArc(r,h,o,u,_?d:-d,_),this._tickContainer.visible&&this._ticks.forEach((e,a,l)=>{const n=s.getRate(i[a])*(_?d:-d)+u;p=r+t.cos(n)*o,b=h+t.sin(n)*o,w=r+t.cos(n)*c,m=h+t.sin(n)*c,e.setLine(p,b,w,m)}),this._labelContainer.visible){this._labels.get(0).setText(String(a.prop("maxValue")));const e=c+.2*this._labels.get(0).getBBox().height*l;this._labels.forEach((n,o)=>{const c=s.getRate(i[o])*(_?d:-d)+u;n.setText(String(t.fixnum(a.prop("minValue")+s.getRate(i[o])*g))),n.setContrast(null).layout("center");const p=n.getBBox();w=r+t.cos(c)*(e+p.width/2*l)-p.width/2,m=h+t.sin(c)*(e+p.height/2*l)-p.height/2,n.trans(w,m)})}}}class p extends t.ChartElement{constructor(e){super(e,"rct-circle-gauge-rim"),this._sectorViews=new t.ElementPool(this,t.SectorElement,"rct-circle-gauge-rim")}setExtents(e,t){this._center=e,this._exts=t}_doLayout(e){const s=this.model,i=s.gauge,a=i.getProps(),l=s.getRanges(),n=this._center.x,r=this._center.y,h=this._exts.radius,o=1-s.getSegmentThickness(this._exts.radiusThick)/h,c=i.prop("clockwise"),d=a._sweepRad;let u=a._startRad;if(0===l.length){const e=this._sectorViews.prepare(1).get(0);return e.internalSetStyleOrClass(s._style),void e.setSector({cx:n,cy:r,rx:h,ry:h,innerRadius:o,start:u,angle:d,clockwise:c})}const g=t.pickNum(s.prop("segmentGap"),0),_=g>0?g/h:0,p=_*(l.length-1),b=t.maxv(0,d-p),w=l.reduce((e,t)=>e+(t.toValue-t.fromValue),0);this._sectorViews.prepare(l.length).forEach((e,t)=>{const s=w>0?(l[t].toValue-l[t].fromValue)/w*b:0;e.setSector({cx:n,cy:r,rx:h,ry:h,innerRadius:o,start:u,angle:s,clockwise:c}),e.internalClearStyleAndClass(),e.setFill(l[t].color),l[t].style&&e.addStyleOrClass(l[t].style),u+=c?s+_:-(s+_)})}}let b=class extends t.ChartElement{constructor(e){super(e,"rct-circle-gauge-band"),this._sectorViews=new t.ElementPool(this,t.SectorElement),this.add(this._labelContainer=new t.LayerElement(e,"rct-circle-gauge-band-tick-labels")),this._labels=new t.ElementPool(this._labelContainer,t.TextElement)}setExtends(e,t){this._center=e,this._exts=t}_doLayout(e){const t=this.model,s=t.gauge,i=s.getProps(),a=this._center.x,l=this._center.y,n=this._exts.band,r=s.prop("clockwise"),h=1-this._exts.bandThick/n,o=t.getRanges(),c=i._sweepRad;let d=i._startRad;const u=o.reduce((e,t)=>e+(t.toValue-t.fromValue),0);this._sectorViews.prepare(o.length).forEach((e,t)=>{const s=u>0?(o[t].toValue-o[t].fromValue)/u*c:0;e.setSector({cx:a,cy:l,rx:n,ry:n,innerRadius:h,start:d,angle:s,clockwise:r}),e.internalClearStyleAndClass(),e.setFill(o[t].color),o[t].style&&e.addStyleOrClass(o[t].style),d+=r?s:-s})}};class w extends t.PathElement{render(e,s){const i=e.getRadius(s);return i!==this._radius&&(this._radius=i,this.setPath((new t.PathBuilder).circle(0,0,i).end())),this.internalSetStyleOrClass(e._style),this}}class m extends t.PathElement{render(e,s){const i=e.getExtents(s);if(i.radius!==this._radius||i.length!==this._length||i.offset!==this._offset){const e=this._radius=i.radius,s=this._offset=i.offset;if(this._length=i.length,this._radius>0&&this._length>0){const i=new t.PathBuilder;i.move(-e,s).line(0,-this._length+s).line(e,s),this.setPath(i.end())}else this.setPath("")}return this.internalSetStyleOrClass(e._style),this}}class x extends g{constructor(e){super(e,"rct-circle-gauge")}_doInitContents(e,s){s.add(this._rimView=new p(e)),s.add(this._valueView=new t.SectorElement(e,"rct-circle-gauge-value")),s.add(this._innerView=new t.SectorElement(e,"rct-circle-gauge-inner")),s.add(this._textView=new t.TextElement(e,"rct-circle-gauge-label")),s.add(this._handContainer=new t.LayerElement(e,void 0)),s.add(this._scaleView=new _(e)),s.add(this._bandView=new b(e))}_backgroundView(){return this._rimView}_prepareGauge(e,t){this._rimView.setVis(t.rim.visible),this._scaleView.setVis(t.scale.visible),this._bandView.setVis(t.band.visible),this._valueView.setVis(t.valueRim.visible),t.hand.visible?(this._handView||this._handContainer.add(this._handView=new m(e,"rct-circle-gauge-hand")),this._handView.visible=!0):this._handView&&(this._handView.visible=!1),t.pin.visible?(this._pinView||this._handContainer.add(this._pinView=new w(e,"rct-circle-gauge-pin")),this._pinView.visible=!0):this._pinView&&(this._pinView.visible=!1),this._textView.setVis(t.labelVisible())&&this._textView.setStyleOrClass(t.label._style)}_renderGauge(e,s){const i=this.model,a=i.getCenter(e,s),l=i.getExtents(t.minv(e,s));this.$_renderBackground(i,a,l),this._renderValue()}_renderValue(){const e=this.model,s=e.scale,i=e.getProps(),a=e.getValue(),l=s.getRate(t.pickNum(a,0)),n=this._center,r=this._exts,h=e.valueRim.getThickness(r.radiusThick),o=this._textView;if(this._valueView.visible){const s=e.valueRim,o=e.calcedMinMax(),c=s.getRange({minValue:o.min,maxValue:o.max},a),d=r.value+(s.prop("stroked")?0:h/2),u=this._valueView;u.setStyleOrClass(s._style),c&&(u.setStyle(s.prop("stroked")?"stroke":"fill",c.color),c.style&&u.addStyleOrClass(c.style)),s.prop("stroked")&&(u.setFill("none"),u.setStyle("strokeWidth",t.pixel(h))),u.setBoolData("stroked",s.prop("stroked")),u.setSectorEx({cx:n.x,cy:n.y,rx:d,ry:d,innerRadius:(d-h)/d,start:i._startRad,angle:i._sweepRad*l,clockwise:e.prop("clockwise")},s.prop("stroked"))}if(this._handView){const s=(i._handRad+i._sweepRad*l)*t.RAD_DEG;this._handView.render(e.hand,r.radius).transp(n).rotate(e.prop("clockwise")?s:-s)}if(o.visible){const t=e.label;if(t.setText(e.getLabel(t,t.prop("animatable")?a:e.prop("value"))),o.text=t.prop("text"),o.setBoolData("grouped",!!e._group),t.buildSvg(o,null,NaN,NaN,e,t._domain),e._group)this.$_layoutGroupedLabel(e,o,r);else{const e=o.getBBox(),s=t.getOffset(this.width,this.height);o.trans(n.x+s.x,n.y-e.height/2+s.y)}}}$_renderBackground(e,t,s){const i=e.getProps();this._center=t,this._exts=s,e.scale.buildSteps(s.scale*i._sweepRad,NaN),this._rimView.visible&&(this._rimView.measure(this.doc,e.rim,this.width,this.height,0),this._rimView.setExtents(t,s),this._rimView.layout()),this._scaleView.visible&&(this._scaleView.setStyleOrClass(e.scale._style),this._scaleView.measure(this.doc,e.scale,this.width,this.height,0),this._scaleView.setExtents(t,s),this._scaleView.layout()),this._bandView.visible&&(this._bandView.setStyleOrClass(e.band._style),this._bandView.measure(this.doc,e.band,this.width,this.height,0),this._bandView.setExtends(t,s),this._bandView.layout()),this._innerView.setStyleOrClass(e.prop("innerStyle"));let a=s.inner;const l=getComputedStyle(this._innerView.dom),n=parseFloat(l.strokeWidth);n>1&&(a-=n/2),this._innerView.setSector({cx:t.x,cy:t.y,rx:a,ry:a,innerRadius:0,start:0,angle:2*Math.PI,clockwise:!0}),this._pinView&&this._pinView.render(e.pin,a).trans(t.x,t.y)}$_layoutGroupedLabel(e,s,i){const a=s.getBBox(),l=this._center,n=+e._group.num("labelGap");s.anchor=t.TextAnchor.END,s.trans(l.x-n,l.y-i.radius+(i.radius-i.inner-a.height)/2)}}class y extends t.GaugeGroupView{constructor(e){super(e,"rct-circle-gauge-group")}_createPool(e){return new t.ElementPool(e,x)}_doRenderGauges(e,s,i,a){const l=this.doc,n=this.model,r=n.getProps().getCenter(i,a),h=n.getProps().getExtents(t.minv(i,a));n.setChildExtents(h),i=a=2*h.radius,s.forEach((e,t)=>{e.measure(l,n.getVisible(t),i,a,0),e.resize(i,a),e.layout()}),e.trans(r.x-h.radius,r.y-h.radius)}}class V extends t.GaugeScale{}class v extends t.GaugeLabel{getWidth(e){return t.calcPercent(this._widthDim,e)}getHeight(e){return t.calcPercent(this._heightDim,e)}getMaxWidth(e){return t.calcPercent(this._maxWidthDim,e)}getMaxHeight(e){return t.calcPercent(this._maxHeightDim,e)}getGap(e){return t.calcPercent(this._gapDim,e,0)}_doApply(e){super._doApply(e),this._setDims(e,"width","height","maxWidth","maxHeight","gap")}}v.defaults=t.extend(t.GaugeLabel.defaults,{maxWidth:"30%",maxHeight:"30%",gap:10});class f extends t.ValueGauge{_doInit(e){super._doInit(e),this._scale=this._addChild("scale",new V(this))}get label(){return this._label}get scale(){return this._scale}_createLabel(){return new v(this.chart)}isVertical(){return this._group?this._group.prop("vertical"):this.prop("vertical")}scaleVisible(){return!this._group&&this._scale.visible}calcedMinMax(){return this._scale.range()}_doPrepareRender(e){super._doPrepareRender(e),this._label._prepareRender()}}f.defaults=t.extend(t.ValueGauge.defaults,{reversed:!1});class k extends t.GaugeItem{constructor(){super(...arguments),this._args={gauge:null,value:NaN}}getStyle(e,t){const s=this.prop("styleCallback");if(s){this._args.gauge=e,this._args.value=t;return s(this._args)}}}class C extends f{_doInit(e){super._doInit(e),this._valueBar=this._addChild("valueBar",new k(this)),this._band=this._addChild("band",new t.GaugeRangeBand(this))}get valueBar(){return this._valueBar}get band(){return this._band}}C.type=t.LinearGaugeType;class S extends t.ChartItem{}S.defaults=t.extend(t.ChartItem.defaults,{opposite:!1,gap:10});class E extends v{}E.defaults=t.extend(v.defaults,{gap:10});class R extends t.GaugeGroup{_doInit(e){super._doInit(e),this._label=this._addChild("label",new E(this.chart)),this._itemLabel=this._addChild("itemLabel",new S(this.chart)),this._scale=this._addChild("scale",new V(this))}get label(){return this._label}get itemLabel(){return this._itemLabel}get scale(){return this._scale}calcedMinMax(){return this.scale.range()}}R.defaults=t.extend(t.GaugeGroup.defaults,{vertical:!1,itemGap:10});class L extends R{_doInit(e){super._doInit(e),this._band=this._addChild("band",new t.GaugeRangeBand(this))}get band(){return this._band}_gaugesType(){return"linear"}_doPrepareRender(e){super._doPrepareRender(e),this.band.visible&&this.band._prepareRender()}}L.type=t.LinearGaugeGroupType,L.gaugeType=t.LinearGaugeType;class G extends t.ScaleView{_createLine(e,s){return new t.LineElement(e,s)}_doMeasure(e,s,i,a,l){const n=s.prop("gap"),r=s._reversed,h=s._vertical,o=s.label,c=s.tick,d=s._steps,u=d.length;let g=h?n:i,_=h?a:n;if(this._tickContainer.setVis(c.visible)&&(this._tickContainer.setStyleOrClass(c._style),this._ticks.prepare(u)),h?g+=c.prop("length"):_+=c.prop("length"),this._labelContainer.setVis(o.visible)&&(this._labels.prepare(u,t=>{t.setModel(e,o,null,null)}),u>0))if(h){let e=0;this._labels.forEach((s,i)=>{s.setText(o.getText(d[r?i:u-1-i])),e=t.maxv(s.getBBox().width)}),g+=e}else{let e=0;this._labels.forEach((s,i)=>{s.setText(o.getText(d[r?u-1-i:i])),e=t.maxv(s.getBBox().height)}),_+=e}return{width:g,height:_}}_doLayout(){const e=this.model;e._vertical?this.$_layoutVert(e,this.width,this.height):this.$_layoutHorz(e,this.width,this.height)}$_layoutHorz(e,t,s){const i=e.prop("gap"),a=this._line,l=e.tick,n=e._steps;n.length;const r="opposite"===e.prop("position"),h=r?-l.prop("length"):l.prop("length");let o,c=r?s-i:i;if(a.setVis(e.line.visible)&&(a.setStyleOrClass(e.line._style),a.setHLine(c,0,t)),this._tickContainer.setVis(l.visible)&&this._ticks.forEach((s,i)=>{o=e.getRate(n[i])*t,s.setVLine(o,c,c+h)}),this._labelContainer.visible){const s=this._labelContainer.textAlign()||"center";let i=Number.MIN_SAFE_INTEGER;c=r?0:c+h,this._labels.forEach((a,l)=>{a.layout(s);const r=a.getBBox();o=e.getRate(n[l])*t,a.setVis(o-r.width/2>i)&&(a.trans(o-r.width/2,c),i=o+r.width/2)})}}$_layoutVert(e,t,s){const i=e.prop("gap"),a=this._line,l=e.tick,n=e._steps;this.height,n.length;const r="opposite"===e.prop("position"),h=r?l.prop("length"):-l.prop("length");let o,c=r?i:t-i;if(a.setVis(e.line.visible)&&(a.setStyleOrClass(e.line._style),a.setVLine(c,0,s)),this._tickContainer.setVis(l.visible)&&this._ticks.forEach((t,i)=>{o=e.getRate(n[i])*s,t.setHLine(o,c,c+h)}),this._labelContainer.visible){const a=this._labelContainer.textAlign()||(r?"left":"right");c=r?c+h:t-i+h,this._labels.forEach((t,i)=>{t.layout(a);const l=t.getBBox(),h=r?c:c-l.width;o=e.getRate(n[i])*s,t.trans(h,o-l.height/2)})}}}class B extends t.ValueGaugeView{_measureLabelSize(e,s,i){const a=e.label,l=this.labelView();return a.setText(e.getLabel(a,e.prop("value"))),l.text=a.prop("text"),a.buildSvg(l,null,s,i,e,a._domain),t.rectToSize(l.getBBox())}_renderGauge(e,s){const i=this.model,a=t.pickNum(i._runValue,i.prop("value"));this._measureGauge(i,i.label,this.labelView(),a,i.isVertical(),e,s),this._renderValue()}_renderValue(){const e=this.model,s=e.label,i=e.scale,a=this.labelView(),l=t.pickNum(e._runValue,e.prop("value")),n=t.assignObj({},this._rBand);if(this._renderScale(n),this.background().setRect(n),n.height>0&&this._renderBand(e,n,l),"top"!==s._runPos&&"bottom"!==s._runPos||(this._rLabel.height=n.height),this._renderLabel(e,s,a,l),!this._vertical&&("left"===s._runPos||"right"===s._runPos)&&i.visible&&"opposite"===i.prop("position")){const e=a.getBBox();a.ty+e.height>this.height&&a.transY(t.maxv(0,this.height-e.height))}}_measureGauge(e,s,i,a,l,n,r){const h=this._rBand=t.createRect(0,0,n,r);if(this._vertical=e._group instanceof R?e._group.prop("vertical"):l,s.visible){const l=s._runPos=t.pickProp(s.prop("position"),this._vertical?"top":"left"),o=s._runVert="top"===l||"bottom"===l,c=e._group?e._group.itemLabel.prop("gap"):s._runGap=s.getGap(o?r:n);let d=o?n:s.getWidth(n),u=o?s.getHeight(r):r;const g=o?n:s.getMaxWidth(n),_=o?s.getMaxHeight(r):r,p=this._rLabel=t.createRect(0,0,n,r);i.setStyleOrClass(s._style),s.setText(e.getLabel(s,s.prop("animatable")?a:e.prop("value"))),i.text=s.prop("text"),s.buildSvg(i,null,t.pickNum(d,g),t.pickNum(u,_),e,s._domain);const b=i.getBBox();switch(o?(p.height=t.pickNum(u,b.height),h.height=t.maxv(0,h.height-(p.height+c))):(p.width=t.pickNum(d,b.width),this._wLabel=e._group?e._group._labelWidth:p.width,h.width=t.maxv(0,h.width-(this._wLabel+c))),l){case"top":h.y=p.height+c;break;case"bottom":p.y=h.height+c;break;case"right":p.x=h.width+c;break;default:h.x=this._wLabel+c}}else this._rLabel=null}_renderLabel(e,s,i,a){if(i.visible){const e=this._rLabel,a=i.getBBox();let l=e.x,n=e.y;switch(s._runPos){case"top":case"bottom":l+=e.width/2;break;case"right":l=this.width-e.width,i.anchor=t.TextAnchor.START,n+=t.maxv(0,(e.height-a.height)/2);break;default:i.anchor=t.TextAnchor.END,l+=this._wLabel,n+=t.maxv(0,(e.height-a.height)/2)}i.trans(l,n)}}_renderScale(e){const s=this.model,i=s.label,a=s.scale,l=this.scaleView(),n=this._vertical?e.height:e.width;let r,h;if(a._vertical=this._vertical,a._reversed=s.prop("reversed"),isNaN(s._runValue)&&a.buildSteps(n,s.prop("value")),l.setVis(s.scaleVisible())){const s=l.measure(this.doc,a,e.width,e.height,1);this._vertical?(r=0,h=e.y,e.width=t.maxv(0,e.width-s.width),"opposite"===a.prop("position")?r=e.x+e.width:(i._runVert||(r=e.x),e.x+=s.width)):(r=e.x,e.height=t.maxv(0,e.height-s.height),"opposite"===a.prop("position")?i._runVert?(h=e.y,e.y+=s.height):(this._rLabel.y=e.y+=s.height,h=e.y-s.height):h=e.y+e.height),l.resizeByMeasured().layout().trans(r,h)}}}class T extends t.ChartElement{constructor(e){super(e,"rct-linear-gauge-band"),this._thick=0,this._gap=0,this._labelGap=3,this._barViews=new t.ElementPool(this,t.RectElement),this.add(this._labelContainer=new t.LayerElement(e,"rct-linear-gauge-band-tick-labels")),this._labels=new t.ElementPool(this._labelContainer,t.TextElement)}_doMeasure(e,s,i,a,l){const n=s.gauge,r=this._vertical=n instanceof C?n.isVertical():n.prop("vertical"),h="inside"===s.prop("position"),o=this._thick=h?r?i:a:s.getThickness(r?i:a)+(this._gap=s.num("gap"));let c=r?o:i,d=r?a:o;const u=this._ranges=s.getRanges();if(this._labelContainer.setVis(s.tickLabel.visible&&u.length>0)){const e=[u[0].fromValue].concat(u.map(e=>e.toValue));if(this._labelContainer.setStyleOrClass(s.tickLabel._style),this._labels.prepare(u.length+1),r){let s=0;this._labels.forEach((i,a)=>{i.text=String(e[a]),s=t.maxv(i.getBBox().width)}),c+=s+this._labelGap}else{let s=0;this._labels.forEach((i,a)=>{i.text=String(e[a]),s=t.maxv(i.getBBox().height)}),d+=s}}return{width:c,height:d}}_doLayout(e){const t=this.model,s=t.gauge,i=s.scale,a=i._max-i._min;this._labelContainer.setVis(this.$_layoutBars(s,a,this._ranges)&&this._labelContainer.visible&&"inside"!==t.prop("position"))&&this.$_layoutLabels(s,a,this._ranges)}$_layoutBars(e,t,s){if(this._barViews.prepare(s.length),!this._barViews.isEmpty&&t>0){const e=this._vertical,i="inside"===this.model.prop("position"),a="opposite"===this.model.prop("position"),l=this.width,n=this.height,r=e?n:l,h=this._thick;let o=0;return this._barViews.prepare(s.length).forEach((c,d)=>{const u=s[d],g=r*(u.toValue-u.fromValue)/t;if(e){const e=i||a?0:l-h;c.setBounds(e,n-o-g,h,g)}else{const e=a?n-h:0;c.setBounds(o,e,g,this._thick)}c.internalClearStyleAndClass(),c.setFill(u.color),u.style&&c.addStyleOrClass(u.style),o+=g}),!0}}$_layoutLabels(e,s,i){const a="opposite"===this.model.prop("position");if(this._vertical){const e=this.height,l=a?t.TextAnchor.START:t.TextAnchor.END,n=a?this._thick+this._labelGap:this.width-this._thick-this._labelGap;let r=this._labels.get(0);r.anchor=l,r.trans(n,e-r.getBBox().height/2);for(let t=1;t<=i.length;t++){const a=e-e*i[t-1].toValue/s;r=this._labels.get(t),r.anchor=l,r.trans(n,a-r.getBBox().height/2)}}else{const e=this.width,t=a?0:this._thick;this._labels.get(0).trans(0,t);for(let a=1;a<=i.length;a++){const l=e*i[a-1].toValue/s;this._labels.get(a).trans(l,t)}}}}class P extends B{constructor(e){super(e,"rct-linear-gauge")}_doInitContents(e,s){s.add(this._background=new t.RectElement(e,"rct-linear-gauge-background")),s.add(this._bandView=new T(e)),s.add(this._scaleView=new G(e)),s.add(this._valueView=new t.RectElement(e,"rct-linear-gauge-value")),s.add(this._labelView=new t.TextElement(e))}_backgroundView(){return this._background}labelView(){return this._labelView}scaleView(){return this._scaleView}background(){return this._background}_prepareGauge(e,t){}_renderScale(e){const t=this.model.band,s=this._bandView;if(super._renderScale(e),s.setVis(t.visible)){const i=t.num("gap"),a=s.measure(this.doc,t,e.width,e.height,1);s.resizeByMeasured().layout(),this._vertical?"inside"===t.prop("position")?s.trans(e.x,e.y):"opposite"===t.prop("position")?(s.trans(e.x+e.width-a.width,e.y),e.width-=a.width+i):(s.trans(e.x,e.y),e.width-=a.width+i,e.x+=a.width+i):"inside"===t.prop("position")?s.trans(e.x,e.y):"opposite"===t.prop("position")?(s.trans(e.x,e.y),e.height-=a.height+i,e.y+=a.height+i):(s.trans(e.x,e.y+e.height-a.height),e.height-=a.height+i)}}_renderBand(e,s,i){const a=this._valueView,l=e.prop("reversed"),n=e.valueBar,r=e._group?e._group.scale:e.scale;if(a.setVis(!t.isEmptyRect(s)&&n.visible&&!r.isEmpty()&&!isNaN(e.prop("value"))))if(a.setStyleOrClass(n._style),a.internalSetStyleOrClass(n.getStyle(e,i)),this._vertical){const e=s.height*r.getRate(i),t=l?s.y:s.y+s.height-e;a.setBounds(s.x,t,s.width,e)}else{const e=s.width*r.getRate(i),t=l?s.x+s.width-e:s.x;a.setBounds(t,s.y,e,s.height)}}}class I extends t.GaugeGroupView{constructor(e,t){super(e,t)}_doInitContents(e,s){super._doInitContents(e,s),s.insertFirst(this._scaleView=new G(e)),s.insertFirst(this._textView=new t.TextElement(e,"rct-linear-gauge-group-label"))}_prepareGauge(e,t){this._textView.setVis(t.label.visible)&&this._textView.setStyleOrClass(t.label._style),this._scaleView.setVis(t.scale.visible)&&this._scaleView.setStyleOrClass(t.scale._style),super._prepareGauge(e,t)}_doRenderGauges(e,s,i,a){const l=this.model,n=this._textView,r=t.createRect(0,0,i,a);if(n.visible){n.text=l.label.prop("text"),l.label.buildSvg(n,null,NaN,NaN,l,null);const e=this._textView.getBBox().height+l.label.getGap(a);r.y+=e,r.height-=e,n.trans(this.width/2,0)}l._labelWidth=l._labelHeight=0,this._gaugeViews.forEach((e,s)=>{const n=e._measureLabelSize(l.get(s),i,a);l._labelWidth=t.maxv(l._labelWidth,n.width),l._labelHeight=t.maxv(l._labelHeight,n.height)});const h=t.copyObj(r),o=l.itemLabel.prop("gap");l.prop("vertical")?(h.height-=l._labelHeight+o,l.itemLabel.prop("opposite")||(h.y+=l._labelHeight+o)):(h.width-=l._labelWidth+o,l.itemLabel.prop("opposite")||(h.x+=l._labelWidth+o)),this._renderScale(l,r,h),l.prop("vertical")?this.$_layoutVert(this.doc,l,s,r):this.$_layoutHorz(this.doc,l,s,r)}_renderScale(e,t,s){const i=this._scaleView,a=e.scale,l=e.prop("vertical"),n=l?t.height:t.width,r=[];let h,o;if(this._gaugeViews.forEach((t,s)=>{r.push(e.get(s).getValue())}),a.buildGroupSteps(n,r),a._vertical=l,i.setVis(a.visible)){const e=i.measure(this.doc,a,s.width,s.height,1);if(l){const i=e.width;s.width-=i,t.width-=i,o=s.y,"opposite"===a.prop("position")?h=s.x+s.width:(h=s.x,s.x+=i,t.x+=i)}else{const i=e.height;s.height-=i,t.height-=i,h=s.x,"opposite"===a.prop("position")?(o=s.y,s.y+=i,t.y+=i):o=s.y+s.height}i.resizeByMeasured().layout().trans(h,o)}}$_layoutVert(e,t,s,i){const a=i.height,l=(i.width-t.prop("itemGap")*(s.count-1))/s.count,n=i.y;let r=i.x;s.forEach((s,i)=>{s.measure(e,t.get(i),l,a,0),s.resize(l,a),s.layout(),s.trans(r,n),r+=l+t.prop("itemGap")})}$_layoutHorz(e,t,s,i){const a=t.prop("itemGap"),l=i.width,n=(i.height-a*(s.count-1))/s.count,r=i.x;let h=i.y;s.forEach((s,i)=>{s.measure(e,t.get(i),l,n,0),s.resize(l,n),s.layout(),s.trans(r,h),h+=n+a})}}class N extends I{constructor(e){super(e,"rct-linear-gauge-group")}_doInitContents(e,t){super._doInitContents(e,t),t.insertChild(this._bandView=new T(e),this._scaleView)}_createPool(e){return new t.ElementPool(e,P)}_renderScale(e,t,s){super._renderScale(e,t,s);const i=this._bandView,a=e.band;let l,n;if(i.setVis(a.visible)){const r=a.num("gap"),h=i.measure(this.doc,a,s.width,s.height,1);if(e.prop("vertical")){const e=h.width+r;s.width-=e,t.width-=e,n=s.y,"opposite"===a.prop("position")?l=s.x+s.width+r:(l=s.x,s.x+=e,t.x+=e)}else{const e=h.height+r;s.height-=e,t.height-=e,l=s.x,"opposite"===a.prop("position")?(n=s.y,s.y+=e,t.y+=e):n=s.y+s.height+r}i.resizeByMeasured().layout().trans(l,n)}}}class O extends t.GaugeLabel{getText(e){return this._getText(null,e,t.absv(e)>1e3,!0)}}O.defaults=t.extend(t.GaugeLabel.defaults,{visible:!1,position:"outside",offset:4});class D extends t.GaugeLabel{getText(e){return this._getText(null,e,t.absv(e)>1e3,!0)}}D.defaults=t.extend(t.GaugeLabel.defaults,{visible:!1,offset:4});class A extends t.ChartItem{constructor(e){super(e.chart),this.gauge=e}get toValueLabel(){return this._toValueLabel}_doInit(e){super._doInit(e),this._toValueLabel=this._addChild("toValueLabel",new D(this.chart))}getRanges(){var e;return null===(e=this.$_internalRanges())||void 0===e?void 0:e.slice(0)}_doApply(e){const t=this;var s;super._doApply(e),(s=e.ranges)!==t._ranges&&(t._ranges=s,t._runRanges=null)}$_internalRanges(){if(!this._runRanges){const e=this.gauge;this._runRanges=t.buildValueRanges(this._ranges,e.prop("minValue"),e.prop("maxValue"),this.prop("rangeInclusive"))}return this._runRanges}}A.defaults=t.extend(t.ChartItem.defaults,{vertical:!0,rangeInclusive:!0});class H extends t.GaugeItem{get label(){return this._label}_doInit(e){super._doInit(e),this._label=this._addChild("label",new O(this.chart))}}H.defaults=t.extend(t.ChartItem.defaults,{visible:!0});class M extends k{get label(){return this._label}_doInit(e){super._doInit(e),this._label=this._addChild("label",new O(this.chart))}}class $ extends f{_doInit(e){super._doInit(e),this._band=this._addChild("band",new A(this)),this._targetBar=this._addChild("targetBar",new H(this)),this._valueBar=this._addChild("valueBar",new M(this))}get band(){return this._band}get targetBar(){return this._targetBar}get valueBar(){return this._valueBar}getRanges(e,s,i){return t.buildValueRanges(this.prop("ranges"),e,s,t.pickProp(i,this.prop("rangeInclusive")))}getParam(e){return"targetValue"===e?this.prop("targetValue"):super.getParam(e)}}$.type=t.BulletGaugeType,$.defaults=t.extend(f.defaults,{rangeInclusive:!0});class z extends R{getRanges(e,s,i){return t.buildValueRanges(this.prop("ranges"),e,s,t.pickProp(i,this.prop("rangeInclusive")))}_gaugesType(){return"bullet"}}z.type=t.BulletGaugeGroupType,z.gaugeType=t.BulletGaugeType,z.defaults=t.extend(R.defaults,{rangeInclusive:!0});class F extends B{constructor(e){super(e,"rct-bullet-gauge")}_doInitContents(e,s){s.add(this._background=new t.RectElement(e,"rct-bullet-gauge-background")),s.add(this._barContainer=new t.LayerElement(e,void 0)),this._barViews=new t.ElementPool(this._barContainer,t.RectElement),s.add(this._valueView=new t.RectElement(e,"rct-bullet-gauge-value")),s.add(this._targetView=new t.RectElement(e,"rct-bullet-gauge-target")),s.add(this._scaleView=new G(e)),s.add(this._labelView=new t.TextElement(e)),s.add(this._valueLabelView=new t.TextElement(e,"rct-bullet-gauge-value-label")),s.add(this._targetLabelView=new t.TextElement(e,"rct-bullet-gauge-target-label")),this._bandLabelViews=new t.ElementPool(s,t.TextElement)}_backgroundView(){return this._background}labelView(){return this._labelView}scaleView(){return this._scaleView}background(){return this._background}_prepareGauge(e,t){}_renderBand(e,s,i){const a=e.prop("targetValue"),l=e._group,n=e.prop("reversed"),r=this._vertical,h=l?l.scale:e.scale,o=this._valueView,c=this._targetView;if(this._barContainer.setVis(!t.isEmptyRect(s)&&!h.isEmpty())){const t=e.getRanges(h._min,h._max,!1)||(null==l?void 0:l.getRanges(h._min,h._max,!1));if(t){this._barContainer.setRect(s),this._barViews.prepare(t.length),r?this._barViews.forEach((e,i)=>{const a=t[i],l=s.height*h.getRate(a.toValue-a.fromValue),r=s.height*h.getRate(a.fromValue);e.setBounds(0,n?r:s.height-r-l,s.width,l),e.internalClearStyleAndClass(),e.setFill(a.color),a.style&&e.addStyleOrClass(a.style)}):this._barViews.forEach((e,i)=>{const a=t[i],l=s.width*h.getRate(a.toValue-a.fromValue),r=s.width*h.getRate(a.fromValue);e.setBounds(n?s.width-l-r:r,0,l,s.height),e.internalClearStyleAndClass(),e.setFill(a.color),a.style&&e.addStyleOrClass(a.style)});const i=e.band.toValueLabel;if(i.visible){const e=i.num("offset");this._bandLabelViews.prepare(t.length,e=>{e.internalClearStyleAndClass(),e.setStyleOrClass(i._style)}),this._bandLabelViews.forEach((a,l)=>{const o=t[l].toValue;a.text=i.getText(o);const c=a.getBBox();if(r){const t=n?s.y+s.height*h.getRate(o):s.y+s.height*(1-h.getRate(o)),i=c.width/2;a.trans(s.x+s.width+e+i,t-c.height/2)}else{const t=n?s.x+s.width*(1-h.getRate(o)):s.x+s.width*h.getRate(o);a.trans(t-c.width/2,s.y-e-c.height)}})}else this._bandLabelViews.prepare(0)}}if(o.setVis(e.valueBar.visible&&!h.isEmpty()&&!isNaN(i)))if(o.setStyleOrClass(e.valueBar._style),i<a&&e.valueBar.prop("belowStyle")&&o.internalSetStyleOrClass(e.valueBar.prop("belowStyle")),o.internalSetStyleOrClass(e.valueBar.getStyle(e,i)),r){const e=s.height*h.getRate(i),t=n?s.y:s.y+s.height-e;o.setBounds(s.x+s.width/3,t,s.width/3,e)}else{const e=s.width*h.getRate(i),t=n?s.x+s.width-e:s.x;o.setBounds(t,s.y+s.height/3,e,s.height/3)}const d=e.valueBar.label;if(this._valueLabelView.setVis(d.visible&&o.visible)){const e=d.prop("position")||"outside",t=d.num("offset");this._valueLabelView.setStyleOrClass(d._style),this._valueLabelView.text=d.getText(i);const a=this._valueLabelView.getBBox();if(r){const l=s.height*h.getRate(i),r=n?s.y:s.y+s.height-l,o=n?r+l:r;if("inside"===e){const e=n?o-a.height-t:o+t;this._valueLabelView.trans(s.x+s.width/2,e)}else{const e=n?o+t:o-t-a.height;this._valueLabelView.trans(s.x+s.width/2,e)}}else{const l=s.width*h.getRate(i),r=n?s.x+s.width-l:s.x,o=n?r:r+l,c=s.y+s.height/2,d=a.width/2;if("inside"===e){const e=n?o+t+d:o-t-d;this._valueLabelView.trans(e,c-a.height/2)}else{const e=n?o-t-d:o+t+d;this._valueLabelView.trans(e,c-a.height/2)}}}if(c.setVis(e.targetBar.visible&&!h.isEmpty()&&!isNaN(a)))if(c.setStyleOrClass(e.targetBar._style),r&&s.width>10){let e=s.height*h.getRate(a);e=n?s.y+e:s.y+s.height-e,c.setBounds(s.x+5,e-1,s.width-10,3)}else if(!r&&s.height>10){let e=s.width*h.getRate(a);e=n?s.x+s.width-e:s.x+e,c.setBounds(e-1,s.y+5,3,s.height-10)}const u=e.targetBar.label;if(this._targetLabelView.setVis(u.visible&&c.visible)){const e=u.prop("position")||"outside",t=u.num("offset");this._targetLabelView.setStyleOrClass(u._style),this._targetLabelView.text=u.getText(a);const i=this._targetLabelView.getBBox();if(r){const l=h.getRate(a),r=n?s.y+s.height*l:s.y+s.height*(1-l),o=r-i.height/2,c=i.width/2;if("inside"===e){const e=s.x+s.width/2;n?this._targetLabelView.trans(e,r-t-i.height):this._targetLabelView.trans(e,r+t)}else this._targetLabelView.trans(s.x+s.width+t+c,o)}else{const l=h.getRate(a),r=n?s.x+s.width*(1-l):s.x+s.width*l;if("inside"===e){const e=i.width/2,a=s.y+s.height/2,l=n?r+t+e:r-t-e;this._targetLabelView.trans(l,a-i.height/2)}else this._targetLabelView.trans(r,s.y-t-i.height)}}}}class W extends I{constructor(e){super(e,"rct-bullet-gauge-group")}_createPool(e){return new t.ElementPool(e,F)}}class j extends t.GaugeItem{getThickness(e){return t.calcPercent(this._thicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"thickness")}}j.defaults=t.extend(t.ChartItem.defaults,{thickness:7});class Y extends t.GaugeItem{getLength(e){return t.calcPercent(this._lengthDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"length")}}Y.defaults=t.extend(t.ChartItem.defaults,{thickness:7,length:"60%"});class X extends Y{}X.defaults=t.extend(Y.defaults,{thickness:5,length:"85%"});class U extends Y{}U.defaults=t.extend(Y.defaults,{thickness:2,length:"95%",animatable:!1,duration:200});class q extends t.GaugeItem{constructor(e,t){super(e),this.length=t}}class J extends t.GaugeItem{}J.defaults=t.extend(t.ChartItem.defaults,{step:1,offset:1});class K extends t.GaugeItem{constructor(e,t){super(e),this.raidus=t}}class Q extends t.ChartText{constructor(e){super(e.chart)}}Q.defaults=t.extend(t.ChartText.defaults,{text:"RealChart Clock<br>ver1.0",position:"top"});class Z extends t.Gauge{_doInit(e){super._doInit(e),this.rim=this._addChild("rim",new j(this)),this.hourHand=this._addChild("hourHand",new Y(this)),this.minuteHand=this._addChild("minuteHand",new X(this)),this.secondHand=this._addChild("secondHand",new U(this)),this.tick=this._addChild("tick",new q(this,10)),this.minorTick=this._addChild("minorTick",new q(this,5)),this.tickLabel=this._addChild("tickLabel",new J(this)),this.pin=this._addChild("pin",new K(this,5)),this.label=this._addChild("label",new Q(this))}getTime(){const e=this._op;return e.time instanceof this.chart.win.Date?e.time:t.isString(e.time)?new Date(e.time):isNaN(e.time)?void 0:new Date(e.time)}getExtents(e,s){const i=t.minv(e,s);return{cx:t.calcPercent(this._centerXDim,e,e/2),cy:t.calcPercent(this._centerYDim,s,s/3),rd:t.calcPercent(this._radiusDim,i,i/2)}}_doApply(e){const s=this;var i,a,l;super._doApply(e),i=e.centerX,a=e.centerY,l=e.radius,(s._centerXDim||i!==s._centerX)&&(s._centerXDim=t.parsePercentSize(t.pickProp(s._centerX=i,t.CircularGauge.DEF_CENTER),!0)),s._centerYDim&&a===s._centerY||(s._centerYDim=t.parsePercentSize(t.pickProp(s._centerY=a,t.CircularGauge.DEF_CENTER),!0)),s._radiusDim&&l===s._radius||(s._radiusDim=t.parsePercentSize(t.pickProp(s._radius=l,t.CircularGauge.DEF_RADIUS),!0))}}Z.type=t.ClockGaugeType,Z.defaults=t.extend(t.Gauge.defaults,{centerX:"50%",centerY:"50%",radius:"40%",active:!0});class ee extends t.RcAnimation{constructor(e){super(),this.view=e}_doUpdate(e){return this.view._secRate=e,this.view.$_renderHands(this.view.model,this.view._exts),!0}}class te extends t.GaugeView{constructor(e){super(e,"rct-clock-gauge"),this._rimThick=0,this._secRate=1}_doInitContents(e,s){s.add(this._faceView=new t.CircleElement(e,"rct-clock-gauge-face")),s.add(this._rimView=new t.SectorElement(e,"rct-clock-gauge-rim")),s.add(this._labelView=new t.TextElement(e,"rct-clock-gauge-label")),this._labelView.layout=t.TextLayout.MIDDLE,s.add(this._tickContainer=new t.LayerElement(e,"rct-clock-gauge-ticks")),s.add(this._tickLabelContainer=new t.LayerElement(e,"rct-clock-gauge-tick-labels")),s.add(this._hourView=new t.PathElement(e,"rct-clock-gauge-hour")),s.add(this._minuteView=new t.PathElement(e,"rct-clock-gauge-minute")),s.add(this._secondView=new t.PathElement(e,"rct-clock-gauge-second")),s.add(this._pinView=new t.CircleElement(e,"rct-clock-gauge-pin")),this._tickViews=new t.ElementPool(this._tickContainer,t.LineElement,"rct-clock-gauge-tick"),this._minorTickViews=new t.ElementPool(this._tickContainer,t.LineElement,"rct-clock-gauge-minor-tick"),this._tickLabelViews=new t.ElementPool(this._tickLabelContainer,t.TextElement,"rct-clock-gauge-tick-label")}_prepareGauge(e,s){this._tickViews.prepare(s.tick.visible?12:0),this._minorTickViews.prepare(s.minorTick.visible?48:0);const i=Math.round(12/t.maxv(1,Math.floor(s.tickLabel.prop("step"))||1));this._tickLabelViews.prepare(s.tickLabel.visible?i:0,e=>{e.layout=t.TextLayout.MIDDLE})}_renderGauge(e,s){const i=this.model,a=this._exts=i.getExtents(e,s);this._secRate=1,this.$_renderFace(i,a),this.$_renderHands(i,a),i.prop("active")&&!i.getTime()?this._runner||(this._runner=setInterval(()=>{const e=this._prevSec;this.$_renderHands(this.model,this._exts),t.absv(e-this._prevSec)>=1&&this._secondView.visible&&i.chart.animatable()&&i.secondHand.prop("animatable")&&this.$_moveSecond(e)},1e3)):this._runner&&(clearInterval(this._runner),this._runner=void 0)}$_renderFace(e,s){const i=this._labelView,a=this._rimView,l=this._minorTickViews,n=this._tickLabelViews,r=this._pinView,{cx:h,cy:o,rd:c}=s,d=this._rimThick=e.rim.getThickness(c);this._faceView.setCircle(h,o,c),a.setVis(e.rim.visible)&&(a.internalSetStyleOrClass(e.rim._style),a.setSector({cx:h,cy:o,rx:c,ry:c,innerRadius:1-d/c,start:0,angle:2*Math.PI,clockwise:!0}));const u=c-(a.visible?d:0);let g=u-e.tick.length,_=t.ORG_ANGLE,p=t.PI_2/12;if(this._tickViews.forEach((s,i)=>{s.setLine(h+t.cos(_)*u,o+t.sin(_)*u,h+t.cos(_)*g,o+t.sin(_)*g),s.internalSetStyleOrClass(e.tick._style),_+=p}),!l.isEmpty){let s=0;g=u-e.minorTick.length,_=t.ORG_ANGLE,p=t.PI_2/60,l.forEach(i=>{s%5==0&&(_+=p,s++),i.setLine(h+t.cos(_)*u,o+t.sin(_)*u,h+t.cos(_)*g,o+t.sin(_)*g),i.internalSetStyleOrClass(e.minorTick._style),_+=p,s++})}if(!n.isEmpty){const s=12/n.count,i=t.PI_2/12*s;_=t.ORG_ANGLE,n.get(0).text="12",g=u-(e.tick.length+e.tickLabel.prop("offset")||0),g-=.5*n.get(0).getBBox().height,n.forEach((a,l,n)=>{a.text=String(0===l?12:l*s),a.trans(h+t.cos(_)*g,o+t.sin(_)*g),a.internalSetStyleOrClass(e.tickLabel._style),_+=i})}r.setVis(e.pin.visible)&&(r.setCircle(h,o,e.pin.raidus),r.setStyleOrClass(e.pin._style)),i.setVis(e.label.visible)&&(i.internalSetStyleOrClass(e.label._style),e.label.buildSvg(i,null,NaN,NaN,null,null),"bottom"===e.label.prop("position")?i.trans(h,o+g/2):i.trans(h,o-g/2))}$_getNow(){const e=this.model.prop("timezone");let t=this.model.getTime()||new Date;if(!isNaN(e)){const s=t.getMinutes()+(t.getTimezoneOffset()+e);t.setMinutes(s)}return t}$_renderHands(e,s){const i=this.$_getNow(),a=i.getHours(),l=i.getMinutes(),n=i.getSeconds(),{cx:r,cy:h,rd:o}=s,c=new t.PathBuilder;let d,u,g,_;d=e.hourHand,u=this._hourView,u.setVis(d.visible)&&(_=t.PI_2*(a/12+l/60/12+n/60/60/12),g=d.getLength(o-this._rimThick),c.rect(-d.prop("thickness")/2,-g,d.prop("thickness"),g),u.internalSetStyleOrClass(d._style),u.setPath(c.close(!0)).trans(r,h).rotate(_*t.RAD_DEG)),d=e.minuteHand,u=this._minuteView,u.setVis(d.visible)&&(_=t.PI_2*(l/60+n/60/60),g=d.getLength(o-this._rimThick),c.rect(-d.prop("thickness")/2,-g,d.prop("thickness"),g),u.internalSetStyleOrClass(d._style),u.setPath(c.close(!0)).trans(r,h).rotate(_*t.RAD_DEG)),d=e.secondHand,u=this._secondView,u.setVis(d.visible)&&(_=this._secRate<1?t.PI_2*(this._aniSec+this._secRate)/60:t.PI_2*n/60,g=d.getLength(o-this._rimThick),c.rect(-d.prop("thickness")/2,-g,d.prop("thickness"),g),u.internalSetStyleOrClass(d._style),u.setPath(c.close(!0)).trans(r,h).rotate(_*t.RAD_DEG),this._prevSec=n)}$_moveSecond(e){if(!isNaN(e)){this._aniSec=e;const t=new ee(this);t.duration=this.model.secondHand.prop("duration")||200,t.start()}}}function se(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Gauge.register($,d,Z,C),e.GaugeGroup.register(z,u,L),e.GaugeView.register([d,x],[C,P],[$,F],[Z,te],[u,y],[L,N],[z,W]))}se(i),e.BulletGauge=$,e.CircleGauge=d,e.ClockGauge=Z,e.LinearGauge=C,e.default=se,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/gauge.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* RealChart Gauge v1.4.
|
|
3
|
+
* RealChart Gauge v1.4.32
|
|
4
4
|
* Copyright (C) 2023-2026 WooriTech Inc.
|
|
5
5
|
* All Rights Reserved.
|
|
6
6
|
*/
|
|
7
|
-
import{extend as e,ChartItem as t,GaugeScale as s,CircleGaugeType as i,CircleGaugeGroupType as a,CircularGaugeGroup as n,GaugeItem as l,maxv as r,pickNum as h,buildValueRanges as o,calcPercent as c,CircularGauge as d,GaugeRangeBand as _,SectorElement as g,TextElement as u,LayerElement as p,minv as b,pixel as w,RAD_DEG as V,TextAnchor as y,GaugeGroupView as x,ElementPool as m,ValueGaugeView as f,ScaleView as v,ArcElement as k,cos as S,sin as C,fixnum as R,ChartElement as L,PathElement as B,PathBuilder as T,GaugeLabel as E,ValueGauge as D,LinearGaugeType as I,GaugeGroup as N,LinearGaugeGroupType as O,RectElement as G,isEmptyRect as A,LineElement as H,rectToSize as $,assignObj as M,createRect as P,pickProp as z,copyObj as F,BulletGaugeType as W,BulletGaugeGroupType as Y,absv as X,ChartText as U,ClockGaugeType as j,Gauge as q,isString as J,parsePercentSize as K,GaugeView as Q,CircleElement as Z,TextLayout as ee,ORG_ANGLE as te,PI_2 as se,RcAnimation as ie}from"./index.mjs";class ae extends l{constructor(e){super(e),this.gauge=e}getRanges(e){if(!e){const t=this.gauge.calcedMinMax();e={minValue:t.min,maxValue:t.max}}let t=e.minValue,s=e.maxValue;if(!(s>t)&&(s=r(t,h(this.gauge.options.value,t)),this._ranges))for(let e=0;e<this._ranges.length;e++){const t=h(this._ranges[e].toValue,NaN);isNaN(t)||(s=r(s,t))}return o(this._ranges,t,s,!1,!0)||[]}getRange(e,t){const s=this.$_internalRanges(e);if(s)for(let e=0,i=s.length;e<i;e++){const a=s[e];if(t>=a.fromValue&&(t<a.toValue||e===i-1&&t<=a.toValue))return a}}_doApply(e){const t=this;var s;super._doApply(e),(s=e.ranges)!==t._ranges&&(t._ranges=s,t._runRanges=null)}$_internalRanges(e){return this._runRanges||(this._runRanges=o(this._ranges,e.minValue,e.maxValue,this._op.rangeInclusive)||[]),this._runRanges}}ae.defaults=e(t.defaults,{rangeInclusive:!0});class ne extends ae{getSegmentThickness(e){return c(this._segmentThicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"segmentThickness")}}ne.defaults=e(ae.defaults,{segmentGap:0});class le extends ae{getThickness(e){return c(this._thicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"thickness")}}le.defaults=e(ae.defaults,{thickness:"100%",stroked:!1});(class extends l{}).defaults=e(t.defaults,{visible:!1});class re extends l{getExtents(e){return{radius:c(this._radiusDim,e,0),length:c(this._lengthDim,e,0),offset:c(this._offsetDim,e,0)}}_doApply(e){super._doApply(e),this._setDims(e,"radius","length","offset")}}re.defaults=e(t.defaults,{visible:!1,radius:3,length:"100%",offset:0});class he extends l{getRadius(e){return c(this._radiusDim,e,0)}_doApply(e){super._doApply(e),this._setDim(e,"radius")}}he.defaults=e(t.defaults,{visible:!1,radius:5});class oe extends s{_getStepMultiples(e){return[1,2,2.5,5,10]}}oe.defaults=e(s.defaults,{visible:!1,stepPixels:72});class ce extends d{_doInit(e){super._doInit(e),e.band=(this._band=new _(this)).init(),e.scale=(this._scale=new oe(this)).init(),e.rim=(this._rim=new ne(this)).init(),e.valueRim=(this._valueRim=new le(this)).init(),e.hand=(this._hand=new re(this)).init(),e.pin=(this._pin=new he(this)).init()}get band(){return this._band}get scale(){return this._scale}get rim(){return this._rim}get valueRim(){return this._valueRim}get hand(){return this._hand}get pin(){return this._pin}getExtents(e){const t=super.getExtents(e),s=this.scale,i=this.band;let a=t.radius;const n=a-t.inner;if(i.visible)switch(t.bandThick=i.getThickness(n),i.options.position){case"inside":t.band=a-(n-t.bandThick)/2;break;case"opposite":t.band=t.inner-i.options.gap,t.inner=t.band-t.bandThick;break;default:t.band=a+=t.bandThick+i.options.gap}if(t.scaleTick=r(1,s.tick.options.length||0),t.scaleLabel=16,"opposite"===s.options.position)t.scale=r(t.inner-s.options.gap,0),t.inner=t.scale-t.scaleTick-t.scaleLabel;else t.scale=a+s.options.gap;return t}}ce.type=i;class de extends n{_gaugesType(){return"circle"}}de.type=a,de.gaugeType=i,de.defaults=e(n.defaults,{innerRadius:"50%"});class _e extends f{}class ge extends v{setExtents(e,t){this._center=e,this._exts=t}_createLine(e,t){return new k(e,t)}_doMeasure(e,t,s,i,a){const n=t._steps.length-(360===t.gauge.options.sweepAngle?1:0);return this._line.setVis(t.line.visible)&&this._line.internalSetStyleOrClass(t.line._style),this._tickContainer.setVis(t.tick.visible)&&(this._tickContainer.internalSetStyleOrClass(t.tick._style),this._ticks.prepare(n)),this._labelContainer.setVis(t.label.visible)&&(this._labelContainer.internalSetStyleOrClass(t.label._style),this._labels.prepare(n)),{width:s,height:i}}_doLayout(e){const t=this.model,s=t._steps,i=t.gauge,a=i.options,n="opposite"===t.options.position?-1:1,l=i.getProps(),r=this._center.x,h=this._center.y,o=this._exts.scale,c=o+this.model.tick.options.length*n,d=l._sweepRad,_=l._startRad,g=a.maxValue-a.minValue,u=a.clockwise;let p,b,w,V;if(this._line.visible&&this._line.setArc(r,h,o,_,u?d:-d,u),this._tickContainer.visible&&this._ticks.forEach((e,i,a)=>{const n=t.getRate(s[i])*(u?d:-d)+_;p=r+S(n)*o,b=h+C(n)*o,w=r+S(n)*c,V=h+C(n)*c,e.setLine(p,b,w,V)}),this._labelContainer.visible){this._labels.get(0).setText(String(a.maxValue));const e=c+.2*this._labels.get(0).getBBox().height*n;this._labels.forEach((i,l)=>{const o=t.getRate(s[l])*(u?d:-d)+_;i.setText(String(R(a.minValue+t.getRate(s[l])*g))),i.setContrast(null).layout("center");const c=i.getBBox();w=r+S(o)*(e+c.width/2*n)-c.width/2,V=h+C(o)*(e+c.height/2*n)-c.height/2,i.trans(w,V)})}}}class ue extends L{constructor(e){super(e,"rct-circle-gauge-rim"),this._sectorViews=new m(this,g,"rct-circle-gauge-rim")}setExtents(e,t){this._center=e,this._exts=t}_doLayout(e){const t=this.model,s=t.gauge,i=s.options,a=s.getProps(),n=t.getRanges(),l=this._center.x,o=this._center.y,c=this._exts.radius,d=1-t.getSegmentThickness(this._exts.radiusThick)/c,_=i.clockwise,g=a._sweepRad;let u=a._startRad;if(0===n.length){const e=this._sectorViews.prepare(1).get(0);return e.internalSetStyleOrClass(t._style),void e.setSector({cx:l,cy:o,rx:c,ry:c,innerRadius:d,start:u,angle:g,clockwise:_})}const p=h(t.options.segmentGap,0),b=p>0?p/c:0,w=b*(n.length-1),V=r(0,g-w),y=n.reduce((e,t)=>e+(t.toValue-t.fromValue),0);this._sectorViews.prepare(n.length).forEach((e,t)=>{const s=y>0?(n[t].toValue-n[t].fromValue)/y*V:0;e.setSector({cx:l,cy:o,rx:c,ry:c,innerRadius:d,start:u,angle:s,clockwise:_}),e.internalClearStyleAndClass(),e.setFill(n[t].color),n[t].style&&e.addStyleOrClass(n[t].style),u+=_?s+b:-(s+b)})}}let pe=class extends L{constructor(e){super(e,"rct-circle-gauge-band"),this._sectorViews=new m(this,g),this.add(this._labelContainer=new p(e,"rct-circle-gauge-band-tick-labels")),this._labels=new m(this._labelContainer,u)}setExtends(e,t){this._center=e,this._exts=t}_doLayout(e){const t=this.model,s=t.gauge,i=s.getProps(),a=this._center.x,n=this._center.y,l=this._exts.band,r=s.options.clockwise,h=1-this._exts.bandThick/l,o=t.getRanges(),c=i._sweepRad;let d=i._startRad;const _=o.reduce((e,t)=>e+(t.toValue-t.fromValue),0);this._sectorViews.prepare(o.length).forEach((e,t)=>{const s=_>0?(o[t].toValue-o[t].fromValue)/_*c:0;e.setSector({cx:a,cy:n,rx:l,ry:l,innerRadius:h,start:d,angle:s,clockwise:r}),e.internalClearStyleAndClass(),e.setFill(o[t].color),o[t].style&&e.addStyleOrClass(o[t].style),d+=r?s:-s})}};class be extends B{render(e,t){const s=e.getRadius(t);return s!==this._radius&&(this._radius=s,this.setPath((new T).circle(0,0,s).end())),this.internalSetStyleOrClass(e._style),this}}class we extends B{render(e,t){const s=e.getExtents(t);if(s.radius!==this._radius||s.length!==this._length||s.offset!==this._offset){const e=this._radius=s.radius,t=this._offset=s.offset;if(this._length=s.length,this._radius>0&&this._length>0){const s=new T;s.move(-e,t).line(0,-this._length+t).line(e,t),this.setPath(s.end())}else this.setPath("")}return this.internalSetStyleOrClass(e._style),this}}class Ve extends _e{constructor(e){super(e,"rct-circle-gauge")}_doInitContents(e,t){t.add(this._rimView=new ue(e)),t.add(this._valueView=new g(e,"rct-circle-gauge-value")),t.add(this._innerView=new g(e,"rct-circle-gauge-inner")),t.add(this._textView=new u(e,"rct-circle-gauge-label")),t.add(this._handContainer=new p(e,void 0)),t.add(this._scaleView=new ge(e)),t.add(this._bandView=new pe(e))}_backgroundView(){return this._rimView}_prepareGauge(e,t){this._rimView.setVis(t.rim.visible),this._scaleView.setVis(t.scale.visible),this._bandView.setVis(t.band.visible),this._valueView.setVis(t.valueRim.visible),t.hand.visible?(this._handView||this._handContainer.add(this._handView=new we(e,"rct-circle-gauge-hand")),this._handView.visible=!0):this._handView&&(this._handView.visible=!1),t.pin.visible?(this._pinView||this._handContainer.add(this._pinView=new be(e,"rct-circle-gauge-pin")),this._pinView.visible=!0):this._pinView&&(this._pinView.visible=!1),this._textView.setVis(t.labelVisible())&&this._textView.setStyleOrClass(t.label._style)}_renderGauge(e,t){const s=this.model,i=s.getCenter(e,t),a=s.getExtents(b(e,t));this.$_renderBackground(s,i,a),this._renderValue()}_renderValue(){const e=this.model,t=e.options,s=e.scale,i=e.getProps(),a=e.getValue(),n=s.getRate(h(a,0)),l=this._center,r=this._exts,o=e.valueRim.getThickness(r.radiusThick),c=this._textView;if(this._valueView.visible){const s=e.valueRim,h=s.options,c=s.getRange(t,a),d=r.value+(h.stroked?0:o/2),_=this._valueView;_.setStyleOrClass(s._style),c&&(_.setStyle(h.stroked?"stroke":"fill",c.color),c.style&&_.addStyleOrClass(c.style)),h.stroked&&(_.setFill("none"),_.setStyle("strokeWidth",w(o))),_.setBoolData("stroked",h.stroked),_.setSectorEx({cx:l.x,cy:l.y,rx:d,ry:d,innerRadius:(d-o)/d,start:i._startRad,angle:i._sweepRad*n,clockwise:t.clockwise},h.stroked)}if(this._handView){const t=(i._handRad+i._sweepRad*n)*V;this._handView.render(e.hand,r.radius).transp(l).rotate(e.options.clockwise?t:-t)}if(c.visible){const s=e.label;if(s.setText(e.getLabel(s,s.options.animatable?a:t.value)),c.text=s.options.text,c.setBoolData("grouped",!!e._group),s.buildSvg(c,null,NaN,NaN,e,s._domain),e._group)this.$_layoutGroupedLabel(e,c,r);else{const e=c.getBBox(),t=s.getOffset(this.width,this.height);c.trans(l.x+t.x,l.y-e.height/2+t.y)}}}$_renderBackground(e,t,s){const i=e.getProps();this._center=t,this._exts=s,e.scale.buildSteps(s.scale*i._sweepRad,NaN),this._rimView.visible&&(this._rimView.measure(this.doc,e.rim,this.width,this.height,0),this._rimView.setExtents(t,s),this._rimView.layout()),this._scaleView.visible&&(this._scaleView.setStyleOrClass(e.scale._style),this._scaleView.measure(this.doc,e.scale,this.width,this.height,0),this._scaleView.setExtents(t,s),this._scaleView.layout()),this._bandView.visible&&(this._bandView.setStyleOrClass(e.band._style),this._bandView.measure(this.doc,e.band,this.width,this.height,0),this._bandView.setExtends(t,s),this._bandView.layout()),this._innerView.setStyleOrClass(e.options.innerStyle);let a=s.inner;const n=getComputedStyle(this._innerView.dom),l=parseFloat(n.strokeWidth);l>1&&(a-=l/2),this._innerView.setSector({cx:t.x,cy:t.y,rx:a,ry:a,innerRadius:0,start:0,angle:2*Math.PI,clockwise:!0}),this._pinView&&this._pinView.render(e.pin,a).trans(t.x,t.y)}$_layoutGroupedLabel(e,t,s){const i=t.getBBox(),a=this._center,n=+e._group.options.labelGap||0;t.anchor=y.END,t.trans(a.x-n,a.y-s.radius+(s.radius-s.inner-i.height)/2)}}class ye extends x{constructor(e){super(e,"rct-circle-gauge-group")}_createPool(e){return new m(e,Ve)}_doRenderGauges(e,t,s,i){const a=this.doc,n=this.model,l=n.props.getCenter(s,i),r=n.props.getExtents(b(s,i));n.setChildExtents(r),s=i=2*r.radius,t.forEach((e,t)=>{e.measure(a,n.getVisible(t),s,i,0),e.resize(s,i),e.layout()}),e.trans(l.x-r.radius,l.y-r.radius)}}class xe extends s{}class me extends E{getWidth(e){return c(this._widthDim,e)}getHeight(e){return c(this._heightDim,e)}getMaxWidth(e){return c(this._maxWidthDim,e)}getMaxHeight(e){return c(this._maxHeightDim,e)}getGap(e){return c(this._gapDim,e,0)}_doApply(e){super._doApply(e),this._setDims(e,"width","height","maxWidth","maxHeight","gap")}}me.defaults=e(E.defaults,{maxWidth:"30%",maxHeight:"30%",gap:10});class fe extends D{_doInit(e){super._doInit(e),e.scale=(this._scale=new xe(this)).init()}get label(){return this._label}get scale(){return this._scale}_createLabel(){return new me(this.chart)}isVertical(){return this._group?this._group.options.vertical:this._op.vertical}scaleVisible(){return!this._group&&this._scale.visible}calcedMinMax(){return this._scale.range()}_doPrepareRender(e){super._doPrepareRender(e),this._label._prepareRender()}}fe.defaults=e(D.defaults,{reversed:!1});class ve extends l{constructor(){super(...arguments),this._args={gauge:null,value:NaN}}getStyle(e,t){if(this._op.styleCallback){this._args.gauge=e,this._args.value=t;return this._op.styleCallback(this._args)}}}class ke extends fe{_doInit(e){super._doInit(e),e.valueBar=(this._valueBar=new ve(this)).init(),e.band=(this._band=new _(this)).init()}get valueBar(){return this._valueBar}get band(){return this._band}}ke.type=I;class Se extends t{}Se.defaults=e(t.defaults,{opposite:!1,gap:10});class Ce extends me{}Ce.defaults=e(me.defaults,{gap:10});class Re extends N{_doInit(e){super._doInit(e),e.label=(this._label=new Ce(this.chart)).init(),e.itemLabel=(this._itemLabel=new Se(this.chart)).init(),e.scale=(this._scale=new xe(this)).init()}get label(){return this._label}get itemLabel(){return this._itemLabel}get scale(){return this._scale}calcedMinMax(){return this.scale.range()}}Re.defaults=e(N.defaults,{vertical:!1,itemGap:10});class Le extends Re{_doInit(e){super._doInit(e),e.band=(this._band=new _(this)).init()}get band(){return this._band}_gaugesType(){return"linear"}_doPrepareRender(e){super._doPrepareRender(e),this.band.visible&&this.band._prepareRender()}}Le.type=O,Le.gaugeType=I;class Be extends v{_createLine(e,t){return new H(e,t)}_doMeasure(e,t,s,i,a){const n=t.options,l=t._reversed,h=t._vertical,o=t.label,c=t.tick,d=t._steps,_=d.length;let g=h?n.gap:s,u=h?i:n.gap;if(this._tickContainer.setVis(c.visible)&&(this._tickContainer.setStyleOrClass(c._style),this._ticks.prepare(_)),h?g+=c.options.length:u+=c.options.length,this._labelContainer.setVis(o.visible)&&(this._labels.prepare(_,t=>{t.setModel(e,o,null,null)}),_>0))if(h){let e=0;this._labels.forEach((t,s)=>{t.setText(o.getText(d[l?s:_-1-s])),e=r(t.getBBox().width)}),g+=e}else{let e=0;this._labels.forEach((t,s)=>{t.setText(o.getText(d[l?_-1-s:s])),e=r(t.getBBox().height)}),u+=e}return{width:g,height:u}}_doLayout(){const e=this.model;e._vertical?this.$_layoutVert(e,this.width,this.height):this.$_layoutHorz(e,this.width,this.height)}$_layoutHorz(e,t,s){const i=e.options,a=this._line,n=e.tick,l=e._steps;l.length;const r="opposite"===i.position,h=r?-n.options.length:n.options.length;let o,c=r?s-i.gap:i.gap;if(a.setVis(e.line.visible)&&(a.setStyleOrClass(e.line._style),a.setHLine(c,0,t)),this._tickContainer.setVis(n.visible)&&this._ticks.forEach((s,i)=>{o=e.getRate(l[i])*t,s.setVLine(o,c,c+h)}),this._labelContainer.visible){const s=this._labelContainer.textAlign()||"center";let i=Number.MIN_SAFE_INTEGER;c=r?0:c+h,this._labels.forEach((a,n)=>{a.layout(s);const r=a.getBBox();o=e.getRate(l[n])*t,a.setVis(o-r.width/2>i)&&(a.trans(o-r.width/2,c),i=o+r.width/2)})}}$_layoutVert(e,t,s){const i=e.options,a=this._line,n=e.tick,l=e._steps;this.height,l.length;const r="opposite"===i.position,h=r?n.options.length:-n.options.length;let o,c=r?i.gap:t-i.gap;if(a.setVis(e.line.visible)&&(a.setStyleOrClass(e.line._style),a.setVLine(c,0,s)),this._tickContainer.setVis(n.visible)&&this._ticks.forEach((t,i)=>{o=e.getRate(l[i])*s,t.setHLine(o,c,c+h)}),this._labelContainer.visible){const a=this._labelContainer.textAlign()||(r?"left":"right");c=r?c+h:t-i.gap+h,this._labels.forEach((t,i)=>{t.layout(a);const n=t.getBBox(),h=r?c:c-n.width;o=e.getRate(l[i])*s,t.trans(h,o-n.height/2)})}}}class Te extends f{_measureLabelSize(e,t,s){const i=e.label,a=this.labelView();return i.setText(e.getLabel(i,e.options.value)),a.text=i.options.text,i.buildSvg(a,null,t,s,e,i._domain),$(a.getBBox())}_renderGauge(e,t){const s=this.model,i=h(s._runValue,s.options.value);this._measureGauge(s,s.label,this.labelView(),i,s.isVertical(),e,t),this._renderValue()}_renderValue(){const e=this.model,t=e.label,s=e.scale,i=this.labelView(),a=h(e._runValue,e.options.value),n=M({},this._rBand);if(this._renderScale(n),this.background().setRect(n),n.height>0&&this._renderBand(e,n,a),"top"!==t._runPos&&"bottom"!==t._runPos||(this._rLabel.height=n.height),this._renderLabel(e,t,i,a),!this._vertical&&("left"===t._runPos||"right"===t._runPos)&&s.visible&&"opposite"===s.options.position){const e=i.getBBox();i.ty+e.height>this.height&&i.transY(r(0,this.height-e.height))}}_measureGauge(e,t,s,i,a,n,l){const o=this._rBand=P(0,0,n,l);if(this._vertical=e._group instanceof Re?e._group.options.vertical:a,t.visible){const a=t._runPos=z(t.options.position,this._vertical?"top":"left"),c=t._runVert="top"===a||"bottom"===a,d=e._group?e._group.itemLabel.options.gap:t._runGap=t.getGap(c?l:n);let _=c?n:t.getWidth(n),g=c?t.getHeight(l):l;const u=c?n:t.getMaxWidth(n),p=c?t.getMaxHeight(l):l,b=this._rLabel=P(0,0,n,l);s.setStyleOrClass(t._style),t.setText(e.getLabel(t,t.options.animatable?i:e.options.value)),s.text=t.options.text,t.buildSvg(s,null,h(_,u),h(g,p),e,t._domain);const w=s.getBBox();switch(c?(b.height=h(g,w.height),o.height=r(0,o.height-(b.height+d))):(b.width=h(_,w.width),this._wLabel=e._group?e._group._labelWidth:b.width,o.width=r(0,o.width-(this._wLabel+d))),a){case"top":o.y=b.height+d;break;case"bottom":b.y=o.height+d;break;case"right":b.x=o.width+d;break;default:o.x=this._wLabel+d}}else this._rLabel=null}_renderLabel(e,t,s,i){if(s.visible){const e=this._rLabel,i=s.getBBox();let a=e.x,n=e.y;switch(t._runPos){case"top":case"bottom":a+=e.width/2;break;case"right":a=this.width-e.width,s.anchor=y.START,n+=r(0,(e.height-i.height)/2);break;default:s.anchor=y.END,a+=this._wLabel,n+=r(0,(e.height-i.height)/2)}s.trans(a,n)}}_renderScale(e){const t=this.model,s=t.label,i=t.scale,a=this.scaleView(),n=this._vertical?e.height:e.width;let l,h;if(i._vertical=this._vertical,i._reversed=t.options.reversed,isNaN(t._runValue)&&i.buildSteps(n,t.options.value),a.setVis(t.scaleVisible())){const t=a.measure(this.doc,i,e.width,e.height,1);this._vertical?(l=0,h=e.y,e.width=r(0,e.width-t.width),"opposite"===i.options.position?l=e.x+e.width:(s._runVert||(l=e.x),e.x+=t.width)):(l=e.x,e.height=r(0,e.height-t.height),"opposite"===i.options.position?s._runVert?(h=e.y,e.y+=t.height):(this._rLabel.y=e.y+=t.height,h=e.y-t.height):h=e.y+e.height),a.resizeByMeasured().layout().trans(l,h)}}}class Ee extends L{constructor(e){super(e,"rct-linear-gauge-band"),this._thick=0,this._gap=0,this._labelGap=3,this._barViews=new m(this,G),this.add(this._labelContainer=new p(e,"rct-linear-gauge-band-tick-labels")),this._labels=new m(this._labelContainer,u)}_doMeasure(e,t,s,i,a){const n=t.gauge,l=this._vertical=n instanceof ke?n.isVertical():n.options.vertical,o="inside"===t.options.position,c=this._thick=o?l?s:i:t.getThickness(l?s:i)+(this._gap=h(t.options.gap,0));let d=l?c:s,_=l?i:c;const g=this._ranges=t.getRanges();if(this._labelContainer.setVis(t.tickLabel.visible&&g.length>0)){const e=[g[0].fromValue].concat(g.map(e=>e.toValue));if(this._labelContainer.setStyleOrClass(t.tickLabel._style),this._labels.prepare(g.length+1),l){let t=0;this._labels.forEach((s,i)=>{s.text=String(e[i]),t=r(s.getBBox().width)}),d+=t+this._labelGap}else{let t=0;this._labels.forEach((s,i)=>{s.text=String(e[i]),t=r(s.getBBox().height)}),_+=t}}return{width:d,height:_}}_doLayout(e){const t=this.model,s=t.gauge,i=s.scale,a=i._max-i._min;this._labelContainer.setVis(this.$_layoutBars(s,a,this._ranges)&&this._labelContainer.visible&&"inside"!==t.options.position)&&this.$_layoutLabels(s,a,this._ranges)}$_layoutBars(e,t,s){if(this._barViews.prepare(s.length),!this._barViews.isEmpty&&t>0){const e=this._vertical,i="inside"===this.model.options.position,a="opposite"===this.model.options.position,n=this.width,l=this.height,r=e?l:n,h=this._thick;let o=0;return this._barViews.prepare(s.length).forEach((c,d)=>{const _=s[d],g=r*(_.toValue-_.fromValue)/t;if(e){const e=i||a?0:n-h;c.setBounds(e,l-o-g,h,g)}else{const e=a?l-h:0;c.setBounds(o,e,g,this._thick)}c.internalClearStyleAndClass(),c.setFill(_.color),_.style&&c.addStyleOrClass(_.style),o+=g}),!0}}$_layoutLabels(e,t,s){const i="opposite"===this.model.options.position;if(this._vertical){const e=this.height,a=i?y.START:y.END,n=i?this._thick+this._labelGap:this.width-this._thick-this._labelGap;let l=this._labels.get(0);l.anchor=a,l.trans(n,e-l.getBBox().height/2);for(let i=1;i<=s.length;i++){const r=e-e*s[i-1].toValue/t;l=this._labels.get(i),l.anchor=a,l.trans(n,r-l.getBBox().height/2)}}else{const e=this.width,a=i?0:this._thick;this._labels.get(0).trans(0,a);for(let i=1;i<=s.length;i++){const n=e*s[i-1].toValue/t;this._labels.get(i).trans(n,a)}}}}class De extends Te{constructor(e){super(e,"rct-linear-gauge")}_doInitContents(e,t){t.add(this._background=new G(e,"rct-linear-gauge-background")),t.add(this._bandView=new Ee(e)),t.add(this._scaleView=new Be(e)),t.add(this._valueView=new G(e,"rct-linear-gauge-value")),t.add(this._labelView=new u(e))}_backgroundView(){return this._background}labelView(){return this._labelView}scaleView(){return this._scaleView}background(){return this._background}_prepareGauge(e,t){}_renderScale(e){const t=this.model.band,s=this._bandView;if(super._renderScale(e),s.setVis(t.visible)){const i=+t.options.gap||0,a=s.measure(this.doc,t,e.width,e.height,1);s.resizeByMeasured().layout(),this._vertical?"inside"===t.options.position?s.trans(e.x,e.y):"opposite"===t.options.position?(s.trans(e.x+e.width-a.width,e.y),e.width-=a.width+i):(s.trans(e.x,e.y),e.width-=a.width+i,e.x+=a.width+i):"inside"===t.options.position?s.trans(e.x,e.y):"opposite"===t.options.position?(s.trans(e.x,e.y),e.height-=a.height+i,e.y+=a.height+i):(s.trans(e.x,e.y+e.height-a.height),e.height-=a.height+i)}}_renderBand(e,t,s){const i=this._valueView,a=e.options.reversed,n=e.valueBar,l=e._group?e._group.scale:e.scale;if(i.setVis(!A(t)&&n.visible&&!l.isEmpty()&&!isNaN(e.options.value)))if(i.setStyleOrClass(n._style),i.internalSetStyleOrClass(n.getStyle(e,s)),this._vertical){const e=t.height*l.getRate(s),n=a?t.y:t.y+t.height-e;i.setBounds(t.x,n,t.width,e)}else{const e=t.width*l.getRate(s),n=a?t.x+t.width-e:t.x;i.setBounds(n,t.y,e,t.height)}}}class Ie extends x{constructor(e,t){super(e,t)}_doInitContents(e,t){super._doInitContents(e,t),t.insertFirst(this._scaleView=new Be(e)),t.insertFirst(this._textView=new u(e,"rct-linear-gauge-group-label"))}_prepareGauge(e,t){this._textView.setVis(t.label.visible)&&this._textView.setStyleOrClass(t.label._style),this._scaleView.setVis(t.scale.visible)&&this._scaleView.setStyleOrClass(t.scale._style),super._prepareGauge(e,t)}_doRenderGauges(e,t,s,i){const a=this.model,n=a.options,l=this._textView,h=P(0,0,s,i);if(l.visible){l.text=a.label.options.text,a.label.buildSvg(l,null,NaN,NaN,a,null);const e=this._textView.getBBox().height+a.label.getGap(i);h.y+=e,h.height-=e,l.trans(this.width/2,0)}a._labelWidth=a._labelHeight=0,this._gaugeViews.forEach((e,t)=>{const n=e._measureLabelSize(a.get(t),s,i);a._labelWidth=r(a._labelWidth,n.width),a._labelHeight=r(a._labelHeight,n.height)});const o=F(h),c=a.itemLabel.options.gap;n.vertical?(o.height-=a._labelHeight+c,a.itemLabel.options.opposite||(o.y+=a._labelHeight+c)):(o.width-=a._labelWidth+c,a.itemLabel.options.opposite||(o.x+=a._labelWidth+c)),this._renderScale(a,h,o),n.vertical?this.$_layoutVert(this.doc,a,t,h):this.$_layoutHorz(this.doc,a,t,h)}_renderScale(e,t,s){const i=this._scaleView,a=e.scale,n=e.options.vertical,l=n?t.height:t.width,r=[];let h,o;if(this._gaugeViews.forEach((t,s)=>{r.push(e.get(s).getValue())}),a.buildGroupSteps(l,r),a._vertical=n,i.setVis(a.visible)){const e=i.measure(this.doc,a,s.width,s.height,1);if(n){const i=e.width;s.width-=i,t.width-=i,o=s.y,"opposite"===a.options.position?h=s.x+s.width:(h=s.x,s.x+=i,t.x+=i)}else{const i=e.height;s.height-=i,t.height-=i,h=s.x,"opposite"===a.options.position?(o=s.y,s.y+=i,t.y+=i):o=s.y+s.height}i.resizeByMeasured().layout().trans(h,o)}}$_layoutVert(e,t,s,i){const a=i.height,n=(i.width-t.options.itemGap*(s.count-1))/s.count,l=i.y;let r=i.x;s.forEach((s,i)=>{s.measure(e,t.get(i),n,a,0),s.resize(n,a),s.layout(),s.trans(r,l),r+=n+t.options.itemGap})}$_layoutHorz(e,t,s,i){const a=t.options.itemGap,n=i.width,l=(i.height-a*(s.count-1))/s.count,r=i.x;let h=i.y;s.forEach((s,i)=>{s.measure(e,t.get(i),n,l,0),s.resize(n,l),s.layout(),s.trans(r,h),h+=l+a})}}class Ne extends Ie{constructor(e){super(e,"rct-linear-gauge-group")}_doInitContents(e,t){super._doInitContents(e,t),t.insertChild(this._bandView=new Ee(e),this._scaleView)}_createPool(e){return new m(e,De)}_renderScale(e,t,s){super._renderScale(e,t,s);const i=this._bandView,a=e.band;let n,l;if(i.setVis(a.visible)){const r=+a.options.gap||0,h=i.measure(this.doc,a,s.width,s.height,1);if(e.options.vertical){const e=h.width+r;s.width-=e,t.width-=e,l=s.y,"opposite"===a.options.position?n=s.x+s.width+r:(n=s.x,s.x+=e,t.x+=e)}else{const e=h.height+r;s.height-=e,t.height-=e,n=s.x,"opposite"===a.options.position?(l=s.y,s.y+=e,t.y+=e):l=s.y+s.height+r}i.resizeByMeasured().layout().trans(n,l)}}}class Oe extends E{getText(e){return this._getText(null,e,X(e)>1e3,!0)}}Oe.defaults=e(E.defaults,{visible:!1,position:"outside",offset:4});class Ge extends E{getText(e){return this._getText(null,e,X(e)>1e3,!0)}}Ge.defaults=e(E.defaults,{visible:!1,offset:4});class Ae extends t{constructor(e){super(e.chart),this.gauge=e}get toValueLabel(){return this._toValueLabel}_doInit(e){super._doInit(e),e.toValueLabel=(this._toValueLabel=new Ge(this.chart)).init()}getRanges(){var e;return null===(e=this.$_internalRanges())||void 0===e?void 0:e.slice(0)}_doApply(e){const t=this;var s;super._doApply(e),(s=e.ranges)!==t._ranges&&(t._ranges=s,t._runRanges=null)}$_internalRanges(){if(!this._runRanges){const e=this.gauge.options;this._runRanges=o(this._ranges,e.minValue,e.maxValue,this._op.rangeInclusive)}return this._runRanges}}Ae.defaults=e(t.defaults,{vertical:!0,rangeInclusive:!0});class He extends l{get label(){return this._label}_doInit(e){super._doInit(e),e.label=(this._label=new Oe(this.chart)).init()}}He.defaults=e(t.defaults,{visible:!0});class $e extends ve{get label(){return this._label}_doInit(e){super._doInit(e),e.label=(this._label=new Oe(this.chart)).init()}}class Me extends fe{_doInit(e){super._doInit(e),e.band=(this._band=new Ae(this)).init(),e.targetBar=(this._targetBar=new He(this)).init(),e.valueBar=(this._valueBar=new $e(this)).init()}get band(){return this._band}get targetBar(){return this._targetBar}get valueBar(){return this._valueBar}getRanges(e,t,s){return o(this._op.ranges,e,t,z(s,this._op.rangeInclusive))}getParam(e){return"targetValue"===e?this._op.targetValue:super.getParam(e)}}Me.type=W,Me.defaults=e(fe.defaults,{rangeInclusive:!0});class Pe extends Re{getRanges(e,t,s){return o(this._op.ranges,e,t,z(s,this._op.rangeInclusive))}_gaugesType(){return"bullet"}}Pe.type=Y,Pe.gaugeType=W,Pe.defaults=e(Re.defaults,{rangeInclusive:!0});class ze extends Te{constructor(e){super(e,"rct-bullet-gauge")}_doInitContents(e,t){t.add(this._background=new G(e,"rct-bullet-gauge-background")),t.add(this._barContainer=new p(e,void 0)),this._barViews=new m(this._barContainer,G),t.add(this._valueView=new G(e,"rct-bullet-gauge-value")),t.add(this._targetView=new G(e,"rct-bullet-gauge-target")),t.add(this._scaleView=new Be(e)),t.add(this._labelView=new u(e)),t.add(this._valueLabelView=new u(e,"rct-bullet-gauge-value-label")),t.add(this._targetLabelView=new u(e,"rct-bullet-gauge-target-label")),this._bandLabelViews=new m(t,u)}_backgroundView(){return this._background}labelView(){return this._labelView}scaleView(){return this._scaleView}background(){return this._background}_prepareGauge(e,t){}_renderBand(e,t,s){const i=e.options,a=e._group,n=e.options.reversed,l=this._vertical,r=a?a.scale:e.scale,o=this._valueView,c=this._targetView;if(this._barContainer.setVis(!A(t)&&!r.isEmpty())){const s=e.getRanges(r._min,r._max,!1)||(null==a?void 0:a.getRanges(r._min,r._max,!1));if(s){this._barContainer.setRect(t),this._barViews.prepare(s.length),l?this._barViews.forEach((e,i)=>{const a=s[i],l=t.height*r.getRate(a.toValue-a.fromValue),h=t.height*r.getRate(a.fromValue);e.setBounds(0,n?h:t.height-h-l,t.width,l),e.internalClearStyleAndClass(),e.setFill(a.color),a.style&&e.addStyleOrClass(a.style)}):this._barViews.forEach((e,i)=>{const a=s[i],l=t.width*r.getRate(a.toValue-a.fromValue),h=t.width*r.getRate(a.fromValue);e.setBounds(n?t.width-l-h:h,0,l,t.height),e.internalClearStyleAndClass(),e.setFill(a.color),a.style&&e.addStyleOrClass(a.style)});const i=e.band.toValueLabel;if(i.visible){const e=h(i.options.offset,4);this._bandLabelViews.prepare(s.length,e=>{e.internalClearStyleAndClass(),e.setStyleOrClass(i._style)}),this._bandLabelViews.forEach((a,h)=>{const o=s[h].toValue;a.text=i.getText(o);const c=a.getBBox();if(l){const s=n?t.y+t.height*r.getRate(o):t.y+t.height*(1-r.getRate(o)),i=c.width/2;a.trans(t.x+t.width+e+i,s-c.height/2)}else{const s=n?t.x+t.width*(1-r.getRate(o)):t.x+t.width*r.getRate(o);a.trans(s-c.width/2,t.y-e-c.height)}})}else this._bandLabelViews.prepare(0)}}if(o.setVis(e.valueBar.visible&&!r.isEmpty()&&!isNaN(s)))if(o.setStyleOrClass(e.valueBar._style),s<i.targetValue&&e.valueBar.options.belowStyle&&o.internalSetStyleOrClass(e.valueBar.options.belowStyle),o.internalSetStyleOrClass(e.valueBar.getStyle(e,s)),l){const e=t.height*r.getRate(s),i=n?t.y:t.y+t.height-e;o.setBounds(t.x+t.width/3,i,t.width/3,e)}else{const e=t.width*r.getRate(s),i=n?t.x+t.width-e:t.x;o.setBounds(i,t.y+t.height/3,e,t.height/3)}const d=e.valueBar.label;if(this._valueLabelView.setVis(d.visible&&o.visible)){const e=d.options.position||"outside",i=h(d.options.offset,4);this._valueLabelView.setStyleOrClass(d._style),this._valueLabelView.text=d.getText(s);const a=this._valueLabelView.getBBox();if(l){const l=t.height*r.getRate(s),h=n?t.y:t.y+t.height-l,o=n?h+l:h;if("inside"===e){const e=n?o-a.height-i:o+i;this._valueLabelView.trans(t.x+t.width/2,e)}else{const e=n?o+i:o-i-a.height;this._valueLabelView.trans(t.x+t.width/2,e)}}else{const l=t.width*r.getRate(s),h=n?t.x+t.width-l:t.x,o=n?h:h+l,c=t.y+t.height/2,d=a.width/2;if("inside"===e){const e=n?o+i+d:o-i-d;this._valueLabelView.trans(e,c-a.height/2)}else{const e=n?o-i-d:o+i+d;this._valueLabelView.trans(e,c-a.height/2)}}}if(c.setVis(e.targetBar.visible&&!r.isEmpty()&&!isNaN(i.targetValue)))if(c.setStyleOrClass(e.targetBar._style),l&&t.width>10){let e=t.height*r.getRate(i.targetValue);e=n?t.y+e:t.y+t.height-e,c.setBounds(t.x+5,e-1,t.width-10,3)}else if(!l&&t.height>10){let e=t.width*r.getRate(i.targetValue);e=n?t.x+t.width-e:t.x+e,c.setBounds(e-1,t.y+5,3,t.height-10)}const _=e.targetBar.label;if(this._targetLabelView.setVis(_.visible&&c.visible)){const e=_.options.position||"outside",s=h(_.options.offset,4);this._targetLabelView.setStyleOrClass(_._style),this._targetLabelView.text=_.getText(i.targetValue);const a=this._targetLabelView.getBBox();if(l){const l=r.getRate(i.targetValue),h=n?t.y+t.height*l:t.y+t.height*(1-l),o=h-a.height/2,c=a.width/2;if("inside"===e){const e=t.x+t.width/2;n?this._targetLabelView.trans(e,h-s-a.height):this._targetLabelView.trans(e,h+s)}else this._targetLabelView.trans(t.x+t.width+s+c,o)}else{const l=r.getRate(i.targetValue),h=n?t.x+t.width*(1-l):t.x+t.width*l;if("inside"===e){const e=a.width/2,i=t.y+t.height/2,l=n?h+s+e:h-s-e;this._targetLabelView.trans(l,i-a.height/2)}else this._targetLabelView.trans(h,t.y-s-a.height)}}}}class Fe extends Ie{constructor(e){super(e,"rct-bullet-gauge-group")}_createPool(e){return new m(e,ze)}}class We extends l{getThickness(e){return c(this._thicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"thickness")}}We.defaults=e(t.defaults,{thickness:7});class Ye extends l{getLength(e){return c(this._lengthDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"length")}}Ye.defaults=e(t.defaults,{thickness:7,length:"60%"});class Xe extends Ye{}Xe.defaults=e(Ye.defaults,{thickness:5,length:"85%"});class Ue extends Ye{}Ue.defaults=e(Ye.defaults,{thickness:2,length:"95%",animatable:!1,duration:200});class je extends l{constructor(e,t){super(e),this.length=t}}class qe extends l{}qe.defaults=e(t.defaults,{step:1,offset:1});class Je extends l{constructor(e,t){super(e),this.raidus=t}}class Ke extends U{constructor(e){super(e.chart)}}Ke.defaults=e(U.defaults,{text:"RealChart Clock<br>ver1.0",position:"top"});class Qe extends q{_doInit(e){super._doInit(e),e.rim=(this.rim=new We(this)).init(),e.hourHand=(this.hourHand=new Ye(this)).init(),e.minuteHand=(this.minuteHand=new Xe(this)).init(),e.secondHand=(this.secondHand=new Ue(this)).init(),e.tick=(this.tick=new je(this,10)).init(),e.minorTick=(this.minorTick=new je(this,5)).init(),e.tickLabel=(this.tickLabel=new qe(this)).init(),e.pin=(this.pin=new Je(this,5)).init(),e.label=(this.label=new Ke(this)).init()}getTime(){const e=this._op;return e.time instanceof this.chart.win.Date?e.time:J(e.time)?new Date(e.time):isNaN(e.time)?void 0:new Date(e.time)}getExtents(e,t){const s=b(e,t);return{cx:c(this._centerXDim,e,e/2),cy:c(this._centerYDim,t,t/3),rd:c(this._radiusDim,s,s/2)}}_doApply(e){const t=this;var s,i,a;super._doApply(e),s=e.centerX,i=e.centerY,a=e.radius,(t._centerXDim||s!==t._centerX)&&(t._centerXDim=K(z(t._centerX=s,d.DEF_CENTER),!0)),t._centerYDim&&i===t._centerY||(t._centerYDim=K(z(t._centerY=i,d.DEF_CENTER),!0)),t._radiusDim&&a===t._radius||(t._radiusDim=K(z(t._radius=a,d.DEF_RADIUS),!0))}}Qe.type=j,Qe.defaults=e(q.defaults,{centerX:"50%",centerY:"50%",radius:"40%",active:!0});class Ze extends ie{constructor(e){super(),this.view=e}_doUpdate(e){return this.view._secRate=e,this.view.$_renderHands(this.view.model,this.view._exts),!0}}class et extends Q{constructor(e){super(e,"rct-clock-gauge"),this._rimThick=0,this._secRate=1}_doInitContents(e,t){t.add(this._faceView=new Z(e,"rct-clock-gauge-face")),t.add(this._rimView=new g(e,"rct-clock-gauge-rim")),t.add(this._labelView=new u(e,"rct-clock-gauge-label")),this._labelView.layout=ee.MIDDLE,t.add(this._tickContainer=new p(e,"rct-clock-gauge-ticks")),t.add(this._tickLabelContainer=new p(e,"rct-clock-gauge-tick-labels")),t.add(this._hourView=new B(e,"rct-clock-gauge-hour")),t.add(this._minuteView=new B(e,"rct-clock-gauge-minute")),t.add(this._secondView=new B(e,"rct-clock-gauge-second")),t.add(this._pinView=new Z(e,"rct-clock-gauge-pin")),this._tickViews=new m(this._tickContainer,H,"rct-clock-gauge-tick"),this._minorTickViews=new m(this._tickContainer,H,"rct-clock-gauge-minor-tick"),this._tickLabelViews=new m(this._tickLabelContainer,u,"rct-clock-gauge-tick-label")}_prepareGauge(e,t){this._tickViews.prepare(t.tick.visible?12:0),this._minorTickViews.prepare(t.minorTick.visible?48:0);const s=Math.round(12/r(1,Math.floor(t.tickLabel.options.step)||1));this._tickLabelViews.prepare(t.tickLabel.visible?s:0,e=>{e.layout=ee.MIDDLE})}_renderGauge(e,t){const s=this.model,i=this._exts=s.getExtents(e,t);this._secRate=1,this.$_renderFace(s,i),this.$_renderHands(s,i),s.options.active&&!s.getTime()?this._runner||(this._runner=setInterval(()=>{const e=this._prevSec;this.$_renderHands(this.model,this._exts),X(e-this._prevSec)>=1&&this._secondView.visible&&s.chart.animatable()&&s.secondHand.options.animatable&&this.$_moveSecond(e)},1e3)):this._runner&&(clearInterval(this._runner),this._runner=void 0)}$_renderFace(e,t){const s=this._labelView,i=this._rimView,a=this._minorTickViews,n=this._tickLabelViews,l=this._pinView,{cx:r,cy:h,rd:o}=t,c=this._rimThick=e.rim.getThickness(o);this._faceView.setCircle(r,h,o),i.setVis(e.rim.visible)&&(i.internalSetStyleOrClass(e.rim._style),i.setSector({cx:r,cy:h,rx:o,ry:o,innerRadius:1-c/o,start:0,angle:2*Math.PI,clockwise:!0}));const d=o-(i.visible?c:0);let _=d-e.tick.length,g=te,u=se/12;if(this._tickViews.forEach((t,s)=>{t.setLine(r+S(g)*d,h+C(g)*d,r+S(g)*_,h+C(g)*_),t.internalSetStyleOrClass(e.tick._style),g+=u}),!a.isEmpty){let t=0;_=d-e.minorTick.length,g=te,u=se/60,a.forEach(s=>{t%5==0&&(g+=u,t++),s.setLine(r+S(g)*d,h+C(g)*d,r+S(g)*_,h+C(g)*_),s.internalSetStyleOrClass(e.minorTick._style),g+=u,t++})}if(!n.isEmpty){const t=12/n.count,s=se/12*t;g=te,n.get(0).text="12",_=d-(e.tick.length+e.tickLabel.options.offset||0),_-=.5*n.get(0).getBBox().height,n.forEach((i,a,n)=>{i.text=String(0===a?12:a*t),i.trans(r+S(g)*_,h+C(g)*_),i.internalSetStyleOrClass(e.tickLabel._style),g+=s})}l.setVis(e.pin.visible)&&(l.setCircle(r,h,e.pin.raidus),l.setStyleOrClass(e.pin._style)),s.setVis(e.label.visible)&&(s.internalSetStyleOrClass(e.label._style),e.label.buildSvg(s,null,NaN,NaN,null,null),"bottom"===e.label.options.position?s.trans(r,h+_/2):s.trans(r,h-_/2))}$_getNow(){const e=this.model.options.timezone;let t=this.model.getTime()||new Date;if(!isNaN(e)){const s=t.getMinutes()+(t.getTimezoneOffset()+e);t.setMinutes(s)}return t}$_renderHands(e,t){const s=this.$_getNow(),i=s.getHours(),a=s.getMinutes(),n=s.getSeconds(),{cx:l,cy:r,rd:h}=t,o=new T;let c,d,_,g;c=e.hourHand,d=this._hourView,d.setVis(c.visible)&&(g=se*(i/12+a/60/12+n/60/60/12),_=c.getLength(h-this._rimThick),o.rect(-c.options.thickness/2,-_,c.options.thickness,_),d.internalSetStyleOrClass(c._style),d.setPath(o.close(!0)).trans(l,r).rotate(g*V)),c=e.minuteHand,d=this._minuteView,d.setVis(c.visible)&&(g=se*(a/60+n/60/60),_=c.getLength(h-this._rimThick),o.rect(-c.options.thickness/2,-_,c.options.thickness,_),d.internalSetStyleOrClass(c._style),d.setPath(o.close(!0)).trans(l,r).rotate(g*V)),c=e.secondHand,d=this._secondView,d.setVis(c.visible)&&(g=this._secRate<1?se*(this._aniSec+this._secRate)/60:se*n/60,_=c.getLength(h-this._rimThick),o.rect(-c.options.thickness/2,-_,c.options.thickness,_),d.internalSetStyleOrClass(c._style),d.setPath(o.close(!0)).trans(l,r).rotate(g*V),this._prevSec=n)}$_moveSecond(e){if(!isNaN(e)){this._aniSec=e;const t=new Ze(this);t.duration=this.model.secondHand.options.duration||200,t.start()}}}function tt(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Gauge.register(Me,ce,Qe,ke),e.GaugeGroup.register(Pe,de,Le),e.GaugeView.register([ce,Ve],[ke,De],[Me,ze],[Qe,et],[de,ye],[Le,Ne],[Pe,Fe]))}export{Me as BulletGauge,ce as CircleGauge,Qe as ClockGauge,ke as LinearGauge,tt as default,tt as registerGauge};
|
|
7
|
+
import{extend as e,ChartItem as t,GaugeScale as s,CircleGaugeType as i,CircleGaugeGroupType as a,CircularGaugeGroup as l,GaugeItem as r,maxv as n,pickNum as h,buildValueRanges as o,calcPercent as d,CircularGauge as c,GaugeRangeBand as _,SectorElement as u,TextElement as g,LayerElement as p,minv as b,pixel as w,RAD_DEG as V,TextAnchor as y,GaugeGroupView as x,ElementPool as m,ValueGaugeView as f,ScaleView as v,ArcElement as k,cos as C,sin as S,fixnum as R,ChartElement as L,PathElement as B,PathBuilder as T,GaugeLabel as E,ValueGauge as D,LinearGaugeType as I,GaugeGroup as N,LinearGaugeGroupType as O,RectElement as G,isEmptyRect as A,LineElement as H,rectToSize as M,assignObj as P,createRect as $,pickProp as z,copyObj as F,BulletGaugeType as W,BulletGaugeGroupType as Y,absv as X,ChartText as U,ClockGaugeType as j,Gauge as q,isString as J,parsePercentSize as K,GaugeView as Q,CircleElement as Z,TextLayout as ee,ORG_ANGLE as te,PI_2 as se,RcAnimation as ie}from"./index.mjs";class ae extends r{constructor(e){super(e),this.gauge=e}getRanges(e){if(!e){const t=this.gauge.calcedMinMax();e={minValue:t.min,maxValue:t.max}}let t=e.minValue,s=e.maxValue;if(!(s>t)&&(s=n(t,h(this.gauge.prop("value"),t)),this._ranges))for(let e=0;e<this._ranges.length;e++){const t=h(this._ranges[e].toValue,NaN);isNaN(t)||(s=n(s,t))}return o(this._ranges,t,s,!1,!0)||[]}getRange(e,t){const s=this.$_internalRanges(e);if(s)for(let e=0,i=s.length;e<i;e++){const a=s[e];if(t>=a.fromValue&&(t<a.toValue||e===i-1&&t<=a.toValue))return a}}_doApply(e){const t=this;var s;super._doApply(e),(s=e.ranges)!==t._ranges&&(t._ranges=s,t._runRanges=null)}$_internalRanges(e){return this._runRanges||(this._runRanges=o(this._ranges,e.minValue,e.maxValue,this.prop("rangeInclusive"))||[]),this._runRanges}}ae.defaults=e(t.defaults,{rangeInclusive:!0});class le extends ae{getSegmentThickness(e){return d(this._segmentThicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"segmentThickness")}}le.defaults=e(ae.defaults,{segmentGap:0});class re extends ae{getThickness(e){return d(this._thicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"thickness")}}re.defaults=e(ae.defaults,{thickness:"100%",stroked:!1});(class extends r{}).defaults=e(t.defaults,{visible:!1});class ne extends r{getExtents(e){return{radius:d(this._radiusDim,e,0),length:d(this._lengthDim,e,0),offset:d(this._offsetDim,e,0)}}_doApply(e){super._doApply(e),this._setDims(e,"radius","length","offset")}}ne.defaults=e(t.defaults,{visible:!1,radius:3,length:"100%",offset:0});class he extends r{getRadius(e){return d(this._radiusDim,e,0)}_doApply(e){super._doApply(e),this._setDim(e,"radius")}}he.defaults=e(t.defaults,{visible:!1,radius:5});class oe extends s{_getStepMultiples(e){return[1,2,2.5,5,10]}}oe.defaults=e(s.defaults,{visible:!1,stepPixels:72});class de extends c{_doInit(e){super._doInit(e),this._band=this._addChild("band",new _(this)),this._scale=this._addChild("scale",new oe(this)),this._rim=this._addChild("rim",new le(this)),this._valueRim=this._addChild("valueRim",new re(this)),this._hand=this._addChild("hand",new ne(this)),this._pin=this._addChild("pin",new he(this))}get band(){return this._band}get scale(){return this._scale}get rim(){return this._rim}get valueRim(){return this._valueRim}get hand(){return this._hand}get pin(){return this._pin}getExtents(e){const t=super.getExtents(e),s=this.scale,i=this.band;let a=t.radius;const l=a-t.inner;if(i.visible)switch(t.bandThick=i.getThickness(l),i.prop("position")){case"inside":t.band=a-(l-t.bandThick)/2;break;case"opposite":t.band=t.inner-i.prop("gap"),t.inner=t.band-t.bandThick;break;default:t.band=a+=t.bandThick+i.prop("gap")}if(t.scaleTick=n(1,s.tick.num("length")),t.scaleLabel=16,"opposite"===s.prop("position"))t.scale=n(t.inner-s.prop("gap"),0),t.inner=t.scale-t.scaleTick-t.scaleLabel;else t.scale=a+s.prop("gap");return t}}de.type=i;class ce extends l{_gaugesType(){return"circle"}}ce.type=a,ce.gaugeType=i,ce.defaults=e(l.defaults,{innerRadius:"50%"});class _e extends f{}class ue extends v{setExtents(e,t){this._center=e,this._exts=t}_createLine(e,t){return new k(e,t)}_doMeasure(e,t,s,i,a){const l=t._steps.length-(360===t.gauge.prop("sweepAngle")?1:0);return this._line.setVis(t.line.visible)&&this._line.internalSetStyleOrClass(t.line._style),this._tickContainer.setVis(t.tick.visible)&&(this._tickContainer.internalSetStyleOrClass(t.tick._style),this._ticks.prepare(l)),this._labelContainer.setVis(t.label.visible)&&(this._labelContainer.internalSetStyleOrClass(t.label._style),this._labels.prepare(l)),{width:s,height:i}}_doLayout(e){const t=this.model,s=t._steps,i=t.gauge,a="opposite"===t.prop("position")?-1:1,l=i.getProps(),r=this._center.x,n=this._center.y,h=this._exts.scale,o=h+this.model.tick.prop("length")*a,d=l._sweepRad,c=l._startRad,_=i.prop("maxValue")-i.prop("minValue"),u=i.prop("clockwise");let g,p,b,w;if(this._line.visible&&this._line.setArc(r,n,h,c,u?d:-d,u),this._tickContainer.visible&&this._ticks.forEach((e,i,a)=>{const l=t.getRate(s[i])*(u?d:-d)+c;g=r+C(l)*h,p=n+S(l)*h,b=r+C(l)*o,w=n+S(l)*o,e.setLine(g,p,b,w)}),this._labelContainer.visible){this._labels.get(0).setText(String(i.prop("maxValue")));const e=o+.2*this._labels.get(0).getBBox().height*a;this._labels.forEach((l,h)=>{const o=t.getRate(s[h])*(u?d:-d)+c;l.setText(String(R(i.prop("minValue")+t.getRate(s[h])*_))),l.setContrast(null).layout("center");const g=l.getBBox();b=r+C(o)*(e+g.width/2*a)-g.width/2,w=n+S(o)*(e+g.height/2*a)-g.height/2,l.trans(b,w)})}}}class ge extends L{constructor(e){super(e,"rct-circle-gauge-rim"),this._sectorViews=new m(this,u,"rct-circle-gauge-rim")}setExtents(e,t){this._center=e,this._exts=t}_doLayout(e){const t=this.model,s=t.gauge,i=s.getProps(),a=t.getRanges(),l=this._center.x,r=this._center.y,o=this._exts.radius,d=1-t.getSegmentThickness(this._exts.radiusThick)/o,c=s.prop("clockwise"),_=i._sweepRad;let u=i._startRad;if(0===a.length){const e=this._sectorViews.prepare(1).get(0);return e.internalSetStyleOrClass(t._style),void e.setSector({cx:l,cy:r,rx:o,ry:o,innerRadius:d,start:u,angle:_,clockwise:c})}const g=h(t.prop("segmentGap"),0),p=g>0?g/o:0,b=p*(a.length-1),w=n(0,_-b),V=a.reduce((e,t)=>e+(t.toValue-t.fromValue),0);this._sectorViews.prepare(a.length).forEach((e,t)=>{const s=V>0?(a[t].toValue-a[t].fromValue)/V*w:0;e.setSector({cx:l,cy:r,rx:o,ry:o,innerRadius:d,start:u,angle:s,clockwise:c}),e.internalClearStyleAndClass(),e.setFill(a[t].color),a[t].style&&e.addStyleOrClass(a[t].style),u+=c?s+p:-(s+p)})}}let pe=class extends L{constructor(e){super(e,"rct-circle-gauge-band"),this._sectorViews=new m(this,u),this.add(this._labelContainer=new p(e,"rct-circle-gauge-band-tick-labels")),this._labels=new m(this._labelContainer,g)}setExtends(e,t){this._center=e,this._exts=t}_doLayout(e){const t=this.model,s=t.gauge,i=s.getProps(),a=this._center.x,l=this._center.y,r=this._exts.band,n=s.prop("clockwise"),h=1-this._exts.bandThick/r,o=t.getRanges(),d=i._sweepRad;let c=i._startRad;const _=o.reduce((e,t)=>e+(t.toValue-t.fromValue),0);this._sectorViews.prepare(o.length).forEach((e,t)=>{const s=_>0?(o[t].toValue-o[t].fromValue)/_*d:0;e.setSector({cx:a,cy:l,rx:r,ry:r,innerRadius:h,start:c,angle:s,clockwise:n}),e.internalClearStyleAndClass(),e.setFill(o[t].color),o[t].style&&e.addStyleOrClass(o[t].style),c+=n?s:-s})}};class be extends B{render(e,t){const s=e.getRadius(t);return s!==this._radius&&(this._radius=s,this.setPath((new T).circle(0,0,s).end())),this.internalSetStyleOrClass(e._style),this}}class we extends B{render(e,t){const s=e.getExtents(t);if(s.radius!==this._radius||s.length!==this._length||s.offset!==this._offset){const e=this._radius=s.radius,t=this._offset=s.offset;if(this._length=s.length,this._radius>0&&this._length>0){const s=new T;s.move(-e,t).line(0,-this._length+t).line(e,t),this.setPath(s.end())}else this.setPath("")}return this.internalSetStyleOrClass(e._style),this}}class Ve extends _e{constructor(e){super(e,"rct-circle-gauge")}_doInitContents(e,t){t.add(this._rimView=new ge(e)),t.add(this._valueView=new u(e,"rct-circle-gauge-value")),t.add(this._innerView=new u(e,"rct-circle-gauge-inner")),t.add(this._textView=new g(e,"rct-circle-gauge-label")),t.add(this._handContainer=new p(e,void 0)),t.add(this._scaleView=new ue(e)),t.add(this._bandView=new pe(e))}_backgroundView(){return this._rimView}_prepareGauge(e,t){this._rimView.setVis(t.rim.visible),this._scaleView.setVis(t.scale.visible),this._bandView.setVis(t.band.visible),this._valueView.setVis(t.valueRim.visible),t.hand.visible?(this._handView||this._handContainer.add(this._handView=new we(e,"rct-circle-gauge-hand")),this._handView.visible=!0):this._handView&&(this._handView.visible=!1),t.pin.visible?(this._pinView||this._handContainer.add(this._pinView=new be(e,"rct-circle-gauge-pin")),this._pinView.visible=!0):this._pinView&&(this._pinView.visible=!1),this._textView.setVis(t.labelVisible())&&this._textView.setStyleOrClass(t.label._style)}_renderGauge(e,t){const s=this.model,i=s.getCenter(e,t),a=s.getExtents(b(e,t));this.$_renderBackground(s,i,a),this._renderValue()}_renderValue(){const e=this.model,t=e.scale,s=e.getProps(),i=e.getValue(),a=t.getRate(h(i,0)),l=this._center,r=this._exts,n=e.valueRim.getThickness(r.radiusThick),o=this._textView;if(this._valueView.visible){const t=e.valueRim,h=e.calcedMinMax(),o=t.getRange({minValue:h.min,maxValue:h.max},i),d=r.value+(t.prop("stroked")?0:n/2),c=this._valueView;c.setStyleOrClass(t._style),o&&(c.setStyle(t.prop("stroked")?"stroke":"fill",o.color),o.style&&c.addStyleOrClass(o.style)),t.prop("stroked")&&(c.setFill("none"),c.setStyle("strokeWidth",w(n))),c.setBoolData("stroked",t.prop("stroked")),c.setSectorEx({cx:l.x,cy:l.y,rx:d,ry:d,innerRadius:(d-n)/d,start:s._startRad,angle:s._sweepRad*a,clockwise:e.prop("clockwise")},t.prop("stroked"))}if(this._handView){const t=(s._handRad+s._sweepRad*a)*V;this._handView.render(e.hand,r.radius).transp(l).rotate(e.prop("clockwise")?t:-t)}if(o.visible){const t=e.label;if(t.setText(e.getLabel(t,t.prop("animatable")?i:e.prop("value"))),o.text=t.prop("text"),o.setBoolData("grouped",!!e._group),t.buildSvg(o,null,NaN,NaN,e,t._domain),e._group)this.$_layoutGroupedLabel(e,o,r);else{const e=o.getBBox(),s=t.getOffset(this.width,this.height);o.trans(l.x+s.x,l.y-e.height/2+s.y)}}}$_renderBackground(e,t,s){const i=e.getProps();this._center=t,this._exts=s,e.scale.buildSteps(s.scale*i._sweepRad,NaN),this._rimView.visible&&(this._rimView.measure(this.doc,e.rim,this.width,this.height,0),this._rimView.setExtents(t,s),this._rimView.layout()),this._scaleView.visible&&(this._scaleView.setStyleOrClass(e.scale._style),this._scaleView.measure(this.doc,e.scale,this.width,this.height,0),this._scaleView.setExtents(t,s),this._scaleView.layout()),this._bandView.visible&&(this._bandView.setStyleOrClass(e.band._style),this._bandView.measure(this.doc,e.band,this.width,this.height,0),this._bandView.setExtends(t,s),this._bandView.layout()),this._innerView.setStyleOrClass(e.prop("innerStyle"));let a=s.inner;const l=getComputedStyle(this._innerView.dom),r=parseFloat(l.strokeWidth);r>1&&(a-=r/2),this._innerView.setSector({cx:t.x,cy:t.y,rx:a,ry:a,innerRadius:0,start:0,angle:2*Math.PI,clockwise:!0}),this._pinView&&this._pinView.render(e.pin,a).trans(t.x,t.y)}$_layoutGroupedLabel(e,t,s){const i=t.getBBox(),a=this._center,l=+e._group.num("labelGap");t.anchor=y.END,t.trans(a.x-l,a.y-s.radius+(s.radius-s.inner-i.height)/2)}}class ye extends x{constructor(e){super(e,"rct-circle-gauge-group")}_createPool(e){return new m(e,Ve)}_doRenderGauges(e,t,s,i){const a=this.doc,l=this.model,r=l.getProps().getCenter(s,i),n=l.getProps().getExtents(b(s,i));l.setChildExtents(n),s=i=2*n.radius,t.forEach((e,t)=>{e.measure(a,l.getVisible(t),s,i,0),e.resize(s,i),e.layout()}),e.trans(r.x-n.radius,r.y-n.radius)}}class xe extends s{}class me extends E{getWidth(e){return d(this._widthDim,e)}getHeight(e){return d(this._heightDim,e)}getMaxWidth(e){return d(this._maxWidthDim,e)}getMaxHeight(e){return d(this._maxHeightDim,e)}getGap(e){return d(this._gapDim,e,0)}_doApply(e){super._doApply(e),this._setDims(e,"width","height","maxWidth","maxHeight","gap")}}me.defaults=e(E.defaults,{maxWidth:"30%",maxHeight:"30%",gap:10});class fe extends D{_doInit(e){super._doInit(e),this._scale=this._addChild("scale",new xe(this))}get label(){return this._label}get scale(){return this._scale}_createLabel(){return new me(this.chart)}isVertical(){return this._group?this._group.prop("vertical"):this.prop("vertical")}scaleVisible(){return!this._group&&this._scale.visible}calcedMinMax(){return this._scale.range()}_doPrepareRender(e){super._doPrepareRender(e),this._label._prepareRender()}}fe.defaults=e(D.defaults,{reversed:!1});class ve extends r{constructor(){super(...arguments),this._args={gauge:null,value:NaN}}getStyle(e,t){const s=this.prop("styleCallback");if(s){this._args.gauge=e,this._args.value=t;return s(this._args)}}}class ke extends fe{_doInit(e){super._doInit(e),this._valueBar=this._addChild("valueBar",new ve(this)),this._band=this._addChild("band",new _(this))}get valueBar(){return this._valueBar}get band(){return this._band}}ke.type=I;class Ce extends t{}Ce.defaults=e(t.defaults,{opposite:!1,gap:10});class Se extends me{}Se.defaults=e(me.defaults,{gap:10});class Re extends N{_doInit(e){super._doInit(e),this._label=this._addChild("label",new Se(this.chart)),this._itemLabel=this._addChild("itemLabel",new Ce(this.chart)),this._scale=this._addChild("scale",new xe(this))}get label(){return this._label}get itemLabel(){return this._itemLabel}get scale(){return this._scale}calcedMinMax(){return this.scale.range()}}Re.defaults=e(N.defaults,{vertical:!1,itemGap:10});class Le extends Re{_doInit(e){super._doInit(e),this._band=this._addChild("band",new _(this))}get band(){return this._band}_gaugesType(){return"linear"}_doPrepareRender(e){super._doPrepareRender(e),this.band.visible&&this.band._prepareRender()}}Le.type=O,Le.gaugeType=I;class Be extends v{_createLine(e,t){return new H(e,t)}_doMeasure(e,t,s,i,a){const l=t.prop("gap"),r=t._reversed,h=t._vertical,o=t.label,d=t.tick,c=t._steps,_=c.length;let u=h?l:s,g=h?i:l;if(this._tickContainer.setVis(d.visible)&&(this._tickContainer.setStyleOrClass(d._style),this._ticks.prepare(_)),h?u+=d.prop("length"):g+=d.prop("length"),this._labelContainer.setVis(o.visible)&&(this._labels.prepare(_,t=>{t.setModel(e,o,null,null)}),_>0))if(h){let e=0;this._labels.forEach((t,s)=>{t.setText(o.getText(c[r?s:_-1-s])),e=n(t.getBBox().width)}),u+=e}else{let e=0;this._labels.forEach((t,s)=>{t.setText(o.getText(c[r?_-1-s:s])),e=n(t.getBBox().height)}),g+=e}return{width:u,height:g}}_doLayout(){const e=this.model;e._vertical?this.$_layoutVert(e,this.width,this.height):this.$_layoutHorz(e,this.width,this.height)}$_layoutHorz(e,t,s){const i=e.prop("gap"),a=this._line,l=e.tick,r=e._steps;r.length;const n="opposite"===e.prop("position"),h=n?-l.prop("length"):l.prop("length");let o,d=n?s-i:i;if(a.setVis(e.line.visible)&&(a.setStyleOrClass(e.line._style),a.setHLine(d,0,t)),this._tickContainer.setVis(l.visible)&&this._ticks.forEach((s,i)=>{o=e.getRate(r[i])*t,s.setVLine(o,d,d+h)}),this._labelContainer.visible){const s=this._labelContainer.textAlign()||"center";let i=Number.MIN_SAFE_INTEGER;d=n?0:d+h,this._labels.forEach((a,l)=>{a.layout(s);const n=a.getBBox();o=e.getRate(r[l])*t,a.setVis(o-n.width/2>i)&&(a.trans(o-n.width/2,d),i=o+n.width/2)})}}$_layoutVert(e,t,s){const i=e.prop("gap"),a=this._line,l=e.tick,r=e._steps;this.height,r.length;const n="opposite"===e.prop("position"),h=n?l.prop("length"):-l.prop("length");let o,d=n?i:t-i;if(a.setVis(e.line.visible)&&(a.setStyleOrClass(e.line._style),a.setVLine(d,0,s)),this._tickContainer.setVis(l.visible)&&this._ticks.forEach((t,i)=>{o=e.getRate(r[i])*s,t.setHLine(o,d,d+h)}),this._labelContainer.visible){const a=this._labelContainer.textAlign()||(n?"left":"right");d=n?d+h:t-i+h,this._labels.forEach((t,i)=>{t.layout(a);const l=t.getBBox(),h=n?d:d-l.width;o=e.getRate(r[i])*s,t.trans(h,o-l.height/2)})}}}class Te extends f{_measureLabelSize(e,t,s){const i=e.label,a=this.labelView();return i.setText(e.getLabel(i,e.prop("value"))),a.text=i.prop("text"),i.buildSvg(a,null,t,s,e,i._domain),M(a.getBBox())}_renderGauge(e,t){const s=this.model,i=h(s._runValue,s.prop("value"));this._measureGauge(s,s.label,this.labelView(),i,s.isVertical(),e,t),this._renderValue()}_renderValue(){const e=this.model,t=e.label,s=e.scale,i=this.labelView(),a=h(e._runValue,e.prop("value")),l=P({},this._rBand);if(this._renderScale(l),this.background().setRect(l),l.height>0&&this._renderBand(e,l,a),"top"!==t._runPos&&"bottom"!==t._runPos||(this._rLabel.height=l.height),this._renderLabel(e,t,i,a),!this._vertical&&("left"===t._runPos||"right"===t._runPos)&&s.visible&&"opposite"===s.prop("position")){const e=i.getBBox();i.ty+e.height>this.height&&i.transY(n(0,this.height-e.height))}}_measureGauge(e,t,s,i,a,l,r){const o=this._rBand=$(0,0,l,r);if(this._vertical=e._group instanceof Re?e._group.prop("vertical"):a,t.visible){const a=t._runPos=z(t.prop("position"),this._vertical?"top":"left"),d=t._runVert="top"===a||"bottom"===a,c=e._group?e._group.itemLabel.prop("gap"):t._runGap=t.getGap(d?r:l);let _=d?l:t.getWidth(l),u=d?t.getHeight(r):r;const g=d?l:t.getMaxWidth(l),p=d?t.getMaxHeight(r):r,b=this._rLabel=$(0,0,l,r);s.setStyleOrClass(t._style),t.setText(e.getLabel(t,t.prop("animatable")?i:e.prop("value"))),s.text=t.prop("text"),t.buildSvg(s,null,h(_,g),h(u,p),e,t._domain);const w=s.getBBox();switch(d?(b.height=h(u,w.height),o.height=n(0,o.height-(b.height+c))):(b.width=h(_,w.width),this._wLabel=e._group?e._group._labelWidth:b.width,o.width=n(0,o.width-(this._wLabel+c))),a){case"top":o.y=b.height+c;break;case"bottom":b.y=o.height+c;break;case"right":b.x=o.width+c;break;default:o.x=this._wLabel+c}}else this._rLabel=null}_renderLabel(e,t,s,i){if(s.visible){const e=this._rLabel,i=s.getBBox();let a=e.x,l=e.y;switch(t._runPos){case"top":case"bottom":a+=e.width/2;break;case"right":a=this.width-e.width,s.anchor=y.START,l+=n(0,(e.height-i.height)/2);break;default:s.anchor=y.END,a+=this._wLabel,l+=n(0,(e.height-i.height)/2)}s.trans(a,l)}}_renderScale(e){const t=this.model,s=t.label,i=t.scale,a=this.scaleView(),l=this._vertical?e.height:e.width;let r,h;if(i._vertical=this._vertical,i._reversed=t.prop("reversed"),isNaN(t._runValue)&&i.buildSteps(l,t.prop("value")),a.setVis(t.scaleVisible())){const t=a.measure(this.doc,i,e.width,e.height,1);this._vertical?(r=0,h=e.y,e.width=n(0,e.width-t.width),"opposite"===i.prop("position")?r=e.x+e.width:(s._runVert||(r=e.x),e.x+=t.width)):(r=e.x,e.height=n(0,e.height-t.height),"opposite"===i.prop("position")?s._runVert?(h=e.y,e.y+=t.height):(this._rLabel.y=e.y+=t.height,h=e.y-t.height):h=e.y+e.height),a.resizeByMeasured().layout().trans(r,h)}}}class Ee extends L{constructor(e){super(e,"rct-linear-gauge-band"),this._thick=0,this._gap=0,this._labelGap=3,this._barViews=new m(this,G),this.add(this._labelContainer=new p(e,"rct-linear-gauge-band-tick-labels")),this._labels=new m(this._labelContainer,g)}_doMeasure(e,t,s,i,a){const l=t.gauge,r=this._vertical=l instanceof ke?l.isVertical():l.prop("vertical"),h="inside"===t.prop("position"),o=this._thick=h?r?s:i:t.getThickness(r?s:i)+(this._gap=t.num("gap"));let d=r?o:s,c=r?i:o;const _=this._ranges=t.getRanges();if(this._labelContainer.setVis(t.tickLabel.visible&&_.length>0)){const e=[_[0].fromValue].concat(_.map(e=>e.toValue));if(this._labelContainer.setStyleOrClass(t.tickLabel._style),this._labels.prepare(_.length+1),r){let t=0;this._labels.forEach((s,i)=>{s.text=String(e[i]),t=n(s.getBBox().width)}),d+=t+this._labelGap}else{let t=0;this._labels.forEach((s,i)=>{s.text=String(e[i]),t=n(s.getBBox().height)}),c+=t}}return{width:d,height:c}}_doLayout(e){const t=this.model,s=t.gauge,i=s.scale,a=i._max-i._min;this._labelContainer.setVis(this.$_layoutBars(s,a,this._ranges)&&this._labelContainer.visible&&"inside"!==t.prop("position"))&&this.$_layoutLabels(s,a,this._ranges)}$_layoutBars(e,t,s){if(this._barViews.prepare(s.length),!this._barViews.isEmpty&&t>0){const e=this._vertical,i="inside"===this.model.prop("position"),a="opposite"===this.model.prop("position"),l=this.width,r=this.height,n=e?r:l,h=this._thick;let o=0;return this._barViews.prepare(s.length).forEach((d,c)=>{const _=s[c],u=n*(_.toValue-_.fromValue)/t;if(e){const e=i||a?0:l-h;d.setBounds(e,r-o-u,h,u)}else{const e=a?r-h:0;d.setBounds(o,e,u,this._thick)}d.internalClearStyleAndClass(),d.setFill(_.color),_.style&&d.addStyleOrClass(_.style),o+=u}),!0}}$_layoutLabels(e,t,s){const i="opposite"===this.model.prop("position");if(this._vertical){const e=this.height,a=i?y.START:y.END,l=i?this._thick+this._labelGap:this.width-this._thick-this._labelGap;let r=this._labels.get(0);r.anchor=a,r.trans(l,e-r.getBBox().height/2);for(let i=1;i<=s.length;i++){const n=e-e*s[i-1].toValue/t;r=this._labels.get(i),r.anchor=a,r.trans(l,n-r.getBBox().height/2)}}else{const e=this.width,a=i?0:this._thick;this._labels.get(0).trans(0,a);for(let i=1;i<=s.length;i++){const l=e*s[i-1].toValue/t;this._labels.get(i).trans(l,a)}}}}class De extends Te{constructor(e){super(e,"rct-linear-gauge")}_doInitContents(e,t){t.add(this._background=new G(e,"rct-linear-gauge-background")),t.add(this._bandView=new Ee(e)),t.add(this._scaleView=new Be(e)),t.add(this._valueView=new G(e,"rct-linear-gauge-value")),t.add(this._labelView=new g(e))}_backgroundView(){return this._background}labelView(){return this._labelView}scaleView(){return this._scaleView}background(){return this._background}_prepareGauge(e,t){}_renderScale(e){const t=this.model.band,s=this._bandView;if(super._renderScale(e),s.setVis(t.visible)){const i=t.num("gap"),a=s.measure(this.doc,t,e.width,e.height,1);s.resizeByMeasured().layout(),this._vertical?"inside"===t.prop("position")?s.trans(e.x,e.y):"opposite"===t.prop("position")?(s.trans(e.x+e.width-a.width,e.y),e.width-=a.width+i):(s.trans(e.x,e.y),e.width-=a.width+i,e.x+=a.width+i):"inside"===t.prop("position")?s.trans(e.x,e.y):"opposite"===t.prop("position")?(s.trans(e.x,e.y),e.height-=a.height+i,e.y+=a.height+i):(s.trans(e.x,e.y+e.height-a.height),e.height-=a.height+i)}}_renderBand(e,t,s){const i=this._valueView,a=e.prop("reversed"),l=e.valueBar,r=e._group?e._group.scale:e.scale;if(i.setVis(!A(t)&&l.visible&&!r.isEmpty()&&!isNaN(e.prop("value"))))if(i.setStyleOrClass(l._style),i.internalSetStyleOrClass(l.getStyle(e,s)),this._vertical){const e=t.height*r.getRate(s),l=a?t.y:t.y+t.height-e;i.setBounds(t.x,l,t.width,e)}else{const e=t.width*r.getRate(s),l=a?t.x+t.width-e:t.x;i.setBounds(l,t.y,e,t.height)}}}class Ie extends x{constructor(e,t){super(e,t)}_doInitContents(e,t){super._doInitContents(e,t),t.insertFirst(this._scaleView=new Be(e)),t.insertFirst(this._textView=new g(e,"rct-linear-gauge-group-label"))}_prepareGauge(e,t){this._textView.setVis(t.label.visible)&&this._textView.setStyleOrClass(t.label._style),this._scaleView.setVis(t.scale.visible)&&this._scaleView.setStyleOrClass(t.scale._style),super._prepareGauge(e,t)}_doRenderGauges(e,t,s,i){const a=this.model,l=this._textView,r=$(0,0,s,i);if(l.visible){l.text=a.label.prop("text"),a.label.buildSvg(l,null,NaN,NaN,a,null);const e=this._textView.getBBox().height+a.label.getGap(i);r.y+=e,r.height-=e,l.trans(this.width/2,0)}a._labelWidth=a._labelHeight=0,this._gaugeViews.forEach((e,t)=>{const l=e._measureLabelSize(a.get(t),s,i);a._labelWidth=n(a._labelWidth,l.width),a._labelHeight=n(a._labelHeight,l.height)});const h=F(r),o=a.itemLabel.prop("gap");a.prop("vertical")?(h.height-=a._labelHeight+o,a.itemLabel.prop("opposite")||(h.y+=a._labelHeight+o)):(h.width-=a._labelWidth+o,a.itemLabel.prop("opposite")||(h.x+=a._labelWidth+o)),this._renderScale(a,r,h),a.prop("vertical")?this.$_layoutVert(this.doc,a,t,r):this.$_layoutHorz(this.doc,a,t,r)}_renderScale(e,t,s){const i=this._scaleView,a=e.scale,l=e.prop("vertical"),r=l?t.height:t.width,n=[];let h,o;if(this._gaugeViews.forEach((t,s)=>{n.push(e.get(s).getValue())}),a.buildGroupSteps(r,n),a._vertical=l,i.setVis(a.visible)){const e=i.measure(this.doc,a,s.width,s.height,1);if(l){const i=e.width;s.width-=i,t.width-=i,o=s.y,"opposite"===a.prop("position")?h=s.x+s.width:(h=s.x,s.x+=i,t.x+=i)}else{const i=e.height;s.height-=i,t.height-=i,h=s.x,"opposite"===a.prop("position")?(o=s.y,s.y+=i,t.y+=i):o=s.y+s.height}i.resizeByMeasured().layout().trans(h,o)}}$_layoutVert(e,t,s,i){const a=i.height,l=(i.width-t.prop("itemGap")*(s.count-1))/s.count,r=i.y;let n=i.x;s.forEach((s,i)=>{s.measure(e,t.get(i),l,a,0),s.resize(l,a),s.layout(),s.trans(n,r),n+=l+t.prop("itemGap")})}$_layoutHorz(e,t,s,i){const a=t.prop("itemGap"),l=i.width,r=(i.height-a*(s.count-1))/s.count,n=i.x;let h=i.y;s.forEach((s,i)=>{s.measure(e,t.get(i),l,r,0),s.resize(l,r),s.layout(),s.trans(n,h),h+=r+a})}}class Ne extends Ie{constructor(e){super(e,"rct-linear-gauge-group")}_doInitContents(e,t){super._doInitContents(e,t),t.insertChild(this._bandView=new Ee(e),this._scaleView)}_createPool(e){return new m(e,De)}_renderScale(e,t,s){super._renderScale(e,t,s);const i=this._bandView,a=e.band;let l,r;if(i.setVis(a.visible)){const n=a.num("gap"),h=i.measure(this.doc,a,s.width,s.height,1);if(e.prop("vertical")){const e=h.width+n;s.width-=e,t.width-=e,r=s.y,"opposite"===a.prop("position")?l=s.x+s.width+n:(l=s.x,s.x+=e,t.x+=e)}else{const e=h.height+n;s.height-=e,t.height-=e,l=s.x,"opposite"===a.prop("position")?(r=s.y,s.y+=e,t.y+=e):r=s.y+s.height+n}i.resizeByMeasured().layout().trans(l,r)}}}class Oe extends E{getText(e){return this._getText(null,e,X(e)>1e3,!0)}}Oe.defaults=e(E.defaults,{visible:!1,position:"outside",offset:4});class Ge extends E{getText(e){return this._getText(null,e,X(e)>1e3,!0)}}Ge.defaults=e(E.defaults,{visible:!1,offset:4});class Ae extends t{constructor(e){super(e.chart),this.gauge=e}get toValueLabel(){return this._toValueLabel}_doInit(e){super._doInit(e),this._toValueLabel=this._addChild("toValueLabel",new Ge(this.chart))}getRanges(){var e;return null===(e=this.$_internalRanges())||void 0===e?void 0:e.slice(0)}_doApply(e){const t=this;var s;super._doApply(e),(s=e.ranges)!==t._ranges&&(t._ranges=s,t._runRanges=null)}$_internalRanges(){if(!this._runRanges){const e=this.gauge;this._runRanges=o(this._ranges,e.prop("minValue"),e.prop("maxValue"),this.prop("rangeInclusive"))}return this._runRanges}}Ae.defaults=e(t.defaults,{vertical:!0,rangeInclusive:!0});class He extends r{get label(){return this._label}_doInit(e){super._doInit(e),this._label=this._addChild("label",new Oe(this.chart))}}He.defaults=e(t.defaults,{visible:!0});class Me extends ve{get label(){return this._label}_doInit(e){super._doInit(e),this._label=this._addChild("label",new Oe(this.chart))}}class Pe extends fe{_doInit(e){super._doInit(e),this._band=this._addChild("band",new Ae(this)),this._targetBar=this._addChild("targetBar",new He(this)),this._valueBar=this._addChild("valueBar",new Me(this))}get band(){return this._band}get targetBar(){return this._targetBar}get valueBar(){return this._valueBar}getRanges(e,t,s){return o(this.prop("ranges"),e,t,z(s,this.prop("rangeInclusive")))}getParam(e){return"targetValue"===e?this.prop("targetValue"):super.getParam(e)}}Pe.type=W,Pe.defaults=e(fe.defaults,{rangeInclusive:!0});class $e extends Re{getRanges(e,t,s){return o(this.prop("ranges"),e,t,z(s,this.prop("rangeInclusive")))}_gaugesType(){return"bullet"}}$e.type=Y,$e.gaugeType=W,$e.defaults=e(Re.defaults,{rangeInclusive:!0});class ze extends Te{constructor(e){super(e,"rct-bullet-gauge")}_doInitContents(e,t){t.add(this._background=new G(e,"rct-bullet-gauge-background")),t.add(this._barContainer=new p(e,void 0)),this._barViews=new m(this._barContainer,G),t.add(this._valueView=new G(e,"rct-bullet-gauge-value")),t.add(this._targetView=new G(e,"rct-bullet-gauge-target")),t.add(this._scaleView=new Be(e)),t.add(this._labelView=new g(e)),t.add(this._valueLabelView=new g(e,"rct-bullet-gauge-value-label")),t.add(this._targetLabelView=new g(e,"rct-bullet-gauge-target-label")),this._bandLabelViews=new m(t,g)}_backgroundView(){return this._background}labelView(){return this._labelView}scaleView(){return this._scaleView}background(){return this._background}_prepareGauge(e,t){}_renderBand(e,t,s){const i=e.prop("targetValue"),a=e._group,l=e.prop("reversed"),r=this._vertical,n=a?a.scale:e.scale,h=this._valueView,o=this._targetView;if(this._barContainer.setVis(!A(t)&&!n.isEmpty())){const s=e.getRanges(n._min,n._max,!1)||(null==a?void 0:a.getRanges(n._min,n._max,!1));if(s){this._barContainer.setRect(t),this._barViews.prepare(s.length),r?this._barViews.forEach((e,i)=>{const a=s[i],r=t.height*n.getRate(a.toValue-a.fromValue),h=t.height*n.getRate(a.fromValue);e.setBounds(0,l?h:t.height-h-r,t.width,r),e.internalClearStyleAndClass(),e.setFill(a.color),a.style&&e.addStyleOrClass(a.style)}):this._barViews.forEach((e,i)=>{const a=s[i],r=t.width*n.getRate(a.toValue-a.fromValue),h=t.width*n.getRate(a.fromValue);e.setBounds(l?t.width-r-h:h,0,r,t.height),e.internalClearStyleAndClass(),e.setFill(a.color),a.style&&e.addStyleOrClass(a.style)});const i=e.band.toValueLabel;if(i.visible){const e=i.num("offset");this._bandLabelViews.prepare(s.length,e=>{e.internalClearStyleAndClass(),e.setStyleOrClass(i._style)}),this._bandLabelViews.forEach((a,h)=>{const o=s[h].toValue;a.text=i.getText(o);const d=a.getBBox();if(r){const s=l?t.y+t.height*n.getRate(o):t.y+t.height*(1-n.getRate(o)),i=d.width/2;a.trans(t.x+t.width+e+i,s-d.height/2)}else{const s=l?t.x+t.width*(1-n.getRate(o)):t.x+t.width*n.getRate(o);a.trans(s-d.width/2,t.y-e-d.height)}})}else this._bandLabelViews.prepare(0)}}if(h.setVis(e.valueBar.visible&&!n.isEmpty()&&!isNaN(s)))if(h.setStyleOrClass(e.valueBar._style),s<i&&e.valueBar.prop("belowStyle")&&h.internalSetStyleOrClass(e.valueBar.prop("belowStyle")),h.internalSetStyleOrClass(e.valueBar.getStyle(e,s)),r){const e=t.height*n.getRate(s),i=l?t.y:t.y+t.height-e;h.setBounds(t.x+t.width/3,i,t.width/3,e)}else{const e=t.width*n.getRate(s),i=l?t.x+t.width-e:t.x;h.setBounds(i,t.y+t.height/3,e,t.height/3)}const d=e.valueBar.label;if(this._valueLabelView.setVis(d.visible&&h.visible)){const e=d.prop("position")||"outside",i=d.num("offset");this._valueLabelView.setStyleOrClass(d._style),this._valueLabelView.text=d.getText(s);const a=this._valueLabelView.getBBox();if(r){const r=t.height*n.getRate(s),h=l?t.y:t.y+t.height-r,o=l?h+r:h;if("inside"===e){const e=l?o-a.height-i:o+i;this._valueLabelView.trans(t.x+t.width/2,e)}else{const e=l?o+i:o-i-a.height;this._valueLabelView.trans(t.x+t.width/2,e)}}else{const r=t.width*n.getRate(s),h=l?t.x+t.width-r:t.x,o=l?h:h+r,d=t.y+t.height/2,c=a.width/2;if("inside"===e){const e=l?o+i+c:o-i-c;this._valueLabelView.trans(e,d-a.height/2)}else{const e=l?o-i-c:o+i+c;this._valueLabelView.trans(e,d-a.height/2)}}}if(o.setVis(e.targetBar.visible&&!n.isEmpty()&&!isNaN(i)))if(o.setStyleOrClass(e.targetBar._style),r&&t.width>10){let e=t.height*n.getRate(i);e=l?t.y+e:t.y+t.height-e,o.setBounds(t.x+5,e-1,t.width-10,3)}else if(!r&&t.height>10){let e=t.width*n.getRate(i);e=l?t.x+t.width-e:t.x+e,o.setBounds(e-1,t.y+5,3,t.height-10)}const c=e.targetBar.label;if(this._targetLabelView.setVis(c.visible&&o.visible)){const e=c.prop("position")||"outside",s=c.num("offset");this._targetLabelView.setStyleOrClass(c._style),this._targetLabelView.text=c.getText(i);const a=this._targetLabelView.getBBox();if(r){const r=n.getRate(i),h=l?t.y+t.height*r:t.y+t.height*(1-r),o=h-a.height/2,d=a.width/2;if("inside"===e){const e=t.x+t.width/2;l?this._targetLabelView.trans(e,h-s-a.height):this._targetLabelView.trans(e,h+s)}else this._targetLabelView.trans(t.x+t.width+s+d,o)}else{const r=n.getRate(i),h=l?t.x+t.width*(1-r):t.x+t.width*r;if("inside"===e){const e=a.width/2,i=t.y+t.height/2,r=l?h+s+e:h-s-e;this._targetLabelView.trans(r,i-a.height/2)}else this._targetLabelView.trans(h,t.y-s-a.height)}}}}class Fe extends Ie{constructor(e){super(e,"rct-bullet-gauge-group")}_createPool(e){return new m(e,ze)}}class We extends r{getThickness(e){return d(this._thicknessDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"thickness")}}We.defaults=e(t.defaults,{thickness:7});class Ye extends r{getLength(e){return d(this._lengthDim,e,e)}_doApply(e){super._doApply(e),this._setDim(e,"length")}}Ye.defaults=e(t.defaults,{thickness:7,length:"60%"});class Xe extends Ye{}Xe.defaults=e(Ye.defaults,{thickness:5,length:"85%"});class Ue extends Ye{}Ue.defaults=e(Ye.defaults,{thickness:2,length:"95%",animatable:!1,duration:200});class je extends r{constructor(e,t){super(e),this.length=t}}class qe extends r{}qe.defaults=e(t.defaults,{step:1,offset:1});class Je extends r{constructor(e,t){super(e),this.raidus=t}}class Ke extends U{constructor(e){super(e.chart)}}Ke.defaults=e(U.defaults,{text:"RealChart Clock<br>ver1.0",position:"top"});class Qe extends q{_doInit(e){super._doInit(e),this.rim=this._addChild("rim",new We(this)),this.hourHand=this._addChild("hourHand",new Ye(this)),this.minuteHand=this._addChild("minuteHand",new Xe(this)),this.secondHand=this._addChild("secondHand",new Ue(this)),this.tick=this._addChild("tick",new je(this,10)),this.minorTick=this._addChild("minorTick",new je(this,5)),this.tickLabel=this._addChild("tickLabel",new qe(this)),this.pin=this._addChild("pin",new Je(this,5)),this.label=this._addChild("label",new Ke(this))}getTime(){const e=this._op;return e.time instanceof this.chart.win.Date?e.time:J(e.time)?new Date(e.time):isNaN(e.time)?void 0:new Date(e.time)}getExtents(e,t){const s=b(e,t);return{cx:d(this._centerXDim,e,e/2),cy:d(this._centerYDim,t,t/3),rd:d(this._radiusDim,s,s/2)}}_doApply(e){const t=this;var s,i,a;super._doApply(e),s=e.centerX,i=e.centerY,a=e.radius,(t._centerXDim||s!==t._centerX)&&(t._centerXDim=K(z(t._centerX=s,c.DEF_CENTER),!0)),t._centerYDim&&i===t._centerY||(t._centerYDim=K(z(t._centerY=i,c.DEF_CENTER),!0)),t._radiusDim&&a===t._radius||(t._radiusDim=K(z(t._radius=a,c.DEF_RADIUS),!0))}}Qe.type=j,Qe.defaults=e(q.defaults,{centerX:"50%",centerY:"50%",radius:"40%",active:!0});class Ze extends ie{constructor(e){super(),this.view=e}_doUpdate(e){return this.view._secRate=e,this.view.$_renderHands(this.view.model,this.view._exts),!0}}class et extends Q{constructor(e){super(e,"rct-clock-gauge"),this._rimThick=0,this._secRate=1}_doInitContents(e,t){t.add(this._faceView=new Z(e,"rct-clock-gauge-face")),t.add(this._rimView=new u(e,"rct-clock-gauge-rim")),t.add(this._labelView=new g(e,"rct-clock-gauge-label")),this._labelView.layout=ee.MIDDLE,t.add(this._tickContainer=new p(e,"rct-clock-gauge-ticks")),t.add(this._tickLabelContainer=new p(e,"rct-clock-gauge-tick-labels")),t.add(this._hourView=new B(e,"rct-clock-gauge-hour")),t.add(this._minuteView=new B(e,"rct-clock-gauge-minute")),t.add(this._secondView=new B(e,"rct-clock-gauge-second")),t.add(this._pinView=new Z(e,"rct-clock-gauge-pin")),this._tickViews=new m(this._tickContainer,H,"rct-clock-gauge-tick"),this._minorTickViews=new m(this._tickContainer,H,"rct-clock-gauge-minor-tick"),this._tickLabelViews=new m(this._tickLabelContainer,g,"rct-clock-gauge-tick-label")}_prepareGauge(e,t){this._tickViews.prepare(t.tick.visible?12:0),this._minorTickViews.prepare(t.minorTick.visible?48:0);const s=Math.round(12/n(1,Math.floor(t.tickLabel.prop("step"))||1));this._tickLabelViews.prepare(t.tickLabel.visible?s:0,e=>{e.layout=ee.MIDDLE})}_renderGauge(e,t){const s=this.model,i=this._exts=s.getExtents(e,t);this._secRate=1,this.$_renderFace(s,i),this.$_renderHands(s,i),s.prop("active")&&!s.getTime()?this._runner||(this._runner=setInterval(()=>{const e=this._prevSec;this.$_renderHands(this.model,this._exts),X(e-this._prevSec)>=1&&this._secondView.visible&&s.chart.animatable()&&s.secondHand.prop("animatable")&&this.$_moveSecond(e)},1e3)):this._runner&&(clearInterval(this._runner),this._runner=void 0)}$_renderFace(e,t){const s=this._labelView,i=this._rimView,a=this._minorTickViews,l=this._tickLabelViews,r=this._pinView,{cx:n,cy:h,rd:o}=t,d=this._rimThick=e.rim.getThickness(o);this._faceView.setCircle(n,h,o),i.setVis(e.rim.visible)&&(i.internalSetStyleOrClass(e.rim._style),i.setSector({cx:n,cy:h,rx:o,ry:o,innerRadius:1-d/o,start:0,angle:2*Math.PI,clockwise:!0}));const c=o-(i.visible?d:0);let _=c-e.tick.length,u=te,g=se/12;if(this._tickViews.forEach((t,s)=>{t.setLine(n+C(u)*c,h+S(u)*c,n+C(u)*_,h+S(u)*_),t.internalSetStyleOrClass(e.tick._style),u+=g}),!a.isEmpty){let t=0;_=c-e.minorTick.length,u=te,g=se/60,a.forEach(s=>{t%5==0&&(u+=g,t++),s.setLine(n+C(u)*c,h+S(u)*c,n+C(u)*_,h+S(u)*_),s.internalSetStyleOrClass(e.minorTick._style),u+=g,t++})}if(!l.isEmpty){const t=12/l.count,s=se/12*t;u=te,l.get(0).text="12",_=c-(e.tick.length+e.tickLabel.prop("offset")||0),_-=.5*l.get(0).getBBox().height,l.forEach((i,a,l)=>{i.text=String(0===a?12:a*t),i.trans(n+C(u)*_,h+S(u)*_),i.internalSetStyleOrClass(e.tickLabel._style),u+=s})}r.setVis(e.pin.visible)&&(r.setCircle(n,h,e.pin.raidus),r.setStyleOrClass(e.pin._style)),s.setVis(e.label.visible)&&(s.internalSetStyleOrClass(e.label._style),e.label.buildSvg(s,null,NaN,NaN,null,null),"bottom"===e.label.prop("position")?s.trans(n,h+_/2):s.trans(n,h-_/2))}$_getNow(){const e=this.model.prop("timezone");let t=this.model.getTime()||new Date;if(!isNaN(e)){const s=t.getMinutes()+(t.getTimezoneOffset()+e);t.setMinutes(s)}return t}$_renderHands(e,t){const s=this.$_getNow(),i=s.getHours(),a=s.getMinutes(),l=s.getSeconds(),{cx:r,cy:n,rd:h}=t,o=new T;let d,c,_,u;d=e.hourHand,c=this._hourView,c.setVis(d.visible)&&(u=se*(i/12+a/60/12+l/60/60/12),_=d.getLength(h-this._rimThick),o.rect(-d.prop("thickness")/2,-_,d.prop("thickness"),_),c.internalSetStyleOrClass(d._style),c.setPath(o.close(!0)).trans(r,n).rotate(u*V)),d=e.minuteHand,c=this._minuteView,c.setVis(d.visible)&&(u=se*(a/60+l/60/60),_=d.getLength(h-this._rimThick),o.rect(-d.prop("thickness")/2,-_,d.prop("thickness"),_),c.internalSetStyleOrClass(d._style),c.setPath(o.close(!0)).trans(r,n).rotate(u*V)),d=e.secondHand,c=this._secondView,c.setVis(d.visible)&&(u=this._secRate<1?se*(this._aniSec+this._secRate)/60:se*l/60,_=d.getLength(h-this._rimThick),o.rect(-d.prop("thickness")/2,-_,d.prop("thickness"),_),c.internalSetStyleOrClass(d._style),c.setPath(o.close(!0)).trans(r,n).rotate(u*V),this._prevSec=l)}$_moveSecond(e){if(!isNaN(e)){this._aniSec=e;const t=new Ze(this);t.duration=this.model.secondHand.prop("duration")||200,t.start()}}}function tt(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Gauge.register(Pe,de,Qe,ke),e.GaugeGroup.register($e,ce,Le),e.GaugeView.register([de,Ve],[ke,De],[Pe,ze],[Qe,et],[ce,ye],[Le,Ne],[$e,Fe]))}export{Pe as BulletGauge,de as CircleGauge,Qe as ClockGauge,ke as LinearGauge,tt as default,tt as registerGauge};
|
package/heatmap.js
CHANGED