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

Method getInitialData

src/chart/map/MapSeries.ts:134–171  ·  view source on GitHub ↗
(this: MapSeries, option: MapSeriesOption)

Source from the content-addressed store, hash-verified

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 9

getMapTypeMethod · 0.95
createSeriesDataSimplyFunction · 0.85
getNameMethod · 0.80
countMethod · 0.65
loadMethod · 0.65
appendDataMethod · 0.65
eachMethod · 0.45
getMethod · 0.45
getRawDataItemMethod · 0.45

Tested by

no test coverage detected