[Chartjs]-How to set defaults for scales in ChartJS?

1👍

While writing this up, explaining it to the duck, and confirming each error I solved the problem myself. I thought I’d post anyway as I spent some hours on this and my own searching did not turn up anything which helped, maybe it will help a future someone or even future me.

The clue was in the new error I got in the last thing I tried:

Chart.defaults.scales.category.grid.display = false;
// Uncaught TypeError: Cannot set properties of undefined (setting 'display')

So grid is undefined. As a wild desperate guess I tried:

Chart.defaults.scales.category.grid = {
    display: false
};

And it works.

Leave a comment