Chartjs-Uncaught TypeError: Cannot read property 'format' of undefined

1👍

You have to declare the formatter before calling the new Chart constructor function, otherwise it will be undefined inside the options you are passing as the second parameter of new Chart.

var formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',
  minimumFractionDigits: 2,
  // the default value for minimumFractionDigits depends on the currency
  // and is usually already 2
});

window.myBar = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: options
});

Leave a comment