问题
How can I keep zoom-in, zoom-reset functionality after chart redraw? It seems like these options stop working after I use zoom-in option and then redraw the chart. What am I missing? My code is:
google.charts.load('current', {'packages':['corechart','table']});
function drawChart(data, chartType) {
var w = document.getElementById('chart_div').clientWidth;
var h = w * 0.5;
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization[chartType](document.getElementById('chart_div'));
var columns = [];
var series = {};
for(var i = 0; i < data.getNumberOfColumns(); i++) {
//push default columns
columns.push(i);
if (i > 0) {
series[i-1] = {};
}
}
var options = {
height: h,
series: series,
chartArea: {width: "65%", height: "65%"},
legend: {textStyle: {fontSize: 12}},
hAxis: {title: 'Date', titleTextStyle: {color: '#333'}, slantedTextAngle:80, format: 'yyy-MM-dd'},
vAxis: {title: 'GUIDs'},
explorer: {actions: ['dragToZoom', 'rightClickToReset'],
axis: 'horizontal',
keepInBounds: true,
maxZoom: 20}}
function redraw() {
chart.draw(data, options);
}
var view = new google.visualization.DataView(data);
window.addEventListener('resize', redraw, false);
chart.draw(view, options);
}
来源:https://stackoverflow.com/questions/45764587/google-visualization-explorer-options-wont-have-any-effect-after-chart-redraw