Repository navigation
Conversation
…d none. close apache#21862 When showBackground was turned on in an update, the update branch of the data diff created the background with the old data index, laid out in the new data. With fewer bars that index has no layout, so it returned null and updateProps threw "Cannot read properties of null (reading 'stopAnimation')", leaving the chart half-updated. When some old bars had backgrounds and others not, it read a missing one. The update branch now reuses the old background when there is one and otherwise creates one for the new index, and skips it when the bar has no layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief Information
This pull request is in the type of:
What does this PR do?
Creates a bar's background for the new data index when the old bar had none, so turning
showBackgroundon in an update no longer throws or leaves bars without a background.Fixed issues
showBackgroundis turned on in the same update that changes the categories #21862: Bar chart throws or loses some backgrounds whenshowBackgroundis turned on in an updateDetails
Before: What was the problem?
In
BarView._renderNormal, theupdatebranch of the data diff handled a missing background withcreateBackground(oldIndex). That function lays out the given index in the new data, so:createBackgroundreturnednull, andupdateProps(null, …)threwCannot read properties of null (reading 'stopAnimation'). The chart was left half-updated: no tracks, one bar missing, an extra bar drawn.oldBgEls.length !== 0sent the code tooldBgEls[oldIndex], which could beundefined.After: How does it behave after the fixing?
The update branch reuses
oldBgEls[oldIndex]when it exists. Otherwise it creates the background fornewIndex, 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 withshowBackground: true. The update must not throw, and there must be three bars, each with a background. Onmasterit 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);eslinton the changed files;tsc -p tsconfig.json --noEmit.Document Info
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
N.A.
Merging options
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