Chartjs-Precission in bar chart of chartjs

0👍

All values are formatted to 3 decimals by default in Chart.js and there doesn’t seem to be a setting that allows you to change the number of decimals directly.

Instead, you can use the raw value and format it yourself by overriding the label callback in the chart options:

.
.
.
plugins: {
  tooltip: {
    callbacks: {
      label: function(context) {
        return Number((context.raw || 0)).toFixed(4);
      }
    }
  }
}
.
.
.

Edit: Added a working example to demonstrate 4 decimals showing in a bar chart:
https://jsfiddle.net/j2Lwbmu8/

Leave a comment