Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(text): not need fixed bounding box when contentWidth min than style.width #1091

Closed

Conversation

linghaoSu
Copy link

@linghaoSu linghaoSu commented Jul 24, 2024

When overflow is set and style.width is not empty, a fixed boundingBox is used, where the x value of the boundingBox is adjusted according to style.width.

zrender/src/graphic/Text.ts

Lines 604 to 614 in 247e119

el.setBoundingRect(new BoundingRect(
adjustTextX(subElStyle.x, style.width, subElStyle.textAlign as TextAlign),
adjustTextY(subElStyle.y, calculatedLineHeight, subElStyle.textBaseline as TextVerticalAlign),
/**
* Text boundary should be the real text width.
* Otherwise, there will be extra space in the
* bounding rect calculated.
*/
contentWidth,
calculatedLineHeight
));

However, when the width of the text is smaller than the set style.width, the boundingBox will be positioned to the left, as shown in the following figure.

image

2024-07-24.23.57.17.mov

fix apache/echarts#18306

@plainheart plainheart requested a review from pissang November 11, 2024 02:18
100pah added a commit that referenced this pull request Nov 16, 2024
memo info: This code used to be modified in commit bd2642e and bd2642e , where the `boundingRect.width` was modified from `style.width` to `innerWith` and then `outerWith`, but the `boundingRect.x` was not modified correspondingly. Related issue: apache/echarts#18306 . And #1091 located the problematic code successfully but the fix was not entirely correct.
100pah added a commit that referenced this pull request Nov 16, 2024
…lose apache/echarts#18306 . And #1091 located the problematic code successfully but the fix was not entirely correct.
@plainheart
Copy link
Collaborator

Thank you for your contribution! It was superseded by #1100.

@plainheart plainheart closed this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Overflow truncate breaks axis label click target position
2 participants