Hello, thank you for this opportunity to ask questions.
I’m using tabs inside of Plotly Dash application like given below, and it works fine.
import dash
from dash import Dash, dash_table, dcc, html, Input, Output, callback, State
import plotly.express as px
import dash_bootstrap_components as dbc
import pandas as pd
import plotly.graph_objs as go
import plotly.express as px
tabs = html.Div(
[
dbc.Tabs(
[
dbc.Tab(label="Tab 1", tab_id="tab-1"),
dbc.Tab(label="Tab 2", tab_id="tab-2"),
],
id="tabs",
active_tab="tab-1",
),
html.Div(id="content"),
]
)
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
app.title = "Financial Report"
server = app.server
app.layout = html.Div(
dbc.Row([
tabs])
)
@app.callback(Output("content", "children"), [Input("tabs", "active_tab")])
def ind2(value):
purchase = {'date': ['11/03/2021', '12/03/2021', '14/03/2021', '11/03/2021'],
'price': [300, 400, 200, 200],
'currency': ['eur', 'usd', 'usd', 'usd'],
'qty': [200, 300, 400, 500],
'salesman': ['AC', 'BC', "CC", 'DC']}
pur = pd.DataFrame(purchase)
fig2 = go.Figure()
for i in pur['currency'].unique():
fig2.add_trace(go.Bar(x=pur['date'], y=pur[pur['currency'] == i]['qty'], name=i))
fig2.update_layout(barmode="group")
if value=='tab-2':
return dbc.Row(
[
dbc.Col(dcc.Graph(id='bargraph',
figure=fig2)),
]
)
else:
return html.P("Welcome...")
if __name__ == "__main__":
app.run_server(debug=True)
But when I’m trying to add this code to the Dash Page which has mutlti pages it doesn’t return anything, tabs seem to be inactive.
(Multi-Page Apps and URL Support | Dash for Python Documentation | Plotly)
to summarize, I want this page as in picture below. but not only side bar working but tabs inside of the page also.