Skip to content

Conversation

quinnsu
Copy link

@quinnsu quinnsu commented Jul 9, 2025

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Fixed issues

[Question] When the legend may have multiple lines, how do I avoid overlapping graphics with the legend?
#16912

Details

Before: What was the problem?

When legends contain many items, they can grow beyond the available container space and overlap with the main chart area (grid, radar, etc.).

The current behavior calculates maxHeight as containerHeight - bottom - verticalMargin - top, but doesn't enforce any upper limit when users specify a height constraint.

image

After: How does it behave after the fixing?

When legend.height is specified, the legend will automatically scale down if its natural height exceeds the specified threshold.
auto scale

image

Document Info

One of the following should be checked.

  • 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

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

Test file created: test/legend-height-formats.html

Others

Merging options

  • Please squash the commits into a single one when merging.

Other information

I'm not sure if this is the best approach to solve this problem, and I'm happy to iterate and improve based on your feedback and suggestions. Open to alternative solutions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant