schizophrenicmaniac opened a new pull request, #21860:
URL: https://github.com/apache/echarts/pull/21860
## Brief Information
This pull request is in the type of:
- [x] bug fixing
- [ ] new feature
- [ ] others
### What does this PR do?
Makes polar bar labels use the new layout for rotation and position when
existing bars are updated with `setOption`.
### Fixed issues
- #21859: Polar bar label rotation is computed from the previous layout
after setOption
Fixes #21859
## Details
### Before: What was the problem?
In the update branch of `BarView._renderNormal`, `updateStyle()` runs before
`updateProps(el, { shape: layout })`. `setSectorTextRotation` read the angles
from `el.shape`, so bars that already existed kept the label rotation of their
old angles. This happened when more categories were added to `angleAxis`, when
only the data changed with the category on `radiusAxis`, or when the category
axis moved between the two axes.
Also, `calculateTextPosition` was only set in `createPolarBar`. When the
category axis moved between `radiusAxis` and `angleAxis` with `notMerge: true`,
labels at `insideStart`, `insideEnd`, `start` and `end` kept the old
radial/angle mapping and were placed for the wrong orientation.
### After: How does it behave after the fixing?
`setSectorTextRotation` accepts an optional target shape, and `updateStyle`
passes the new layout to it. `calculateTextPosition` is now set in
`updateStyle`, so it is refreshed on every update with the current mapping.
After `setOption`, labels match a chart created directly with the final option.
I added unit tests in `test/ut/spec/series/bar.test.ts`. They compare label
rotation and position after an update against a freshly created chart, for the
cases above.
## 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.
### 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 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]