Change the Y-axis values from real numbers to integers in Chart.js

后端 未结 6 1100
忘了有多久
忘了有多久 2020-12-24 04:39

I have a chart that I want to include in my website using Chart.js. In the Y-axis, it gives me real numbers instead of integers. How can I change the number to integers?

6条回答
  •  隐瞒了意图╮
    2020-12-24 05:26

    I know this is an old question now, but in the current version (v2.9.3) you can just set the precision of the y-axis ticks to zero to get integers:

    options: {  
        scales: {
            yAxes: [{
                ticks: {
                    precision: 0
                }
            }]
        }
    }
    

提交回复
热议问题