-1👍
this is from github:
You could add a personalized callback to the tooltip labels, where you round the values
e.g.
1 – tooltipItem.yLabel.toFixed(2) would return a value with 2 decimal places.
2.123.toFixed(2)
>> "2.12"
2.0001.toFixed(2)
>> "2.00"
2- Math.round(tooltipItem.yLabel * 100) / 100 would return a value rounded to the nearest 2nd decimal place.
Math.round(2.123 * 100) / 100
>> 2.12
Math.round(2.00001 * 100) / 100
>> 2
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var label = data.datasets[tooltipItem.datasetIndex].label || '';
if (label) {
label += ': ';
}
label += tooltipItem.yLabel.toFixed(2);
return label;
}
}
}
- [Chartjs]-How to import Chart.js with Webpack
- [Chartjs]-How can I show dotted gridLines with ChartJS?
Source:stackexchange.com