0
我試圖改變Dygraph GVizChart列的可見性。Dygraphs setVisibility of column
這工作:
function drawChart() {
data = getData();
window.chart1 = new Dygraph.GVizChart(
document.getElementById('dygraphs')).draw(data, {
});
}
而且這個工程:
function drawChart() {
data = getData();
window.chart1 = new Dygraph.GVizChart(
document.getElementById('dygraphs')).draw(data, {
visibility: [false, true, true, true]
});
}
但是這裏面drawChart
,該代碼後,當我添加以下行,
function drawChart() {
data = getData();
window.chart1 = new Dygraph.GVizChart(
document.getElementById('dygraphs')).draw(data, {
});
window.chart1.setVisibility(0, true);
window.chart1.setVisibility(1, false);
}
我得到錯誤: Uncaught TypeError: Cannot call method 'setVisibility' of undefined. drawChart
讀完this question之後,我想可能chart1
在執行時還沒有準備好。所以我添加了這個功能:
function showChange() {
alert('show chart1:' + window.chart1);
window.chart1.setVisibility(3, false);
}
<a href="#" onclick='showChange();return false;'>showChange</a>
但是當我點擊鏈接showChange
,我得到同樣的錯誤:Uncaught TypeError: Cannot call method 'setVisibility' of undefined
和報警窗口說show chart1: undefined