Commit ec2ff7ee by Itzel Camacho

Definir el rango del eje y, entre [50-200]

parent 686c6bea
import pandas as pd
from dash import Dash, Input, Output, dcc, html, callback
from dash import Dash, Input, Output, State, dcc, html, callback
import plotly.graph_objects as go
import plotly.express as px
import plotly.figure_factory as ff
......@@ -378,12 +378,12 @@ app.layout = html.Div(children=[
@callback(
Output('glucosa-graph', 'figure'),
[Input('rango', 'value'),
Input('slider-patient', 'value')]
[Input('slider-patient', 'value'),
Input('rango', 'value')],
)
def update_graph(rango_str, selected_pat):
def update_graph(selected_pat, rango_str):
if selected_pat not in df_total['patient']:
return go.Figure()
return go.Figure()
if not selected_pat or not rango_str:
return {}
......@@ -402,6 +402,7 @@ def update_graph(rango_str, selected_pat):
y=filtered_glucosa['value'],
mode='lines',
name='Glucosa paciente visita 1'))
fig.update_layout(yaxis=dict(range=[50,200]))
y_foods = np.interp(patient_foods['FH_reportada'], glucosa['date_time'], glucosa['value']) # interpolar fecha de las comidas con glucosa
distancias = abs((patient_foods['FH_salto'] - patient_foods['FH_reportada']).dt.total_seconds()) / 60
distancias_df = pd.concat([distancias,patient_foods['FH_reportada'], patient_foods['FH_foto']], axis=1, ignore_index=True)
......@@ -424,7 +425,7 @@ def update_graph(rango_str, selected_pat):
distancias_rango = distancias_df[(distancias_df['Distancia'] >= min(rango)) & (distancias_df['Distancia'] <= max(rango))] #elegir las comidas que se encuentran en el rango seleccionado
fotos_wfoods = distancias_rango.set_index('FH_reportada')['FH_foto']
if distancias_rango.empty:
return fig
return fig
y_distancias = np.interp(pd.to_numeric(distancias_rango['FH_reportada']), pd.to_numeric(glucosa['date_time']), glucosa['value']) #interpolar la fecha de las distancias con glucosa
y_foto_wfood = np.interp(pd.to_numeric(fotos_wfoods.values), pd.to_numeric(glucosa['date_time']), glucosa['value'])
fig.add_trace(go.Scatter(x=distancias_rango['FH_reportada'],
......
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