gpt4 book ai didi

javascript - Google Chart 不是 100% 的 div 宽度 - 包含从代理表重绘图表的事件监听器

转载 作者:行者123 更新时间:2023-12-04 07:38:57 26 4
gpt4 key购买 nike

我已经在这篇文章中实现了@WhiteHat 的建议 Google Chart not taking up 100% of space
我的 <div>是 100% 宽度,但我的图表仍然仅呈现 400 像素宽。见图片。
enter image description here
我设置了以下图表选项。

        "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 是正确的。 div 被隐藏,直到 .draw() 之后被称为。 lib_loadingStatus()取消隐藏 div

proxyTable.setDataTable(proxyView);
proxyTable.draw();
lib_loadingStatus(element_suffix, "done"); //This code unhides the chart <div>
proxyTable.setDataTable(proxyView);    
lib_loadingStatus(element_suffix, "done"); //This code unhides the chart <div>
proxyTable.draw();

图表现在绘制全尺寸。非常感谢@WhiteHat(再次节省一天!)

关于javascript - Google Chart 不是 100% 的 div 宽度 - 包含从代理表重绘图表的事件监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67589324/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com