我收到一个data1
未定义的参考错误,我的表格是可见的,我可以看到我制作的 3 个圆圈。但是当我想更新它时,我得到了参考错误。
这是我正在工作的绘图代码:
google.load('visualization', '1', {packages:['gauge']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data1 = google.visualization.arrayToDataTable([
['Label', 'Value'],
['A', 0],
]);
var data2 = google.visualization.arrayToDataTable([
['Label', 'Value'],
['B', 0]
]);
var data3 = google.visualization.arrayToDataTable([
['Label', 'Value'],
['C', 0]
]);
var options1 = {
width: 150, height: 170,
min:0, max:200,
minorTicks: 5
};
var options2 = {
width: 150, height: 170,
min:0, max:7000,
minorTicks: 5
};
var options3 = {
width: 150, height: 170,
min:0, max:30,
minorTicks: 5
};
var chart = new google.visualization.Gauge(document.getElementById('visualization1'));
var chart2 = new google.visualization.Gauge(document.getElementById('visualization2'));
var chart3 = new google.visualization.Gauge(document.getElementById('visualization3'));
chart.draw(data1, options1);
chart2.draw(data2, options2);
chart3.draw(data3, options3);
}
这是我用来添加新值的函数data1
function changeSpeed(dir) {
console.log(dir);
data1.setValue(0, 0, dir);
chart.draw(data1, options1);
}
可能我的功能设置不正确。