basb-cli
Version:
Blog as Second Brain!
2 lines (1 loc) • 5.92 kB
JavaScript
import{_ as e,b6 as t,b7 as o,k as a,j as i,aT as r,C as n,x as s,an as l,b8 as p,e as m,aK as u,ae as g,S as c,m as h,b9 as f,ba as d}from"./index.js";import{M as y,g as v,i as D}from"./install28.js";import{c as b}from"./createSeriesDataSimply.js";import"./roamHelper.js";import"./RoamController.js";import"./interactionMutex.js";import"./cursorHelper.js";var w=function(n){function s(){var e=null!==n&&n.apply(this,arguments)||this;return e.type=s.type,e}return e(s,n),s.prototype.render=function(e,t,o,a){if(!a||"mapToggleSelect"!==a.type||a.from!==this.uid){var i=this.group;if(i.removeAll(),!e.getHostGeoModel()){if(this._mapDraw&&a&&"geoRoam"===a.type&&this._mapDraw.resetForLabelLayout(),a&&"geoRoam"===a.type&&"series"===a.componentType&&a.seriesId===e.id)(r=this._mapDraw)&&i.add(r.group);else if(e.needsDrawMap){var r=this._mapDraw||new y(o);i.add(r.group),r.draw(e,t,o,this,a),this._mapDraw=r}else this._mapDraw&&this._mapDraw.remove(),this._mapDraw=null;e.get("showLegendSymbol")&&t.getComponent("legend")&&this._renderSymbols(e,t,o)}}},s.prototype.remove=function(){this._mapDraw&&this._mapDraw.remove(),this._mapDraw=null,this.group.removeAll()},s.prototype.dispose=function(){this._mapDraw&&this._mapDraw.remove(),this._mapDraw=null},s.prototype._renderSymbols=function(e,n,s){var l=e.originalData,p=this.group;l.each(l.mapDimension("value"),(function(n,s){if(!isNaN(n)){var m=l.getItemLayout(s);if(m&&m.point){var u=m.point,g=m.offset,c=new t({style:{fill:e.getData().getVisual("style").fill},shape:{cx:u[0]+9*g,cy:u[1],r:3},silent:!0,z2:8+(g?0:o+1)});if(!g){var h=e.mainSeries.getData(),f=l.getName(s),d=h.indexOfName(f),y=l.getItemModel(s),v=y.getModel("label"),D=h.getItemGraphicEl(d);a(c,i(y),{labelFetcher:{getFormattedLabel:function(t,o){return e.getFormattedLabel(d,o)}},defaultText:f}),c.disableLabelAnimation=!0,v.get("position")||c.setTextConfig({position:"bottom"}),D.onHoverStateChange=function(e){r(c,e)}}p.add(c)}}}))},s.type="map",s}(n),S=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.type,e.needsDrawMap=!1,e.seriesGroup=[],e.getTooltipPosition=function(e){if(null!=e){var t=this.getData().getName(e),o=this.coordinateSystem,a=o.getRegion(t);return a&&o.dataToPoint(a.getCenter())}},e}return e(o,t),o.prototype.getInitialData=function(e){for(var t=b(this,{coordDimensions:["value"],encodeDefaulter:s(l,this)}),o=p(),a=[],i=0,r=t.count();i<r;i++){var n=t.getName(i);o.set(n,!0)}var u=v.load(this.getMapType(),this.option.nameMap,this.option.nameProperty);return m(u.regions,(function(e){var t=e.name;o.get(t)||a.push(t)})),t.appendValues([],a),t},o.prototype.getHostGeoModel=function(){var e=this.option.geoIndex;return null!=e?this.ecModel.getComponent("geo",e):null},o.prototype.getMapType=function(){return(this.getHostGeoModel()||this).option.map},o.prototype.getRawValue=function(e){var t=this.getData();return t.get(t.mapDimension("value"),e)},o.prototype.getRegionModel=function(e){var t=this.getData();return t.getItemModel(t.indexOfName(e))},o.prototype.formatTooltip=function(e,t,o){for(var a=this.getData(),i=this.getRawValue(e),r=a.getName(e),n=this.seriesGroup,s=[],l=0;l<n.length;l++){var p=n[l].originalData.indexOfName(r),m=a.mapDimension("value");isNaN(n[l].originalData.get(m,p))||s.push(n[l].name)}return u("section",{header:s.join(", "),noHeader:!s.length,blocks:[u("nameValue",{name:r,value:i})]})},o.prototype.setZoom=function(e){this.option.zoom=e},o.prototype.setCenter=function(e){this.option.center=e},o.prototype.getLegendIcon=function(e){var t=e.icon||"roundRect",o=g(t,0,0,e.itemWidth,e.itemHeight,e.itemStyle.fill);return o.setStyle(e.itemStyle),o.style.stroke="none",t.indexOf("empty")>-1&&(o.style.stroke=o.style.fill,o.style.fill="#fff",o.style.lineWidth=2),o},o.type="series.map",o.dependencies=["geo"],o.layoutMode="box",o.defaultOption={z:2,coordinateSystem:"geo",map:"",left:"center",top:"center",aspectScale:null,showLegendSymbol:!0,boundingCoords:null,center:null,zoom:1,scaleLimit:null,selectedMode:!0,label:{show:!1,color:"#000"},itemStyle:{borderWidth:.5,borderColor:"#444",areaColor:"#eee"},emphasis:{label:{show:!0,color:"rgb(100,0,0)"},itemStyle:{areaColor:"rgba(255,215,0,0.8)"}},select:{label:{show:!0,color:"rgb(100,0,0)"},itemStyle:{color:"rgba(255,215,0,0.8)"}},nameProperty:"name"},o}(c);function M(e){var t={};e.eachSeriesByType("map",(function(e){var o=e.getHostGeoModel(),a=o?"o"+o.id:"i"+e.getMapType();(t[a]=t[a]||[]).push(e)})),m(t,(function(e,t){for(var o,a,i,r=(o=h(e,(function(e){return e.getData()})),a=e[0].get("mapValueCalculation"),i={},m(o,(function(e){e.each(e.mapDimension("value"),(function(t,o){var a="ec-"+e.getName(o);i[a]=i[a]||[],isNaN(t)||i[a].push(t)}))})),o[0].map(o[0].mapDimension("value"),(function(e,t){for(var r="ec-"+o[0].getName(t),n=0,s=1/0,l=-1/0,p=i[r].length,m=0;m<p;m++)s=Math.min(s,i[r][m]),l=Math.max(l,i[r][m]),n+=i[r][m];return 0===p?NaN:"min"===a?s:"max"===a?l:"average"===a?n/p:n}))),n=0;n<e.length;n++)e[n].originalData=e[n].getData();for(n=0;n<e.length;n++)e[n].seriesGroup=e,e[n].needsDrawMap=0===n&&!e[n].getHostGeoModel(),e[n].setData(r.cloneShallow()),e[n].mainSeries=e[0]}))}function N(e){var t={};e.eachSeriesByType("map",(function(o){var a=o.getMapType();if(!o.getHostGeoModel()&&!t[a]){var i={};m(o.seriesGroup,(function(t){var o=t.coordinateSystem,a=t.originalData;t.get("showLegendSymbol")&&e.getComponent("legend")&&a.each(a.mapDimension("value"),(function(e,t){var r=a.getName(t),n=o.getRegion(r);if(n&&!isNaN(e)){var s=i[r]||0,l=o.dataToPoint(n.getCenter());i[r]=s+1,a.setItemLayout(t,{point:l,offset:s})}}))}));var r=o.getData();r.each((function(e){var t=r.getName(e),o=r.getItemLayout(e)||{};o.showLabel=!i[t],r.setItemLayout(e,o)})),t[a]=!0}}))}function T(e){f(D),e.registerChartView(w),e.registerSeriesModel(S),e.registerLayout(N),e.registerProcessor(e.PRIORITY.PROCESSOR.STATISTIC,M),d("map",e.registerAction)}export{T as install};