1
我收到一個參考錯誤data1
沒有定義,我的窗體是可見的,我可以看到我做的3個圓圈。但是當我想更新它時,我收到參考錯誤。Google gauge在發送新值時發生錯誤
這裏是我的繪製代碼這是工作:
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);
}
也許我的功能沒有設置功能正確。
全局範圍變量爲我工作:)謝謝你好回答 –