Add new align 'inner' for X axis#10106
Add new align 'inner' for X axis#10106etimberg merged 8 commits intochartjs:masterfrom Talla2XLC:leftRightAlignForHorizontalAxis
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.
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
And the documentation also needs to be updated here: https://github.com/chartjs/Chart.js/blob/master/docs/axes/cartesian/_common_ticks.md
etimberg
left a comment
There was a problem hiding this comment.
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
etimberg
left a comment
There was a problem hiding this comment.
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
kurkle
left a comment
There was a problem hiding this comment.
Looks good to me. Needs a rebase though.
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 <39033624+LeeLenaleee@users.noreply.github.com>
|
@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:
