¿Cómo diseñar un tablero interactivo y un tablero complementario con mecanismos de devolución de llamada para la implementación local y en línea?
app = dash.dash (__ name__, external_stylesheets =[dbc.themes.BOOTSTRAP]) app.layout = dbc.container ([
dbc.Row([
dbc.Col([
html.H1(“📊 Advanced Financial Dashboard”, className=”text-center mb-4″),
html.P(f”Interactive dashboard with {len(df)} data points across {len(stock_names)} stocks”,
className=”text-center text-muted”),
html.Hr()
])]), dbc.row ([
dbc.Col([
dbc.Card([
dbc.CardBody([
html.H5(“🎛️ Dashboard Controls”, className=”card-title”),

html.Label(“Select Stocks:”, className=”fw-bold mt-3″),
dcc.Dropdown(
id=’stock-dropdown’,
options=[{‘label’: f'{stock} ({base_prices[stock]}) ‘,’ valor ‘: stock} para stock en stock_names]valor =[‘AAPL’, ‘GOOGL’]multi = true, placeHolder = “Elija acciones para analizar …”), html.label (“rango de fecha:”, classname = “fw-bold mt-3”), dcc.datepickErrange (id = ‘date-picker-range’, start_date = “2023-06-01”, final_date = “2024-06-01”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, “,”, display_format = “yyyy-mm-dd”, style = {‘width’: ‘100%’}), html.label (“style de gráfico:”, classname = “fw-bold mt-3”), dcc.radioitems (id = ‘gráfico-type’, opciones = = =[
{‘label’: ‘ Line Chart’, ‘value’: ‘line’},
{‘label’: ‘ Area Chart’, ‘value’: ‘area’},
{‘label’: ‘ Scatter Plot’, ‘value’: ‘scatter’}
]value = “línea”, etiquetStyle = {‘display’: ‘bloque’, ‘margen’: ‘5px’}), dbc.checkList (id = ‘show-ma’, options =[{‘label’: ‘ Show Moving Average’, ‘value’: ‘show’}]valor =[]style = {‘margin’: ’10px 0′}),])]classname = “H-100”)]width = 3), dbc.col ([
dbc.Card([
dbc.CardHeader(“📈 Stock Price Analysis”),
dbc.CardBody([
dcc.Graph(id=’main-chart’, style={‘height’: ‘450px’})
])])]ancho = 9)]classname = “mb-4″), dbc.row ([
dbc.Col([
dbc.Card([
dbc.CardBody([
html.H4(id=”avg-price”, className=”text-primary mb-0″),
html.Small(“Average Price”, className=”text-muted”)
])])]ancho = 3), dbc.col ([
dbc.Card([
dbc.CardBody([
html.H4(id=”total-volume”, className=”text-success mb-0″),
html.Small(“Total Volume”, className=”text-muted”)
])])]ancho = 3), dbc.col ([
dbc.Card([
dbc.CardBody([
html.H4(id=”price-range”, className=”text-info mb-0″),
html.Small(“Price Range”, className=”text-muted”)
])])]ancho = 3), dbc.col ([
dbc.Card([
dbc.CardBody([
html.H4(id=”data-points”, className=”text-warning mb-0″),
html.Small(“Data Points”, className=”text-muted”)
])])]ancho = 3)]className = “Mb-4”), dbc.row ([
dbc.Col([
dbc.Card([
dbc.CardHeader(“📊 Trading Volume”),
dbc.CardBody([
dcc.Graph(id=’volume-chart’, style={‘height’: ‘300px’})
])])]ancho = 6), dbc.col ([
dbc.Card([
dbc.CardHeader(“📉 Returns Distribution”),
dbc.CardBody([
dcc.Graph(id=’returns-chart’, style={‘height’: ‘300px’})
])])]ancho = 6)]classname = “mb-4”), dbc.row ([
dbc.Col([
dbc.Card([
dbc.CardHeader(“📋 Latest Stock Data”),
dbc.CardBody([
dash_table.DataTable(
id=’data-table’,
columns=[
{‘name’: ‘Stock’, ‘id’: ‘Stock’},
{‘name’: ‘Date’, ‘id’: ‘Date’},
{‘name’: ‘Price ($)’, ‘id’: ‘Price’, ‘type’: ‘numeric’,
‘format’: {‘specifier’: ‘.2f’}},
{‘name’: ‘Volume’, ‘id’: ‘Volume’, ‘type’: ‘numeric’,
‘format’: {‘specifier’: ‘,.0f’}},
{‘name’: ‘Daily Return (%)’, ‘id’: ‘Returns’, ‘type’: ‘numeric’,
‘format’: {‘specifier’: ‘.2%’}}
]style_cell = {‘Textalign’: ‘Center’, ‘FontSize’: ’14px’, ‘Padding’: ’10px’}, style_header = {‘backgroundcolor’: ‘rgb (230, 230, 230)’, ‘fontweight’: ‘negri’}, style_data_conditional = =[
{
‘if’: {‘filter_query’: ‘{Returns} > 0’},
‘backgroundColor’: ‘#d4edda’
},
{
‘if’: {‘filter_query’: ‘{Returns} < 0’},
‘backgroundColor’: ‘#f8d7da’
}
]page_size = 15, sort_action = “nativo”, filtre_action = “nativo”)])])])]]fluid = true)