Chart.JS 无法读取未定义的属性“_meta”

Icy*_*rts 6 javascript php jquery chart.js chart.js2

我正在尝试构建一个基本的条形图,但我在标题中收到错误。我已经使用alert()来验证我想要用保存数据填充图表的数组,但仍然无法使用语法正确地找出某些内容。有人可以检查并让我知道我需要做什么才能更好地生成图表吗?

    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;
                            }
                        }
                    }
                }]
        }
});
Run Code Online (Sandbox Code Playgroud)

ɢʀᴜ*_*ᴜɴᴛ 5

在设置所有选项之前,您意外地关闭了选项属性。

这是正确的语法:

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;
                  }
               }
            }
         }]
      }
   }
});
Run Code Online (Sandbox Code Playgroud)