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

[Question]图例可能会有多行时,如何避免图形与图例重叠? #16912

Open
xmdong opened this issue Apr 19, 2022 · 12 comments
Open
Labels
enhancement pending We are not sure about whether this is a bug/new feature. topic: legend waiting-for: community
Milestone

Comments

@xmdong
Copy link

xmdong commented Apr 19, 2022

Version

5.3.0

Link to Minimal Reproduction

No response

Steps to Reproduce

image

Current Behavior

因为需求关系,这块不能使用scroll类型图例,并且由于图例数量不确定,没法给图形设置一个合适的top值,导致图例与图形可能重叠

Expected Behavior

能不能实现图例把图形挤下去的效果?或者能不能获取到图例的高度,这样我就可以给图形设置一个合适的top值。

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

@xmdong xmdong added the bug label Apr 19, 2022
@echarts-bot echarts-bot bot added pending We are not sure about whether this is a bug/new feature. waiting-for: community labels Apr 19, 2022
@echarts-bot
Copy link

echarts-bot bot commented Apr 19, 2022

@xmdong It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

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

BODY

Version

5.3.0

Link to Minimal Reproduction

No response

Steps to Reproduce

image

Current Behavior

Because of the demand, the scroll type legend cannot be used in this piece, and because the number of legends is uncertain, it is impossible to set a suitable top value for the graph, resulting in the legend and the graph may overlap.

Expected Behavior

Is it possible to achieve the effect of the legend squeezing the graphics down? Or is it possible to get the height of the legend so that I can set a suitable top value for the graph.

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

@Ovilia
Copy link
Contributor

Ovilia commented Apr 20, 2022

目前没有很好的办法,只能根据图形数量大致估计一下,然后手动设置 grid.top 来调整

@jiawulin001
Copy link
Member

I think this question shall be solved by a similar way as #16880, where grid is adjusted to accommodate too long labels.
If we can find bounding rect of labels, we can adjust the size of grid to save space for legends too. I might try submitting a PR to do so.

@yswang0927
Copy link

图例多行显示时,grid.top 的值应该自适应的,目前靠估算修改 top 值是不合理的,体验很差。
ECharts功能很强,但是不少细节处理的很糟糕,例如:

  1. X轴 Label 标签太长不能智能处理。
  2. Y轴,配置了 grid.containLabel=true,即使配置不显示Y轴,左侧还是保留了containLabel=true计算出来的空白。
  3. 图例多行展示和下面的图表重叠

@xmdong
Copy link
Author

xmdong commented Apr 28, 2022

我现在的解决办法如下(使用react hooks),大体思路就是渲染完成后通过echartInstance实例获取到legend高度,然后根据高度重新设置top再渲染一次
image

@wuh
Copy link

wuh commented May 25, 2022

这个需求实在是太频繁了,改变组件大小等很多情况都会导致图例显示换行,需要提供一个智能或可编程的办法,总是用重渲染的方式实在是显得有些low。 @Ovilia

@KID-1912
Copy link

@xmdong 这确实一个有效的解决方案

@hanaTsuk1
Copy link

有配置动画 还是用rendered事件 不然要等动画响应完了才改变高度 legend和图表叠在一起了

@hockor
Copy link

hockor commented May 29, 2023

这个问题真的需要解决下啊,太影响体验了吧,而且 x/y 轴 的nameLocation = "middle" 时如果设置了axisLabel的旋转角度,也会有这个重叠的问题

@akiozhang
Copy link

遇到相同的问题,因需求,不确定series数组中包含多少数据组,期望通过滚动条在底部有固定高度全量展示,目前的legend设置vertical后宽度设置失效 @Ovilia

@dev-orange
Copy link

2024年了,这个问题官方有什么好的解法么?同遇到这个问题

@shenxiang216
Copy link

有人解决吗?2024年了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pending We are not sure about whether this is a bug/new feature. topic: legend waiting-for: community
Projects
None yet
Development

No branches or pull requests