Reputation: 105
I have implemented graphs using Chart.js and zoom feature using chartjs-plugin-zoom which works fine. However, while scrolling the y-axes is giving a large range of decimal points which is resulting in the values being out of viewpoint. How do I avoid the decimal points?
chartjs-plugin-zoom code:
plugins: {
zoom: {
pan: {
enabled: true,
},
zoom: {
wheel: {
enabled: true,
speed: .01
},
pinch: {
enabled: true
},
mode: 'xy',
}
},
},
Upvotes: 0
Views: 622
Reputation: 9308
From https://github.com/chartjs/chartjs-plugin-zoom/issues/220#issuecomment-507543826
options: {
scales: {
yAxes: [{
ticks: {
callback: function(value) {
if (Math.floor(value) === value) {
return value
}
}
}
}]
}
}
Upvotes: 2