Skip to content

fix: axisLabel.height should work without backgroundColor (#21504)#21505

Open
SakshamSinghal20 wants to merge 2 commits intoapache:masterfrom
SakshamSinghal20:axis
Open

fix: axisLabel.height should work without backgroundColor (#21504)#21505
SakshamSinghal20 wants to merge 2 commits intoapache:masterfrom
SakshamSinghal20:axis

Conversation

@SakshamSinghal20
Copy link

Summary

Fixes axisLabel.height property to work independently of backgroundColor.

Changes

  • Fixed conditional logic in axis label rendering
  • Height property now applies regardless of background color setting

Fixes #21504

@echarts-bot
Copy link

echarts-bot bot commented Jan 30, 2026

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

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.

To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: PR: doc ready, PR: awaiting doc, PR: doc unchanged

This message is shown because the PR description doesn't contain the document related template.

@SakshamSinghal20
Copy link
Author

@plainheart @100pah could you please review this at your convenience?

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-21505@a7194cc

Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

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

Please double check your test file. It shows nothing on my side. Make sure the test cases are created using npm run mktest axis-label-height-without-bg 3.

Please don't include FIX_SUMMARY.md.

The source code patch itself looks good to me. Thanks.

@SakshamSinghal20
Copy link
Author

Hi @Ovilia I have done what you asked for let me know if there is anything that i need to do.
Thank you,

Comment on lines +685 to +689
// 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';
}
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] The axisLabel.height property does not take effect when no background color is set

3 participants