google visualization chart, size in percentage

后端 未结 5 1666
我在风中等你
我在风中等你 2021-01-07 19:29

How do you set the size of a google chart in percentage : I have this in the html:

5条回答
  •  无人及你
    2021-01-07 19:32

    First, use styles to set your dimensions, not attributes:

    The chart will draw to the size of the div by default, but the charts are not responsive. You have to hook a "resize" event handler to the window (or other element if you are resizing within a window) that redraws the chart:

    function resizeChart () {
        chart.draw(data, options);
    }
    if (document.addEventListener) {
        window.addEventListener('resize', resizeChart);
    }
    else if (document.attachEvent) {
        window.attachEvent('onresize', resizeChart);
    }
    else {
        window.resize = resizeChart;
    }
    

提交回复
热议问题