SahinurDEV opened a new pull request, #21790: URL: https://github.com/apache/echarts/pull/21790
## Brief Information This pull request is in the type of: - [x] bug fixing - [ ] new feature - [ ] others ### What does this PR do? Pie labels with `overflow: 'break'` and a `lineHeight` no longer get a background wider than the wrapped text. ### Fixed issues - #21710: Pie chart label background display is abnormal due to lineHeight ## Details ### Before: What was the problem? `constrainTextWidth` in `pie/labelLayout.ts` measures the wrapped text by temporarily clearing `backgroundColor`, setting the constraining `width`, and reading `label.getBoundingRect()`. But zrender also draws a background rect when `lineHeight` (or a border) is set, and that rect is sized to the constraining width, not the text. So with `lineHeight` set, the measured width was the available width, and the label background was stretched to it. With the half-donut from the issue (SSR, 600×400), background widths for the three labels were: | lineHeight | before | after | |---|---|---| | unset | 109 / 31.3 / 90 | 109 / 31.3 / 90 | | 14 | 137 / 31.3 / 112 | 109 / 31.3 / 90 | | 80 | 137 / **208** / 108 | 109 / 32 / 90 | ### After: How does it behave after the fixing? During the measurement, `lineHeight` and `borderWidth` are cleared along with `backgroundColor` (and restored afterwards), so the bounding box is the wrapped text only. Neither affects line wrapping or text width. Added `test/ut/spec/series/pie.test.ts`, which checks the background width equals the wrapped text width with no `lineHeight`, `14` and `80`. It fails without the change. Full `npm test` (195 tests), `npm run lint` and `npm run checktype` pass. ## Document Info - [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 - [x] 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]
