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
Update plugin.legend.js with a new option: 'alignment'. #5866
Conversation
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.
@Zmimmy that's for this MR. I've left a few comments about the position computations that allow the code to handle some more cases. Additionally, what kind of tests do you think would be appropriate for this feature?
@Zmimmy Thanks! Before reviewing, I would like to align the API with the one in this comment:
No need to implement |
We also need additional logic in Chart.js/src/plugins/plugin.legend.js Line 441 in d6ac7d8
Chart.js/src/plugins/plugin.legend.js Line 445 in d6ac7d8
|
I'm assuming the following default row/column alignment, which needs to be considered in case of more than one row/column, but does this make sense?
|
Thanks for all the feedback! We just started using chartJS and I am not super familiar with the codebase yet so I appreciate all the insight. I will start making those changes this afternoon. |
…egend to be aligned within its layout box. The legend can be aligned in 3 ways 'start', 'center' (default), or 'end'. Updated the legend help page to reflect these changes. Add a number tests to test the new align option
351c05f
to
aca1195
Compare
I have made the changes and added test cases.
Yes, this makes sense and is now happening.
This also makes sense but is not currently happening exactly like this when there are multiple columns, all the columns default to the top of the legend container. |
Any update on this? I'd really appreciate this feature. |
Checking @Zmimmy did you get a chance to remediate? |
Waiting for that feature :) |
The position options for the legend only allow top, bottom, left, and right. Then the legends are aligned in the center on the top and bottom and at the top in left and right.
This adds a new option to the legend: 'alignment' which allow the legend to be aligned within its layout box.
In the case of position top or bottom, the legend can be aligned 'left', 'right', or 'center', with center being the default. For position right or left the legend can be aligned 'top', 'center', or 'bottom', with top being default as the current behavior.
Updated the legend help page to reflect these changes.
Similar: #3706
See: http://jsfiddle.net/pdht9ces/10/