-
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
Add new align 'inner' for X axis #10106
Add new align 'inner' for X axis #10106
Conversation
new align 'left-right' for options.scales['x'].ticks namespace will allow users to aling ticks: 'start" for first (left) tick and 'end' for last (right) tick
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.
1 Suggestion that I think will make the functionality better and more flexible.
Also before this can be merged the typings for this property have to be adjusted here:
Line 3030 in a7d98fb
align: 'start' | 'center' | 'end'; |
And the documentation also needs to be updated here: https://github.com/chartjs/Chart.js/blob/master/docs/axes/cartesian/_common_ticks.md
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.
I like the outcome. It would be good to add some image based tests for this and to test how this works when labels are rotated. There are examples of those tests in https://github.com/chartjs/Chart.js/tree/master/test/fixtures/core.scale
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 adding the tests. They look good. I think there's one more small case to consider that can be tested by hiding the Y axis (display: false
). The default case for the left padding is half the width of the first label. When the alignment is set to 'inner'
I think this should be 0
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.
Looks good to me. Needs a rebase though.
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.
Add test for inner align without Y axis. Works perfect |
They work, but there's a gap at the left and right edges in |
Got it! Padding for left and right borders was corrected. Tests results was corrected |
Co-authored-by: Jacco van den Berg <[email protected]>
@etimberg , @kurkle , @LeeLenaleee |
So this is good to merge, but we want to release v3.7.1 first to keep the branching a little simpler. As soon as that is released (should be soon) then we'll merge this for 3.8.0 |
v3.7.1 has merged, so this is merging and will be released with v3.8.0 |
New align type: 'left-right' for options.scales['x'].ticks namespace will allow users to aling horizontal axis ticks: 'start" for first (left) tick and 'end' for last (right) tick.

Before:
After:
