[Chartjs]-Chart.JS Can not read property '_meta' of Undefined

5👍

You are unexpectedly closing off the options property, before setting all the options.

Here is the correct syntax :

var ctx = document.getElementById('cvtree').getContext('2d');
var chart = new Chart(ctx, {
   type: 'bar',
   data: {
      labels: yoylabels,
      datasets: [{
         label: 'Pay By Person',
         backgroundColor: 'rgba(0, 129, 214, 0.8)',
         data: numericdollarvals
      }]
   },
   options: {
      legend: {
         display: false,
         position: 'top',
      },
      scales: {
         yAxes: [{
            ticks: {
               beginAtZero: true,
               callback: function(value, index, values) {
                  if (parseInt(value) >= 1000) {
                     return '$' + value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                  } else {
                     return '$' + value;
                  }
               }
            }
         }]
      }
   }
});

Leave a comment