[Chartjs]-Using chart.js, how do I align bars instead of centering them when there are only a few bars to display?

2👍

I have checked the settings and there is no setting to left-align the bar charts. I doubt it is easy to implement since Chart.JS is a canvas under the hood.

Also, technically speaking the chart is in fact “left-aligned” however it is just one slim bar. The bar could very well use the whole bar space in red:
enter image description here

The best workaround is to create empty labels that will later be populated if needed.
enter image description here
If you need to add more bars just check if a label name is "" (empty) and then overwrite it. Otherwise push the new label.

Example: https://codepen.io/adelriosantiago/pen/vYLYXPx?editors=0110

Leave a comment