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

Function mapSymbolLayout

src/chart/map/mapSymbolLayout.ts:30–80  ·  view source on GitHub ↗
(ecModel: GlobalModel)

Source from the content-addressed store, hash-verified

28export const mapSymbolLayoutStageHandler = createSimpleOverallStageHandler(SERIES_TYPE_MAP, mapSymbolLayout);
29
30function mapSymbolLayout(ecModel: GlobalModel) {
31
32 each(buildAllMapSeriesGroups(ecModel), function (mapSeriesGroup, groupKey) {
33 if (!getMainMapSeries(mapSeriesGroup) || !mapSeriesGroupHasOwnGeo(groupKey)) {
34 // map series on separate geo components only provide "choropleth map", but symbols are ignored.
35 return;
36 }
37
38 const mapSymbolOffsets = {} as Dictionary<number>;
39
40 each(mapSeriesGroup.f, function (subMapSeries) {
41 const geo = subMapSeries.coordinateSystem;
42 const data = subMapSeries.originalData;
43
44 if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) {
45 data.each(data.mapDimension('value'), function (value, idx) {
46 const name = data.getName(idx);
47 const region = geo.getRegion(name);
48
49 // If input series.data is [11, 22, '-'/null/undefined, 44],
50 // it will be filled with NaN: [11, 22, NaN, 44] and NaN will
51 // not be drawn. So here must validate if value is NaN.
52 if (!region || isNaN(value as number)) {
53 return;
54 }
55
56 const offset = mapSymbolOffsets[name] || 0;
57
58 const point = geo.dataToPoint(region.getCenter());
59
60 mapSymbolOffsets[name] = offset + 1;
61
62 data.setItemLayout(idx, {
63 point: point,
64 offset: offset
65 });
66 });
67 }
68 });
69
70 // Show label of those region not has legendIcon (which is offset 0)
71 const data = getMainMapSeries(mapSeriesGroup).getData();
72 data.each(function (idx) {
73 const name = data.getName(idx);
74 const layout = data.getItemLayout(idx) || {};
75 layout.showLabel = !mapSymbolOffsets[name];
76 data.setItemLayout(idx, layout);
77 });
78
79 });
80}

Callers

nothing calls this directly

Calls 15

buildAllMapSeriesGroupsFunction · 0.90
getMainMapSeriesFunction · 0.90
mapSeriesGroupHasOwnGeoFunction · 0.90
getComponentMethod · 0.80
mapDimensionMethod · 0.80
getNameMethod · 0.80
getRegionMethod · 0.80
getCenterMethod · 0.80
setItemLayoutMethod · 0.80
getItemLayoutMethod · 0.80
dataToPointMethod · 0.65
getDataMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…