MCPcopy
hub / github.com/apache/echarts / MapSeries

Class MapSeries

src/chart/map/MapSeries.ts:117–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115export const SERIES_TYPE_MAP = 'map';
116
117class MapSeries extends SeriesModel<MapSeriesOption> implements RoamHostModel {
118
119 static readonly type = 'series.' + SERIES_TYPE_MAP;
120 readonly type = MapSeries.type;
121
122 static dependencies = ['geo'];
123
124 static layoutMode = 'box' as const;
125
126 coordinateSystem: Geo;
127
128 // -----------------
129 // Injected outside
130 originalData: SeriesData;
131 seriesGroup: MapSeriesGroup | NullUndefined;
132
133
134 getInitialData(this: MapSeries, option: MapSeriesOption): SeriesData {
135 const data = createSeriesDataSimply(this, {
136 coordDimensions: ['value'],
137 encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
138 });
139 const dataNameIndexMap = zrUtil.createHashMap<number>();
140 const toAppendItems: MapDataItemOption[] = [];
141
142 for (let i = 0, len = data.count(); i < len; i++) {
143 const name = data.getName(i);
144 dataNameIndexMap.set(name, i);
145 }
146
147 const geoSource = geoSourceManager.load(this.getMapType(), this.option.nameMap, this.option.nameProperty);
148 zrUtil.each(geoSource.regions, function (region) {
149 const name = region.name;
150 const dataNameIdx = dataNameIndexMap.get(name);
151 // apply specified echarts style in GeoJSON data
152 const specifiedGeoJSONRegionStyle = (region as GeoJSONRegion).properties
153 && (region as GeoJSONRegion).properties.echartsStyle;
154 let dataItem: MapDataItemOption;
155 if (dataNameIdx == null) {
156 dataItem = { name: name };
157 toAppendItems.push(dataItem);
158 }
159 else {
160 dataItem = data.getRawDataItem(dataNameIdx) as MapDataItemOption;
161 }
162 specifiedGeoJSONRegionStyle && zrUtil.merge(dataItem, specifiedGeoJSONRegionStyle);
163 });
164
165 // Complete data with missing regions. The consequent processes (like visual
166 // map and render) can not be performed without a "full data". For example,
167 // find `dataIndex` by name.
168 data.appendData(toAppendItems);
169
170 return data;
171 }
172
173 /**
174 * If no host geo model, return null, which means using a

Callers

nothing calls this directly

Calls 5

getNameMethod · 0.80
getRegionMethod · 0.80
getCenterMethod · 0.80
getDataMethod · 0.65
dataToPointMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…