Xnadir opened a new pull request, #21865:
URL: https://github.com/apache/echarts/pull/21865

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Creates a bar's background for the new data index when the old bar had none, 
so turning `showBackground` on in an update no longer throws or leaves bars 
without a background.
   
   ### Fixed issues
   
   - #21862: Bar chart throws or loses some backgrounds when `showBackground` 
is turned on in an update
   
   ## Details
   
   ### Before: What was the problem?
   
   In `BarView._renderNormal`, the `update` branch of the data diff handled a 
missing background with `createBackground(oldIndex)`. That function lays out 
the given index in the **new** data, so:
   
   - **With fewer bars after the update** (the issue's "All products" → "Top 
3"), the old index has no layout. `createBackground` returned `null`, and 
`updateProps(null, …)` threw `Cannot read properties of null (reading 
'stopAnimation')`. The chart was left half-updated: no tracks, one bar missing, 
an extra bar drawn.
   - **When some old bars had a background and others did not**, 
`oldBgEls.length !== 0` sent the code to `oldBgEls[oldIndex]`, which could be 
`undefined`.
   
   ### After: How does it behave after the fixing?
   
   The update branch reuses `oldBgEls[oldIndex]` when it exists. Otherwise it 
creates the background for `newIndex`, and it skips the background when the bar 
has no layout.
   
   New case in `test/ut/spec/series/bar.test.ts`: five bars without background, 
then the top three with `showBackground: true`. The update must not throw, and 
there must be three bars, each with a background. On `master` it fails with the 
TypeError.
   
   Ran locally:
   
   - `npx jest --config test/ut/jest.config.cjs test/ut/spec/series 
test/ut/spec/component test/ut/spec/api` (46 passed);
   - `eslint` on the changed files;
   - `tsc -p tsconfig.json --noEmit`.
   
   ## Document Info
   
   - [x] This PR doesn't relate to document changes
   
   ## Misc
   
   ### Security Checking
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   N.A.
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information
   
   This change was written with the help of Claude Code (AI). I reviewed it and 
ran the tests above.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to