首页 > 解决方案 > ReferenceError: google 未在 drawChart 中定义

问题描述

我已将 arrayToDataTable 与调用“内部”的数据一起使用。现在,我正在尝试在函数“外部”定义数据(timeAndNote),就像这样。但我得到一个参考错误:google is not defined at drawChart

var timeAndNote = [
['time','note']
[-3,  83],
[-2,  60.5],
[-1,  66],
[0,  67]
];
drawChart(timeAndNote);

function drawChart(array) {

  var data = google.visualization.arrayToDataTable(array, true);

  var options = {
    title: 'note vs time',
    curveType: 'function',
    legend: { position: 'bottom' },
    vAxis: {
      ticks: [
      ---removed ---      
      ]
    }
  };

  var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));


  chart.draw(data, options);
}

谁能告诉我这是什么意思?

标签: chartsgoogle-visualization

解决方案


推荐阅读