-
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
Enhance legend label color point when usePointStyle is true #6006
Conversation
Allow for users to add in an extra parameter to the label options which changes the size of the legend box separate to the font size. This doesn't affect current functionality, but adds to it.
This would have to be added to the documentation. I don't quite understand the feature, but haven't spent much time looking at the PR yet. Can you share a jsfiddle, codepen, or screenshot of what this looks like before and after the change to help demonstrate what you're changing? |
Fixed the position of the legend box, when using custom point sizes.
+1 to calling it |
@benmccann I have changed Should this now go to review? |
I don't know this section of the code all that well, so I'll let the others review it. My main question is why do we need |
@benmccann To be honest, I'm not sure why the functionality isn't allowed. There is a function called Can you label this as waiting for review? I can't do this for some reason. |
This I think the reasoning behind is to provide good default, when IMO this is a configuration resulution issue and So I would not add a new option for this. Instead I would fix the math for better default and honor user provided value over default in any case (this second part might be another PR). |
@kurkle I agree that this could just involve fixing the existing code, I just didn't want to break any existing functionality with this change. I will look into this in more detail and remove the additional option, and instead work on a fix to allow for the user to override the default with the current |
I agree we shouldn't introduce a new option, though I wouldn't change the default (40), neither try to change the resolution order. To me, the point size should be |
@simonbrunel sounds like a better approach again that. |
@simonbrunel I was talking about the default when Also I don't see why its calculated inside those loops in |
I'm not sure about if (opts.labels && opts.labels.usePointStyle) {
var radius = Math.min(boxWidth, fontSize) / 2;
// ... |
Takes min value from boxSize and fontSize when using point styles for legend boxes, and correctly displays them on the screen.
@simonbrunel @kurkle in the recent commits, default functionality remains the same when I have also updated the docs to suit changes. |
A pen to play with (b6acb9f): https://codepen.io/kurkle/full/pGgJMZ And previous (80f117d): https://codepen.io/kurkle/full/GzopJm |
What is the next step for this PR? |
Wait for reviews |
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.
plugins.legend.js
is not quite up to the coding standards. So I'll ignore the surroundings on focus on change.
The current proposed solution seems a bit non-intuitive to me. It seems strange to me that changing the shape should change the size as well. Doing the minimum of the two values also seems weird because it means that boxWidth can only make the point smaller, but you can never make it bigger. One problem is that |
@alfiehd you'll need to rebase this PR |
@kurkle @etimberg I had to merge changes with conflicts in the @benmccann I am not familiar with rebasing. I've done some research but is there a specific procedure in this repo? |
@alfiehd it looks like you did the rebase correctly. By rebase I mean merge the latest changes from master to remove any merge conflicts so that we can merge this PR. Thanks! |
@benmccann ahh right! All done, thanks! |
The point looks too high to me in the screenshot in #6006 (comment). Is it possible to vertically center the point? |
@benmccann I’ve already fixed the vertical positioning in the commit 2989223 - Fixed positioning of legend box |
Ok. Would it be possible to update the screenshot? |
@benmccann updated :) |
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.
Thanks for your patience on this one
Thanks @alfiehd |
@benmccann @simonbrunel @kurkle thanks for all of your input on this one. Really glad it's been merged haha. My first PR ever, and with a library that I use on a daily basis and have created many plugins for internal use. I'll get around to sharing those with the community soon also! |
Allow for users to add in an extra parameter to the label options which changes the size of the legend box separate to the font size. This doesn't affect current functionality, but adds to it.