我想知道,一旦加载图表,有没有办法使用函数更改水平最大窗口值(日期范围)而不必再次调用 drawChart 函数?
例如:
function changeWindow(){
chart.setOptions(hAxis.viewWindow.max = 2);
}
原始代码:
var chart;
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
};
chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
}