Hi, I am trying to place a dcc.Graph
in dbc.Tab
. The plot is supposed to go to the bottom of the screen, so I tried to use a flexbox. My attempt at that looks like this:
from dash import dcc, html, Dash
import dash_bootstrap_components as dbc
import plotly.express as px
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = html.Div(
style={"height": "100vh"},
children=[
dbc.Tabs(
children=[
dbc.Tab(
label="Graph",
children=[
dcc.Graph(
figure=px.line(x=[0, 1, 2, 3], y=[0, 1, 0, 1], title="Simple Graph"),
style={"flex": "1", "display": "flex", "flexDirection": "column"},
)
]
),
dbc.Tab(label="Other"),
],
),
],
)
if __name__ == "__main__":
app.run(debug=True)
Sadly, this doesn’t work as expected. The plot is stops well before the bottom the window.
I’ve also tried without the Tabs:
from dash import dcc, html, Dash
import dash_bootstrap_components as dbc
import plotly.express as px
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = html.Div(
style={"height": "100vh"},
children=[
dcc.Graph(
figure=px.line(x=[0, 1, 2, 3], y=[0, 1, 0, 1], title="Simple Graph"),
style={"flex": "1", "display": "flex", "flexDirection": "column"},
)
],
)
if __name__ == "__main__":
app.run(debug=True)
This places the plot as I want it to.
From my research, I’ve found, that I need to set the height of the layers above the graph. However, I can’t seem to find a way to do that for the content of a dbc.Tab
, only for the navigation content at the top. Is there a way to do that?
Any help would be greatly appreciated.