Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/label/labelStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ function setTokenTextStyle<TNuance extends TextCommonOptionNuanceBase>(
textStyle.borderColor = inheritColor;
}
}
// If height or width is set but no backgroundColor, set transparent background
// to ensure the box constraints are applied
if ((textStyle.height != null || textStyle.width != null) && textStyle.backgroundColor == null) {
textStyle.backgroundColor = 'transparent';
}
Comment on lines +685 to +689
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is the right way to fix the issue. As I mentioned earlier #21504 (comment), this behavior is likely intentional by design, but it did not account for cases where the text has explicit width, height, or padding. In such situations, the text background box should still be drawn, even when no background color is specified.
I would suggest either implementing the fix at the underlying ZRender, or simply not fixing this "bug" at all, since there is already a simple workaround to avoid the problem.

}

export function getFont(
Expand Down
384 changes: 384 additions & 0 deletions test/axis-label-height-without-bg.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.