I am trying to find an option within chart.js that allows me to modify the space between bars and labels, but so far have been unsuccessful. I have tried the options under https://www.chartjs.org/docs/latest/charts/bar.html.
1 Answer
You can use ticks.padding to define the offset of the tick labels from the axis. In you case, it needs to be defined inside the options.scales.yAxis as follows:
options: { scales: { yAxes: [{ gridLines: { drawTicks: false }, ticks: { padding: 5 } }], 2 Comments
Garet Webster
Unfortunately this didn't work, but thanks for the advice. I tried both padding: 5 and padding: 0, but it didn't change the spacing. After reading the documentation I believe this changes the spacing of the ticks, not of the labels, so it makes sense nothing was changed.
Garet Webster
After messing with it some more I realized that these numbers were increased padding, so putting padding: 5 doesn't set the padding to 5, it increases the padding by 5. As such using a negative number like padding: -20 accomplished my goal. Thanks for the help.
