realmap
Version:
Wooritech map chart component library
8 lines (6 loc) • 4.17 kB
JavaScript
/**
* RealMap Feature v1.1.6
* Copyright (C) 2023-2026 WooriTech Inc.
* All Rights Reserved.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("realmap")):"function"==typeof define&&define.amd?define(["exports","realmap"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RealMapfeature={},e.RealMap)}(this,(function(e,t){"use strict";function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=r(t);class s extends t.ValuePoint{_readObject(e,t){super._readObject(e,t),this.value=t.value}}class i extends s{_readObject(e,r){super._readObject(e,r),this.polygon=t.isArray(r.polygon)?r.polygon:[]}}class n extends t.DataPointLabel{}n.defaults=t.extend(t.DataPointLabel.defaults,{visible:!1});class a extends t.ValueSeries{get color(){return this._colorObj}getValueRange(){return{min:this._minValue,max:this._maxValue}}_createLabel(e){return new n(e)}_doApply(e){super._doApply(e)}needMapScale(){return!0}getRangedColor(e){var t;if(!isNaN(e.value)){const r=this._colorRanger||(null===(t=this.chart.getColorScale(this._op.colorScale))||void 0===t?void 0:t.getRanger());return null==r?void 0:r.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 i(e)}_prepareRender(){super._prepareRender()}_doPrepareRender(e,r){super._doPrepareRender(e,r);const o=this._visPoints,{min:s,max:i}=this._calcMinMax(o);if(this._minValue=s,this._maxValue=i,t.isObject(r.colorRange)){const e=t.copyObj(r.colorRange);isNaN(e.minValue)&&(e.minValue=s),isNaN(e.maxValue)&&(e.maxValue=i),this._colorRanger=new t.ColorRanger(e)}else this._colorRanger=null}_doLoadPoints(e){super._doLoadPoints(e)}setCalcedColor(e,r){super.setCalcedColor(e,r),this._colorObj=new t.Color(this._calcedColor),this._color=this._colorObj?this._colorObj.toString():null}getColorScale(){return this._op.colorScale}}a.type=t.FeatureSeriesType,a.defaults=t.extend(t.CoordBaseSeries.defaults,{});const l="rm-feature-series-id-";class u extends t.PointElement{static idClass(e){return l+e.id}static getId(e){for(const t of Array.from(e.classList))if(t.startsWith(l))return t.substring(21)}render(e,t,r){e!==this.model&&(e instanceof i&&this.$_renderArea(e,t),this.model=e),r&&this.dom.classList.add(u.idClass(e))}reset(){}prepare(){this._checkStatic()}$_renderArea(e,t){const r=e.polygon.map((e=>t.project(e)));let o=r.length>0?`M${r[0][0]} ${r[0][1]}`:"";if(r.length>1){const e=[];for(let t=1;t<r.length;t++)e.push(r[t][0],r[t][1]);o+="L "+e.join(" ")+"Z"}this.setPath(o)}}class c extends t.SeriesView{constructor(e){super(e,"rm-feature-series",!0,!1),this._features={},this._featurePool=new t.PointViewPool(this._pointContainer,u)}featureOfDom(e){}needClip(){return!0}_getPointPool(){return this._featurePool}_setModelColor(e){this._pointContainer.setFill(e)}_setPointColor(e,t){e.setFill(t)}_doPrepeare(e,t,r){const o=this._visPoints;this._featurePool.prepare(o.length,((e,r)=>{const s=e.point=o[r];this._setPointStyle(e,t,s),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,r){return!0}_doPointClicked(e){}_runShowEffect(e){e&&t.SeriesAnimation.grow(this)}_doViewRateChanged(e){this.$_layoutFeatures(this.width,this.height)}$_layoutFeatures(e,t){const r=this.chart(),o=r.isDirty;r.body;const s=this.model;s.options;const i=r.getProjection(),n=this._features={};s.pointLabel,this._labelViews(),this._scale,this._featurePool.forEach(((e,t)=>{const r=e.point;n[r.id]=e,e.setVisible(!r.isNull)&&e.render(r,i,o)}))}}function d(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(a),e.SeriesView.register([a,c]))}d(o),e.FeatureSeries=a,e.default=d,Object.defineProperty(e,"__esModule",{value:!0})}));