[Chartjs]-Chartjs 3.2 problem with setting whole numbers for Y axis

1👍

I achieved the intended behavior with react-chartjs-2@4.1.0 and chart.js@3.7.1 with this:

scales: {
    y: {
        type: 'linear' as const, // magic
        ticks: {
            stepSize: 1,
        },
    },
},

setting the type as const is the trick.
I was initially trying it the way you did until I found this.

0👍

I have found a workaround, not a solution
I downgraded my react-chartjs-2 wrapper to 2.9.0 and installed chart.js dependecy version 2.5.0 this works.

0👍

I think the problem (at least regarding the fractional values) is ‘precision: 1’. If you do not want to have the decimal values, it should be ‘precision: 0’.

Leave a comment