Hi,
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.plot.ly/plotly-1.53.0.min.js" charset="utf-8"></script>
</head>
<body>
<div class="container" style="width: 100vw; height: 100vh;">
<div id="main_div" style="width: 100%; height: 100%; display: none;">
<div id="plot_div" style="width: 100%; height: 100%;"></div>
</div>
<button id="btn1">Click</button>
</div>
</body>
<script>
const data = [{
type: 'bar',
x: [1,1,2,2],
y: ["A", "B", "C", "D"],
hovertemplate: '<b>X</b>: %{x}<br><extra></extra>',
orientation: 'h'
}];
const layout = {
margin: {l: 1},
autosize: true
}
const config = {responsive: true}
Plotly.newPlot('plot_div', data, layout, config);
const btn1 = document.getElementById("btn1")
const main_div = document.getElementById("main_div")
btn1.addEventListener("click", () => {main_div.style.display = "block"})
</script>
</html>
With the code above, it contains a basic bar-plot that becomes visible when you click the button. However, when you click the button, the size of the plot is not the same as plot_div until you resize the window. I completely understand why that happens, however, I would like to have the plot consume the complete size of the plot_div when the button gets clicked.
The code above is a simplification of an actual example that I have, and using visibility instead of display will not be suitable for my application.
Thanks