Chartjs-How to change the display of an axis Chart.js

0👍

You should change the options for to xAxes of your chart.

const chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
    scales: {
        xAxes: [{
            ticks: {
                callback: function(value, index, values) {
                    return Math.round(value).toString();
                }
            }
        }]
    },
    tooltips: {
        callbacks: {
            title: function(tooltipItem, data) {
               return data.labels[tooltipItem[0].index];
          }
       }
   }
}});

I think that this won’t change the dataset.

Leave a comment