UNPKG

realmap

Version:

Wooritech map chart component library

8 lines (6 loc) 3.65 kB
/** * RealMap Feature v1.1.6 * Copyright (C) 2023-2026 WooriTech Inc. * All Rights Reserved. */ import{extend as e,DataPointLabel as t,FeatureSeriesType as s,CoordBaseSeries as r,ValueSeries as o,isObject as i,copyObj as n,ColorRanger as l,Color as a,isArray as c,ValuePoint as u,SeriesView as d,PointViewPool as h,SeriesAnimation as _,PointElement as p}from"./index.mjs";class g extends u{_readObject(e,t){super._readObject(e,t),this.value=t.value}}class f extends g{_readObject(e,t){super._readObject(e,t),this.polygon=c(t.polygon)?t.polygon:[]}}class m extends t{}m.defaults=e(t.defaults,{visible:!1});class P extends o{get color(){return this._colorObj}getValueRange(){return{min:this._minValue,max:this._maxValue}}_createLabel(e){return new m(e)}_doApply(e){super._doApply(e)}needMapScale(){return!0}getRangedColor(e){var t;if(!isNaN(e.value)){const s=this._colorRanger||(null===(t=this.chart.getColorScale(this._op.colorScale))||void 0===t?void 0:t.getRanger());return null==s?void 0:s.getColor(this._minValue,this._maxValue,e.value,this._colorObj)}}followTooltipPointer(){return!0}getLegendSources(e,t){return this._points.count>0&&super.getLegendSources(e,t)}_createPoint(e){var t;null!==(t=e.type)&&void 0!==t||this._op.featureType;return new f(e)}_prepareRender(){super._prepareRender()}_doPrepareRender(e,t){super._doPrepareRender(e,t);const s=this._visPoints,{min:r,max:o}=this._calcMinMax(s);if(this._minValue=r,this._maxValue=o,i(t.colorRange)){const e=n(t.colorRange);isNaN(e.minValue)&&(e.minValue=r),isNaN(e.maxValue)&&(e.maxValue=o),this._colorRanger=new l(e)}else this._colorRanger=null}_doLoadPoints(e){super._doLoadPoints(e)}setCalcedColor(e,t){super.setCalcedColor(e,t),this._colorObj=new a(this._calcedColor),this._color=this._colorObj?this._colorObj.toString():null}getColorScale(){return this._op.colorScale}}P.type=s,P.defaults=e(r.defaults,{});const C="rm-feature-series-id-";class b extends p{static idClass(e){return C+e.id}static getId(e){for(const t of Array.from(e.classList))if(t.startsWith(C))return t.substring(21)}render(e,t,s){e!==this.model&&(e instanceof f&&this.$_renderArea(e,t),this.model=e),s&&this.dom.classList.add(b.idClass(e))}reset(){}prepare(){this._checkStatic()}$_renderArea(e,t){const s=e.polygon.map((e=>t.project(e)));let r=s.length>0?`M${s[0][0]} ${s[0][1]}`:"";if(s.length>1){const e=[];for(let t=1;t<s.length;t++)e.push(s[t][0],s[t][1]);r+="L "+e.join(" ")+"Z"}this.setPath(r)}}class y extends d{constructor(e){super(e,"rm-feature-series",!0,!1),this._features={},this._featurePool=new h(this._pointContainer,b)}featureOfDom(e){}needClip(){return!0}_getPointPool(){return this._featurePool}_setModelColor(e){this._pointContainer.setFill(e)}_setPointColor(e,t){e.setFill(t)}_doPrepeare(e,t,s){const r=this._visPoints;this._featurePool.prepare(r.length,((e,s)=>{const o=e.point=r[s];this._setPointStyle(e,t,o),e.internalSetStyle("vectorEffect","non-scaling-stroke"),e.prepare()}))}_doRender(e,t){this.$_layoutFeatures(e,t)}_doReset(){this._featurePool.forEach((e=>{e.visible&&e.reset()}))}_doPointerMoved(e,t,s){return!0}_doPointClicked(e){}_runShowEffect(e){e&&_.grow(this)}_doViewRateChanged(e){this.$_layoutFeatures(this.width,this.height)}$_layoutFeatures(e,t){const s=this.chart(),r=s.isDirty;s.body;const o=this.model;o.options;const i=s.getProjection(),n=this._features={};o.pointLabel,this._labelViews(),this._scale,this._featurePool.forEach(((e,t)=>{const s=e.point;n[s.id]=e,e.setVisible(!s.isNull)&&e.render(s,i,r)}))}}function S(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(P),e.SeriesView.register([P,y]))}export{P as FeatureSeries,S as default};