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