Chartjs-How to format Chart.js dates in the axes and tooltip

1👍

For some reasons the parameters inside callback function are not populated as expected. Ideally first parameter value should be the value which is going to be print.

The workaround for this would be to use your existing data and the index from the callback parameter. You can try the below code.

callback: function(value, index, ticks) {
  const tickDate = new Date(chartData.labels[index]);
  return tickDate.getFullYear().toString();
}

Leave a comment