realchart
Version:
Wooritech charting library
8 lines (6 loc) • 3.71 kB
JavaScript
/**
* RealChart Vector v1.3.17
* Copyright (C) 2023-2025 WooriTech Inc.
* All Rights Reserved.
*/
import{VectorSeriesType as e,extend as t,Series as s,ConnectableSeries as n,maxv as i,PathElement as r,DataPoint as l,assignObj as a,pickNum as o,pickProp as h,pickProp3 as g,incv as u,SeriesView as p,ElementPool as _,SeriesAnimation as d,PointElement as c}from"./index.mjs";class f extends l{_assignTo(e){return a(super._assignTo(e),{length:this.length,angle:this.angle,lengthValue:this.lengthValue,angleValue:this.angleValue})}_valuesChangd(e){return this.length!==e.length||this.angle!==e.angle||super._valuesChangd(e)}_readArray(e,t){if(t.length<=2)this.isNull=!0;else{const s=t.length>3?1:0;s>0&&(this.x=t[o(e.options.xField,0)]),this.y=t[o(e.options.yField,0+s)],this.length=t[o(e.options.lengthField,1+s)],this.angle=t[o(e.options.angleField,2+s)]}}_readObject(e,t){super._readObject(e,t),this.length=h(t[e.options.lengthField],t.length),this.angle=h(t[e.options.angleField],t.angle),this.y=g(e._yFielder(t),t.y,t.value)}_readSingle(e){super._readSingle(e),this.length=this.angle=this.y}parse(e){super.parse(e),this.isNull||(this.isNull=isNaN(this.lengthValue)||isNaN(this.angleValue))}initValues(){this.lengthValue=parseFloat(this.length),this.angleValue=parseFloat(this.angle)}initPrev(e,t){t.yValue=this.yValue,t.lengthValue=.001}applyValueRate(e,t){this.lengthValue=u(e.lengthValue,this.lengthValue,t)}}class V extends n{_createPoint(e){return new f(e)}_doPrepareRender(){super._doPrepareRender();const e=this._runPoints;if(e.length>0){const t=this._op.maxLength,s=this._op.origin,n=e.map((e=>e.length)).reduce(((e,t)=>i(e,t)));e.forEach((e=>{const i=e.length/n;switch(e._len=i*t,s){case"start":e._off=-e._len/2;break;case"end":e._off=e._len/2;break;default:e._off=0}}))}}_createLegendMarker(e,t){const n=.3,i=.7*t,l=[0,-n*t,-.2*t,-n*t,0,-.6*t,.2*t,-n*t,0,-n*t,0,.6*t],a=["M",l[0],l[1]+i];for(let e=2;e<l.length;e+=2)a.push("L",l[e],l[e+1]+i);const o=new r(e,s.LEGEND_MARKER,a);return o.setStyle("strokeWidth","2px"),o.rotation=30,o}}V.type=e,V.defaults=t(s.defaults,{origin:"center",maxLength:20,startAngle:0,arrowHead:"close"});class w extends c{layout(e,t,s){const n=this.point._len,i=n*s,r=.5;let l,a=(n-i)/2;switch(e){case"none":l=[0,a-r*i,0,a+r*i];break;case"open":const e=.15,t=.45,s=.2;l=[0,a-t*i,0-e*i,a-s*i,0,a-r*i,0+e*i,a-s*i,0,a-t*i,0,a+r*i];break;default:const n=.1,o=.3;l=[0,a-o*i,0-n*i,a-o*i,0,a-r*i,0+n*i,a-o*i,0,a-o*i,0,a+r*i]}const o=this.point._off*s,h=["M",l[0],l[1]+o];for(let e=2;e<l.length;e+=2)h.push("L",l[e],l[e+1]+o);this.rotation=t,this.setPath(h)}}class y extends p{constructor(e){super(e,"rct-vector-series"),this._arrows=new _(this._pointContainer,w)}_getPointPool(){return this._arrows}_prepareSeries(e,t){this.$_prepareArrows(t,this._visPoints)}_renderSeries(e,t){const s=this.model;let n=s.options.startAngle;const i=s.options.arrowHead,r=s._xAxisObj,l=s._yAxisObj,a=this._inverted,o=a?e:t,h=a?t:e,g=this._getGrowRate(),u=a?0:t,p=r.options.reversed?-1:1,_=l.options.reversed;this._pointContainer.invert(a,t),this._arrows.forEach((e=>{const t=e.point;if(e.setVis(!t.isNull)){const s=r.getPos(h,t.xValue),d=u-l.getPos(o,t.yValue);let c=n+t.angleValue*p;_&&(c=180-c),t.xPos=a?u+l.getPos(o,t.yValue):s,t.yPos=a?h-r.getPos(h,t.xValue):d,e.trans(s,d),e.layout(i,c,g)}}))}_runShowEffect(e){e&&d.grow(this)}_doViewRateChanged(e){this._renderSeries(this.width,this.height)}getPointsAt(e,t){return[]}$_prepareArrows(e,t){this._arrows.prepare(t.length,((s,n)=>{const i=s.point=t[n];this._setPointStyle(s,e,i)}))}}function x(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(V),e.SeriesView.register([V,y]))}export{V as VectorSeries,x as default};