-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Fix legend item layout issue #5816
Conversation
eb26a7e
to
a1c8533
Compare
Does this fix also work in the case that there are three rows of labels? |
Yes, you can see animations in the fiddle and how it works when the legend box becomes narrow. |
Thanks @nagix |
@nagix some of these tests now fail on my machine, what is your dev environment? |
My environment is Mac OS. The cause of the failures is a floating point number error, correct? |
I'm not sure:
|
Firefox only (63.0.1), it works on Chrome |
Ah, I'm sure this is due to the difference in the font size. |
Any idea how to make these tests more stable? maybe by setting empty labels for each dataset or find a stable character to repeat, or ... |
The use of empty labels would be simplest. I will open a new PR for this. |
When
layout.padding
is specified, legend item layout goes wrong, and some items disappear or overlap with the chart.In the the following examples, I added a blue frame to the legend box and red frames to the legend item boxes to make it easier to understand each box's position.
Version 2.7.3: https://jsfiddle.net/nagix/dy1etr8h/
The legend item for the dataset 'G' disappears in the first chart, and it overlaps with the chart in the second chart.
This PR: https://jsfiddle.net/nagix/4b8utyLv/
In this PR, calculation for item layout is fixed, and
legend.labels.padding
is correctly applied to the left most items.Fixes #4112
Fixes #5491
Fixes #5606