-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix #1913 by pushing overflowed legend items to a new line #3628
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 #1913 by pushing overflowed legend items to a new line #3628
Conversation
…ne whilst respecting grouping
Thank you @nathanjenx for submitting this PR 🎉 It seems like two mocks are not matching the baselines. Could you update the baselines by running:
I will review the rest of your PR shortly 😸 |
About
As of right now, it also affects the horizontal spacing. Could you get rid of this behaviour by not adding cc @nathanjenx |
Removed |
Thank you @nathanjenx for commit b9542c4 which removes I now realize however that we should still have some horizontal spacing between items to be in line with what we have when there are no grouped items. To do so, we should add a While you're at it, I think we should replace L672 from: |
Is commit 51178ec what you had in mind? |
Concerning the changes in this baseline, I am wondering one should find a way to keep the axis line where it was before? |
@nathanjenx The horizontal spacing issue is still present. If I remove all Now if I add a I expected the horizontal spacing to remain the same 🤔
Indeed, it would be better if this baseline didn't change at all. @nathanjenx let me know if this is easy/possible! Thank you again! |
@antoinerg the horizontal spacing was off because I was updating the width then checking it then adding it again, rather than checking if we would be too long + then adding the width if we aren't. @antoinerg, @archmoj the axis line was off as I originally added traceGroupGap to EVERY row, not just new ones. The changes to the horizontal spacing of the legend items you see now are due to the traceGap being set to 5 (not the 10 it was inheriting from opts.traceGroupGap). Should be all sorted now! 🎉 |
Thank you @nathanjenx for the thorough revision! It looks good to me 💃 |
@@ -0,0 +1,57 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…actor of code surrounding y offsets
src/components/legend/draw.js
Outdated
var textWidths = groupData[i].map(function(legendItemArray) { | ||
var maxItems = 0; | ||
|
||
groupData.forEach(function(group) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NON-BLOCKING
We could probably clean up these few lines a little:
- use for-loop here instead of
forEach
- ⚡ that double empty new line
- use
Lib.aggNums
instead ofMath.max.apply
andgroup.reduce
- make the
for(var i = 0, n = groupData.length; i < n; i++)
loopsfor(var i = 0; i < groupData.length; i++)
, i.e. no need to definen
(I think).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a5fa247 except for group.reduce
.
Can I really replace group.reduce
with Lib.aggNums
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I really replace
group.reduce
withLib.aggNums
?
Maybe with something like:
Lib.aggNums(function(a, b) { return a + b[0].height; }, 0, groups)
similar to Lib.mean
, but you're right, that's probably an overkill here as all the b[0].height
should be defined. 💃
@antoinerg Thanks for adding that test! I made one very non-blocking comment. Feel free to ignore it. I'll let you the honours of merging this thing 💃 💃 Thank again @nathanjenx 🥇 |
@etpinard @antoinerg sorry for going dark at the end there! Cheers for pushing it over the line! 💃💃 |
Fixes the handling of horizontal grouped legend items see #1913. Maintains the vertical grouping and includes gaps between traces (see below screenshot)

@antoinerg @etpinard
(edit: updated to show current behaviour, original available here)