From 00ee0a86cf5c1ca3e41696a1c7f5e7766c6fbadf Mon Sep 17 00:00:00 2001 From: Jay Zhou <190699450+jayzhou2309@users.noreply.github.com> Date: Tue, 29 Sep 2026 02:33:40 +0800 Subject: [PATCH 1/2] test(map): cover map series dataset layouts with missing regions Co-Authored-By: Claude Opus 5.5 --- test/ut/spec/series/map.test.ts | 85 +++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 test/ut/spec/series/map.test.ts diff --git a/test/ut/spec/series/map.test.ts b/test/ut/spec/series/map.test.ts new file mode 100644 index 0000000000..b7f73ea7f3 --- /dev/null +++ b/test/ut/spec/series/map.test.ts @@ -0,0 +1,85 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + + +import { registerMap } from '../../../../src/echarts'; +import { GeoJSON } from '../../../../src/coord/geo/geoTypes'; +import { createChart } from '../../core/utHelper'; + + +describe('map', function () { + + function square(name: string, x: number): GeoJSON['features'][number] { + return { + type: 'Feature', + properties: { name }, + geometry: { + type: 'Polygon', + coordinates: [[[x, 0], [x + 1, 0], [x + 1, 1], [x, 1], [x, 0]]] + } + }; + } + + registerMap('map_test_layout', { + type: 'FeatureCollection', + features: [square('A', 0), square('B', 1), square('C', 2)] + }); + + function getValuesByName(seriesLayoutBy: 'row' | 'column', source: (string | number)[][]) { + const chart = createChart(); + try { + chart.setOption({ + animation: false, + dataset: { source }, + series: [{ + type: 'map', + map: 'map_test_layout', + seriesLayoutBy, + encode: { itemName: 0, value: 1 } + }] + }); + const data = (chart as any).getModel().getSeriesByIndex(0).getData(); + const valueDim = data.mapDimension('value'); + const result: Record = {}; + data.each(function (idx: number) { + result[data.getName(idx)] = data.get(valueDim, idx); + }); + return result; + } + finally { + chart.dispose(); + } + } + + it('should read dataset in column layout and complete missing regions', function () { + expect(getValuesByName('column', [ + ['name', 'val'], + ['A', 10], + ['B', 20] + ])).toEqual({ A: 10, B: 20, C: NaN }); + }); + + it('should read dataset in row layout and complete missing regions', function () { + expect(getValuesByName('row', [ + ['name', 'A', 'B'], + ['val', 10, 20] + ])).toEqual({ A: 10, B: 20, C: NaN }); + }); + +}); From 99b0b966b995e5efeb9d7961adea01c228807bf2 Mon Sep 17 00:00:00 2001 From: Jay Zhou <190699450+jayzhou2309@users.noreply.github.com> Date: Tue, 29 Sep 2026 02:34:48 +0800 Subject: [PATCH 2/2] fix(map): support dataset with seriesLayoutBy row in map series. close #21520 MapSeries completed its data with regions missing from it by appending {name} items to the data provider. A dataset with seriesLayoutBy 'row' throws on any append, and an arrayRows dataset in column layout read the appended objects as rows, so those regions lost their names. Append only names to the store for dataset sources and keep the item append for series.data, which carries GeoJSON echartsStyle. Co-Authored-By: Claude Opus 5.5 --- src/chart/map/MapSeries.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/chart/map/MapSeries.ts b/src/chart/map/MapSeries.ts index b41f8c682d..90dc155168 100644 --- a/src/chart/map/MapSeries.ts +++ b/src/chart/map/MapSeries.ts @@ -37,7 +37,8 @@ import { CallbackDataParams, ComponentOnCalendarOptionMixin, ComponentOnMatrixOptionMixin, - RoamHostModel + RoamHostModel, + SOURCE_FORMAT_ORIGINAL } from '../../util/types'; import { Dictionary, NullUndefined } from 'zrender/src/core/types'; import GeoModel, { GeoCommonOptionMixin, GeoItemStyleOption } from '../../coord/geo/GeoModel'; @@ -165,7 +166,14 @@ class MapSeries extends SeriesModel implements RoamHostModel { // Complete data with missing regions. The consequent processes (like visual // map and render) can not be performed without a "full data". For example, // find `dataIndex` by name. - data.appendData(toAppendItems); + if (this.getSource().sourceFormat === SOURCE_FORMAT_ORIGINAL) { + data.appendData(toAppendItems); + } + else { + // A dataset can not hold `{name}` items, and `seriesLayoutBy: 'row'` + // can not be appended at all, so only add names to the store. + data.appendValues([], zrUtil.map(toAppendItems, item => item.name as string)); + } return data; }