UNPKG

realmap

Version:

Wooritech map chart component library

8 lines (6 loc) 3.71 kB
/** * RealMap Track v1.1.6 * Copyright (C) 2023-2026 WooriTech Inc. * All Rights Reserved. */ import{extend as t,ChartItem as e,TrackSeriesType as s,Series as r,pickNum as i,DataPoint as n,isArray as o,SeriesView as a,PointViewPool as h,SeriesAnimation as l,PointElement as c,PolyLineElement as _,Dom as p,LayerElement as u,PathElement as d,_isIE as k}from"./index.mjs";class g extends n{_readObject(t,e){super._readObject(t,e),o(e.track)?this.track=this.$_parseTrack(e.track):o(e.coord)?this.track=this.coord:this.coord?this.track=[this.coord]:this.track=[]}_readArray(t,e){this.track=this.$_parseTrack(e)}$_parseTrack(t){const e=[];return t.forEach((t=>{o(t)?e.push([t[0],t[1]]):isNaN(t.lon)||isNaN(t.lat)||e.push([t.lon,t.lat])})),e}}class f extends e{}f.defaults=t(e.defaults,{});class P extends r{constructor(t){super(t),this._shape=t.getNextPointShape()}_doInit(t){super._doInit(t),t.outline=(this._outline=new f(this.chart))._init()}get outline(){return this._outline}getShape(){return this._op.shape||this._shape}getRadius(){return i(this._op.radius,P.defaults.radius)}needMapScale(){return!0}_createPoint(t){return new g(t)}_defLabelOff(){return 2}}P.type=s,P.defaults=t(r.defaults,{radius:3});class $ extends c{constructor(t){super(t,!0),this._points=[],this.add(this._line=new _(t)),p.setNoScale(this._line.dom),this.add(this._pointLayer=new u(t)),this.add(this._outline=new _(t,"rm-track-series-outline")),p.setNoScale(this._outline.dom)}prepare(t,e,s,r,i){const n=s.track,a=this._pts=[];if(o(n)){n.forEach((t=>{a.push(r.project(t))}));const t=this._pos=a[0].slice();a[0][0]=a[0][1]=0;for(let e=1;e<a.length;e++)a[e][0]=a[e][0]-t[0],a[e][1]=a[e][1]-t[1]}this.$_preparePoints(t,this._pointLayer,a)}render(t,e,s,r,i){const n=this._pts.slice(0,this._pts.length*i|0);this.$_renderLine(n,i),this.$_renderPoints(t,r,n,i),this.$_renderOutline(e.outline,n,i)}$_preparePoints(t,e,s){const r=this._points;for(;r.length<s.length;){const s=new d(t,"rm-track-series-point");p.setNoScale(s.dom),r.push(e.add(s))}for(;r.length>s.length;)r.pop().remove()}$_renderLine(t,e){this._line.setVisible(t.length>1)&&(this._line.setFill("none"),this._line.setLines(t,!1))}$_renderPoints(t,e,s,r){this._points.forEach(((r,i)=>{r.setVisible(i<s.length)&&(r.setPath(t(e,e)),r.transc(s[i]))}))}$_renderOutline(t,e,s){this._outline.setVisible(t.visible&&e.length>1)&&(this._outline.internalResetStyleOrClass(t._style),this._outline.setFill("none"),this._outline.setLines(e,!1))}}class S extends a{constructor(t){super(t,"rm-track-series",!1,!1),this._tracks=new h(this._pointContainer,$,"rm-track-series-track")}_getPointPool(){return this._tracks}_setPointColor(t,e){t.setColor(e)}_doPrepeare(t,e,s){s&&this.$_prepareTracks(t,e,e._visPoints)}_doRender(t,e){this.$_layoutTracks(this._getGrowRate())}_doReset(){}_runShowEffect(t){t&&l.grow(this)}_doViewRateChanged(t){this.$_layoutTracks(t)}runPointAddAnimation(t){}_legendColorProp(){return"stroke"}$_prepareTracks(t,e,s){e.options.shape;const r=s.length,i=!k,n=e.chart.getProjection();this._pointContainer.setStroke(e._runColor),this._pointContainer.setFill(e._runColor),this._tracks.prepare(r,((r,o)=>{const a=r.point=s[o];this._setPointStyle(r,e,a),r.prepare(t,e,a,n,i)}))}$_layoutTracks(t){const e=this.model,s=e.chart.getProjection();this._scaler;const r=this._scale;this._tracks.forEach(((i,n)=>{const o=i.point;if(i.setVisible(!o.isNull&&null!=s.getVisible(o.track[0]))){let[s,n]=i._pos;const h=a.getDrawer(e.getShape()),l=i._radius=e.getRadius();o.xPos=s,o.yPos=n,i.render(h,e,o,l/r,t),i.trans(s,n)}}))}}function w(t){(function(t){return t.Series&&t.SeriesView})(t)&&(t.Series.register(P),t.SeriesView.register([P,S]))}export{P as TrackSeries,w as default};