Google Visualization explorer options won't have any effect after chart redraw

断了今生、忘了曾经 提交于 2019-12-31 04:14:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!