-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
[5.0][FEATURE] Label enhancement and state transition #12911
Conversation
Thanks for your contribution! |
Congratulations! Your PR has been merged. Thanks for your contribution! 👍 |
The new label feature with hideOverlap is very cool!!! But in version 5.0.0-alpha.2 my bar chart has a small problem. My tooltip appears only when hovering over the bar itself. It disappears when hovering on the label (which is placed in the center of the bar). |
@zevero Hi, sorry for the late reply. |
Thank you @pissang for this great enhancement. I am afraid that I cannot get the |
Hello, grate feature!! Its suposed to work on GraphGL with forceAtlas2 too? I tried but nothing happened! |
|
5.0版本,设置labelLayout后,移动地图,label文字位置不动 |
@lifront 怎么设置的? |
@pissang 这是我的设置
|
@pissang 已经确认是问题了吗,目前有没有替代方案 |
@lifront 只能暂时不在地图上使用 labelLayout 配置 |
@pissang 好的,明白了,5.1.0大概啥时候上线 |
@pissang graph 的label支持绑定点击事件了么? |
[5.0][FEATURE] Label enhancement and state transition
Brief Information
This pull request introduces following main features:
labelLayout
for a more flexible label layout.labelLine
on all series.State transition feature is developed in this branch because it's related to label on many codes.
1. Better displayed labels.
It includes several strategies to make sure the labels are displayed nicely and neatly by default in most cases.
1) Smarter color strategy
It has better strategy to calculate the
fill
andstroke
color based on the color of underlying elements, background color and label position.Text inside the rect
Text outside
2) Smarter label placement in Pie.
Related issues: #6050
An extreme case from Gallery
Case from https://gallery.echartsjs.com/editor.html?c=xSkDzAue4G
Before:
After:
GIF to show how labels will be hidden or truncated when it's overlapped or overflow.
3) Overflow
Add
overflow
configuration. Which can betruncate
,break
,breakAll
.Truncate
Break
The difference between
'break'
and'breakAll'
isbreakAll
will break the word.2. Introduce
labelLayout
for a more flexible overall label layout.labelLayout
provides more abilities for developers to tweak the layout of the labels after it's originally positioned by the chart itself.It's available for all series.
Interface Defninition
Use cases of
labelLayout
1) Hide overlapped labels.
Usage
That's all.
📈 Line Chart
Related issue #8554
Before
After
📊 Bar
Related issue: #6514
Before
After
Graph
Overlapped labels are overlapped automatically when zooming out. The priority is based on the size of circle.
2) Align labels on top.
3) Align labels on right.
4) Adjust labelLine
If we wan't to move the labelLine under the text in pie. Like following:
Based on this callback, we can tweak the label position in a few lines. For example, add a gap between the line end and label.
5) Draggable label.
The labels can be dragged to a different position if users don't satisify the original layout. And the labelLine will be recalculated automatically.
3. Support
labelLine
on all series.Related issues: #11534
labelLine is very useful for guiding element to related labels when labels are moved far away, like the case of the aligned labels above.
1) Auto calculated labelLine points.
The points of labelLine are calculated based on the position of the label and shape of the element. To make sure the display of labelLine is nice and neat.
2) Support limiting labelLine angle
3) Optimizing smooth algorithm
4. State transition
It provides smoooth state transition when the mouse entered / leaved the element.
Before:
After:
Interface:
5. Other optimizations
Animation.
1) Pie animation optimization
Related issue: #12553
2) Bar animation optimization
Related issue: #12543
3) Use
cubicInOut
easing by defaultIntroduce dark mode.
The dark mode is inferenced from the background automatically by default. We can also specify it manually if we have an image background which echarts can't pick a color from.
As described above, the color of labels will be different in dark mode.
6. TODO
7. PS
Added rich text support in SVG rendering mode.