jayzhou2309 opened a new pull request, #21767:
URL: https://github.com/apache/echarts/pull/21767
<!-- Please fill in the following information to help us review your PR more
efficiently. -->
## Brief Information
This pull request is in the type of:
- [x] bug fixing
- [ ] new feature
- [ ] others
### What does this PR do?
Let a map series read a `dataset` in `seriesLayoutBy: 'row'`, and keep
region names when a dataset leaves some regions out.
### Fixed issues
- #21520: Error in "map" chart with seriesLayoutBy: 'row'
## Details
### Before: What was the problem?
`MapSeries.getInitialData` adds every GeoJSON region that has no data item
by calling `data.appendData([{name}, ...])`, even when that list is empty. Two
dataset cases broke:
- `seriesLayoutBy: 'row'`: the `arrayRows` row-layout data provider throws
`Do not support appendData when set seriesLayoutBy: "row".`, so `setOption`
fails.
- `seriesLayoutBy: 'column'` (the default): the `{name}` objects get pushed
into the user's `dataset.source` rows. The name is then read from index 0 of an
object, so every missing region gets the name `''`, and the dataset array is
mutated.
### After: How does it behave after the fixing?
For a dataset source, the missing regions go to the store with
`data.appendValues([], names)`, which adds the names without touching the data
provider. For `series.data` (source format `original`), the code still calls
`appendData` with the `{name}` items, so GeoJSON `properties.echartsStyle`
still applies to regions missing from the data.
A regression test in `test/ut/spec/series/map.test.ts` covers both layouts
with one region missing from the dataset:
- Before the fix: 2 of 2 fail. The row test throws the error above. The
column test gets `{"": NaN}` where it expects `{C: NaN}`.
- After the fix: 2 of 2 pass.
- Full unit suite (`npm test`): 195 of 196 pass. The one failure, `util/time
› roundTime_locale`, depends on the machine's locale and fails the same way
without this change.
- `npx tsc --noEmit` and `eslint` on the changed files are clean.
Not verified: rendering in a browser. The test checks the series data (names
and values), which the map view and tooltip read.
## Document Info
One of the following should be checked.
- [x] This PR doesn't relate to document changes
- [ ] The document should be updated later
- [ ] The document changes have been made in apache/echarts-doc#xxx
## Misc
### Security Checking
- [ ] This PR uses security-sensitive Web APIs.
<!-- PLEASE CHECK IT AGAINST:
<https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors>
-->
### ZRender Changes
- [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
### Related test cases or examples to use the new APIs
`test/ut/spec/series/map.test.ts`
### Merging options
- [x] Please squash the commits into a single one when merging.
### Other information
#### AI disclosure
An AI agent (Claude Code) reproduced this issue, wrote the fix and the test,
and ran these checks: `npx jest --config test/ut/jest.config.cjs
test/ut/spec/series/map.test.ts` before and after the fix, `npm test`, `npx tsc
--noEmit`, and `npx eslint src/chart/map/MapSeries.ts
test/ut/spec/series/map.test.ts`.
---
<!-- oss-agent -->
<sub>🤖 Written and posted by an AI agent (Claude Code) on behalf of
@jayzhou2309.</sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]