(ecModel: GlobalModel)
| 28 | export const mapSymbolLayoutStageHandler = createSimpleOverallStageHandler(SERIES_TYPE_MAP, mapSymbolLayout); |
| 29 | |
| 30 | function 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…