Open luggie opened 4 years ago
If the dcc.Graph is initially empty and populated with a callback, the graph may be covered by other components until the window is resized (which will trigger a resizing event). This doesn't happen if responsive=False
.
https://github.com/plotly/dash/assets/101562106/5f0cacc4-5731-4c88-98ca-b724c5529897
Env:
dash==2.16.1
plotly==5.21.0
Code to replicate the issue:
from dash import Dash, html, dcc, callback, Output, Input
import plotly.graph_objects as go
from time import sleep
app = Dash()
RESPONSIVE = True
app.layout = html.Div(
[
dcc.Graph(
figure=go.Figure(data=go.Bar(y=[2, 3, 1], marker_color="pink")),
id="g1",
responsive=RESPONSIVE,
),
dcc.Graph(
id="g2",
responsive=RESPONSIVE,
),
dcc.Graph(
figure=go.Figure(data=go.Bar(y=[2, 3, 1], marker_color="blue")),
id="g3",
responsive=RESPONSIVE,
),
html.Div(id="container")
]
)
@callback(Output("g2", "figure"), Input("container", "id"))
def update(id):
sleep(3)
return go.Figure(data=go.Bar(y=[2, 3, 1], marker_color="yellow"))
app.run(debug=True)
Tested workarounds (that don't work)
style={'height':'100%'}
to dcc.Graph()
.dash-graph {
height : 100%;
}
ddc.Graph isn't inheriting height from parent div as it does with width. This happens even when responsive = True is set.
dash versions:
Minimal code example: https://community.plotly.com/t/js-onresize-event-listener-for-toast-not-working/47670