realmap
Version:
Wooritech map chart component library
8 lines (6 loc) • 5.17 kB
JavaScript
/**
* RealMap Feature v1.0.11
* Copyright (C) 2023-2025 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 o(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var r=o(t);class i extends t.ValuePoint{_readObject(e,t){super._readObject(e,t),this.center=t.center,this.value=t.value}}class s extends t.DataPointLabel{}s.defaults=t.extend(t.DataPointLabel.defaults,{hoverColor:"white"});class a extends t.ValueSeries{get areaCount(){return this._map.areaCount}get detail(){return this._detail}get color(){return this._colorObj}getValueRange(){return{min:this._minValue,max:this._maxValue}}_createLabel(e){return new s(e)}_doApply(e){t.isObject(e.detail)?this._detail||(this._detail=new a(this.chart)):e.hasOwnProperty("detail")&&(this._detail=null),super._doApply(e)}needMapScale(){return!0}getRangedColor(e){var t;if(!isNaN(e.value)){const o=this._colorRanger||(null===(t=this.chart.getColorScale(this._op.colorScale))||void 0===t?void 0:t.getRanger());return null==o?void 0:o.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){return new i(e)}_prepareRender(){super._prepareRender()}_doPrepareRender(e,o){super._doPrepareRender(e,o);const r=this._visPoints,{min:i,max:s}=this._calcMinMax(r);if(this._minValue=i,this._maxValue=s,t.isObject(o.colorRange)){const e=t.copyObj(o.colorRange);isNaN(e.minValue)&&(e.minValue=i),isNaN(e.maxValue)&&(e.maxValue=s),this._colorRanger=new t.ColorRanger(e)}else this._colorRanger=null}_doLoadPoints(e){this._useMapData&&(e=this._map._internalAreas().map((e=>({id:e.id,name:e.name})))),super._doLoadPoints(e),this._map}setCalcedColor(e,o){super.setCalcedColor(e,o),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.ValueSeries.defaults,{selectable:!1,detailZoom:250});const l="rm-map-series-id-";class n 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(17)}constructor(e){super(e)}render(e,t,o){const r=this.model,i=!this.point||this.point.isNull;e!==r&&this.setPath((this.model=e).path),o&&(this.setBoolData("null",i),i&&t&&this.internalSetStyleOrClass(t),this.dom.classList.add(n.idClass(e)))}reset(){this.model=null}}class h extends t.SeriesView{constructor(e){super(e,"rm-feature-series"),this._areas={},this._areaPool=new t.PointViewPool(this._pointContainer,n)}get hoverArea(){return this._hoverArea}set hoverArea(e){var o,r;const i=this._hoverArea;if(e!==i){const s=this.model;if(i&&(i.setBoolData(t.SeriesView.DATA_HOVER,!1),i.point&&(null===(o=this._labelContainer.get(i.point,0))||void 0===o||o._text.setBoolData(t.SeriesView.DATA_HOVER,!1))),e&&!e.point&&(e=void 0),this._hoverArea=e,e){const o=this.model.options,i=document.querySelector(".rm-root");let s=o.hoverColor,a=this.model.pointLabel.options.hoverColor;!s&&t.isObject(o.hoverStyle)&&(s=o.hoverStyle.fill),i.style.setProperty("--map-series-hover-fill",s||""),i.style.setProperty("--map-series-hover-label-fill",a||""),e.setBoolData(t.SeriesView.DATA_HOVER,!0),e.point&&(null===(r=this._labelContainer.get(e.point,0))||void 0===r||r._text.setBoolData(t.SeriesView.DATA_HOVER,!0))}e!=i&&s.chart._hoverAreaChanged(s,null==e?void 0:e.model,null==i?void 0:i.model)}}areaOfDom(e){let t=e;for(;t;){if(t.classList.contains("rm-point")){const e=n.getId(t);if(e)return this._areas[e];break}t=t.parentElement}}_getPointPool(){return this._areaPool}_setModelColor(e){this._pointContainer.setFill(e)}_setPointColor(e,t){e.setFill(t)}_doPrepeare(e,t,o){this._second;const r=t.options.bringToFront?[]:null;this._areaPool.prepare(t.areaCount,((e,t)=>{})),r&&r.length!==t.areaCount&&r.forEach((e=>{e.parent.moveToLast(e)}))}_doRender(e,t){this.$_layoutAreas(e,t)}_doReset(){this._areaPool.forEach((e=>{e.visible&&e.reset()}))}_doPointerMoved(e,t,o){const r=this.areaOfDom(o);return this.hoverArea=r,!0}_doPointClicked(e){this.model.chart._areaClicked(this.model,e.model)}_runShowEffect(e){e&&t.SeriesAnimation.grow(this)}_doViewRateChanged(e){this.$_layoutAreas(this.width,this.height)}$_layoutAreas(e,t){const o=this.chart(),r=this._second;o.isDirty,o.body;const i=this.model;i.options,o.getProjection(r),this._areas={},i.pointLabel,this._labelViews(),this._scale,this._areaPool.forEach(((e,t)=>{}))}}function d(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(a),e.SeriesView.register([a,h]))}d(r),e.FeatureSeries=a,e.default=d,Object.defineProperty(e,"__esModule",{value:!0})}));