Javascript Google图表不是100%的div宽度-包含事件侦听器以从代理表重新绘制图表

Javascript Google图表不是100%的div宽度-包含事件侦听器以从代理表重新绘制图表,javascript,charts,google-visualization,Javascript,Charts,Google Visualization,我已经在这篇文章中按照@WhiteHat实施了建议 我的是100%宽度,但是我的图表仍然以400px的宽度呈现。参见图。 我设置了以下图表选项 "chartType": "ComboChart", "containerId": "chartnull_G3G", "view": {"columns":[2,3]},

我已经在这篇文章中按照@WhiteHat实施了建议

我的
是100%宽度,但是我的图表仍然以400px的宽度呈现。参见图。

我设置了以下图表选项

        "chartType": "ComboChart",
        "containerId": "chartnull_G3G",   
        "view": {"columns":[2,3]}, 
        "options": {
           "chartArea": { "left": "auto", "right": "auto", "top": 50, "bottom": "auto", "width": "80%", "height": "60%", "backgroundColor": "white" },
           "width": "100%",
           "height": 500    
         }
我的程序流程包含以下步骤

//proxyTable_default and comboChart_default simply creates the content for the chart - this works without problem

var proxyTable = new google.visualization.ChartWrapper(proxyTable_default(element_suffix));
var chart = new google.visualization.ChartWrapper(comboChart_default(null, element_suffix, json.comboChart.options));

addListenersComboChart();

window.addEventListener('resize', function () { proxyTable.draw(); }, false);

proxyTable.setDataTable(proxyView)
proxyTable.draw();
下面是我的侦听器和重画函数,上面引用了这些函数

function addListenersComboChart() {
    google.visualization.events.addListener(proxyTable, 'ready', function () {
        redrawComboChart(element_suffix, json.comboChart);
    });
}

function redrawComboChart(element_suffix, comboChart) {
    //Do many steps to calculate the finalView_forChart - this works without problem
    chart.setDataTable(finalView_forChart);
    chart.draw();
}
我无法发布完整的代码库,因为它有1000多行。一切正常,直到图表没有画出100%宽。我错过了什么


一如既往,我感谢您的反馈。

@Whitehat是正确的。在调用
.draw()
之前,div一直处于隐藏状态
lib\u loadingStatus()
取消隐藏div

以前

proxyTable.setDataTable(proxyView);
proxyTable.draw();    
lib_loadingStatus(element_suffix, "done"); //This code unhides the chart <div>
proxyTable.setDataTable(proxyView);
proxyTable.draw();
lib_loadingStatus(元素后缀“done”)//此代码取消隐藏图表
之后

proxyTable.setDataTable(proxyView);
lib_loadingStatus(元素后缀“done”)//此代码取消隐藏图表
proxyTable.draw();

现在,图表将绘制全尺寸。非常感谢@WhiteHat(再次拯救了这一天!)

嘿@cmill!不要马上发现任何东西。图表的容器在第一次绘制后显示时是否会被隐藏?另外,我从未见过
auto
用于
chartArea
维度,您确定这些维度工作正常吗?您100%正确!我没有在原始帖子中包含取消隐藏脚本。我已经重新安排了它,并在下面发布了我所做的更改。组合图的文档看起来像默认的chartArea。左(…右、上、下)表示它是自动的。这就是为什么我把它设置为自动。
proxyTable.setDataTable(proxyView);    
lib_loadingStatus(element_suffix, "done"); //This code unhides the chart <div>    
proxyTable.draw();