agregamos una nueva figura al layout

es un duplicado de la última figura, con un nuevo dropdown y una nueva
función para generar la gráfica. así, ya tenemos todo listo para solo
modificar la gráfica de modo que envíe lo que queremos -que en este
caso será un heatmap-
parent 06e4bc1e
......@@ -195,6 +195,29 @@ app.layout = html.Div(children=[
#y gráfica
dcc.Graph(id="cobertura_protocolo"),
], className="wrapper"),
#heatmap
html.Div(children=[
html.H1("Pruebas por paciente", className="header-title2"),
# selector de etapa
html.Div(children=[
html.Div(children="Etapa", className="menu-title"),
dcc.Dropdown(
id="select_vis_pppaciente",
options=[
{"label":1, "value":1},
{"label":2, "value":2},
{"label":3, "value":3},
{"label":4, "value":4}
],
value=1,
clearable=False,
searchable=False,
className="dropdown",
),
], className="wrapper"),
#y gráfica
dcc.Graph(id="pppaciente"),
], className="wrapper"),
]) # cierre del layout
@app.callback(
......@@ -306,6 +329,38 @@ def update_por_protocolo(visita):
figura.update_traces(texttemplate='%{text:.2s}', textposition='auto')
return figura
@app.callback(
Output("pppaciente","figure"),
Input("select_vis_pppaciente", "value")
)
def update_por_prueba(visita):
lcol = 1
lrow = 1
df1 = visitas_datos[visita-1]
protocolos = {
"pyhsiological" : ["pas", "pad", "ipaq", "stress", "hadsa", "hadsd"],
"tolerance_curves" : ["Pan", "Gelatina", "Glucosa"],
"corporal_composition" : ["mmkg", "mmekg", "mgkg", "mlgkg", "percent_mg", "gv"],
"biochemical" :["hba1c", "glucose", "ct", "tag", "ldl", "hdl", "pcr","alt", "ast","homa", "insuline" ],
"antropometric" : ["imc", "weight", "waist_circumference"]
}
figura = make_subplots(rows=2, cols=3, vertical_spacing=0.25)
for protocolo in protocolos.keys():
columnas = list(set(df1.columns).intersection(set(protocolos[protocolo])))
cuentas = 100 * df1[columnas].replace("",np.nan).count() / len(df1)
figura.add_trace(
go.Bar(x=cuentas.index, y=cuentas, textposition='auto', text=cuentas),
row = lrow,
col = lcol,
)
lcol = lcol + 1
if lcol > 3:
lcol = 1
lrow = lrow + 1
figura.update_layout(showlegend=False)
figura.update_traces(texttemplate='%{text:.2s}', textposition='auto')
return figura
if __name__ == "__main__":
app.run_server(debug=True, port=8090, host='0.0.0.0')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment