我正在尝试在我的程序中使用 Chart.js . 我在公共托管网站上托管了我的php和JavaScript文件 . 当我尝试运行图表功能时,我收到以下错误:

未捕获的TypeError:无法读取未定义的属性“数据集” . 请找到下面的代码 .

<head>
    <title>Operation Details</title>
    <script src="../Chart.js"></script>
</head>
var barChartData = { 
    labels : [month1,month2,month3,month4,month5,month6,month7,month8,month9,month10,month11,month12],
    datasets : [ 
        { 
        label: "My First dataset", fillColor : "rgba(192,192,192,0.5)", strokeColor : "rgba(192,192,192,0.8)", highlightFill: "rgba(192,192,192,0.75)", highlightStroke: "rgba(192,192,192,1)",
        data : [avg1[temp[i]],avg2[temp[i]]]
        }
    ]
}
//...

window.onload = function(){
    var ctx = document.getElementById("canvas").getContext("2d");
    window.myBar = new Chart(ctx).Bar(barChartData, {
        responsive: true
    });
//...
}

chart.js之:

helpers.each(data.datasets,function(dataset,datasetIndex){

    var datasetObject = {
    //...

我是JavaScript和这个论坛的新手 . 如果出现问题,请就此提出建议 .