Skip decimal points on y-axis in chartJS

后端 未结 6 1279
说谎
说谎 2020-12-24 00:18

I am using this library to draw charts in my web app. The issue is that I am having decimal points in my y-axis. You can see that in the image below

Is there a way

6条回答
  •  一个人的身影
    2020-12-24 01:06

    I use this:

    yAxes: [
            {
                ticks: {
                        callback: function(val) {
                        return Number.isInteger(val) ? val : null;
                    }
                }
            }
        ]
    

    Note: use the callback function for better granular control. We check if val is an integer instead of a floating-point decimal. If it is, we return the value. If not, we return null.

提交回复
热议问题