nueva versión de la gráfica de datos por paciente

no recurre a los datos del archivo, tiene su función independiente
parent dd955cae
......@@ -183,7 +183,47 @@ app.layout = html.Div(children=[
#gráfica
html.Div(children=[dcc.Graph(id="gauges")],)
],style={'display': 'flex', 'flexDirection': 'row'}, className="wrapper"),
# segundo 'panel': datos existentes por paciente.
# segundo 'panel': datos existentes por paciente. working in progress
html.Div(children=[
html.H1("Cantidad de datos registrados por paciente", className="header-title2"),
# controles. 1 renglon, dos columnas.
html.Div(children=[
#dropdown etapa. columna izquierda.
html.Div(children=[
html.Div(children="Etapa", className="menu-title"),
dcc.Dropdown(
id="select_etapa_dpp",
options=[
{"label":1, "value":1},
{"label":2, "value":2},
{"label":3, "value":3},
],
value=1,
clearable=False,
searchable=False,
className="dropdown",
),
], className="wrapper"),
# dropdown fuente. columna derecha.
html.Div(children=[
html.Div(children="Fuente", className="menu-title"),
dcc.Dropdown(
id="select_fuente_dpp",
options=[
{"label":"Comidas", "value":1},
{"label":"Glucómetro", "value":2},
],
value=1,
clearable=False,
searchable=False,
className="dropdown",
),
],className="wrapper",),
], style={"display":"flex", "flexDirection": "row"},),
dcc.Graph(id="datos_por_paciente"),
], className="wrapper"),
# segundo 'panel': datos existentes por paciente. legajo.
html.Div(children=[
html.H1("Cantidad de datos por paciente", className="header-title2"),
# controles. 1 renglon, dos columnas.
......@@ -197,7 +237,6 @@ app.layout = html.Div(children=[
{"label":1, "value":1},
{"label":2, "value":2},
{"label":3, "value":3},
{"label":"No-Clas.", "value":99}
],
value=1,
clearable=False,
......@@ -356,6 +395,42 @@ def update_gauges(etapaSel, min_comidas, min_glucosa):
return multi
@app.callback(
Output("datos_por_paciente", "figure"),
Input("select_etapa_dpp", "value"),
Input("select_fuente_dpp", "value")
)
def update_datos_por_paciente(etapa, fuente):
if fuente == 1:
xs = resumen_comidas.loc[(slice(None),f'e{etapa}')].sort_values()
title = f"Comidas por paciente en la etapa {etapa}"
medCadena = 'comidas'
if fuente == 2:
xs = glucometro_df.loc[glucometro_df["visit_id"] == etapa]["amount_of_days"].sort_values()
title = f'dias de glucómetro por paciente en la etapa {etapa}'
medCadena = 'días de glucómetro'
xs.index = "p_" + xs.index.astype(str)
figura = {
"data": [
{
"x": xs.index,
"y": xs,
"name": "Comidas",
#"orientation": "v",
},
#{ "x": temp["Comidas_e1"], "type": "histogram"},
],
"layout": {
"title": {"text": title},
"xaxis": { "title": {"text": "Paciente"}},
"yaxis": { "title": {"text": f'Número de {medCadena}'}},
"bargap": "0.05"
}
}
return figura
@app.callback(
Output("detalle_figura", "figure"),
Output("multi-visitas", "figure"),
Output("detalle_pruebas", "figure"),
......
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