reordenamos codigo y variables

para no dejar lo de las gráficas idividuales
parent d1f21971
......@@ -7,9 +7,6 @@ data = (
)
comidas = [10, 20, 30, 40]
glucometro = [14, 28, 42]
visitas = [1, 2, 3, 4]
external_stylesheets = [
{
......@@ -44,7 +41,7 @@ app.layout = html.Div(
html.Div(children=[
"Min. Comidas",
dcc.Slider(
id="comida-slider",
id="min_comida",
min=1,
max=42,
value=10,
......@@ -52,7 +49,7 @@ app.layout = html.Div(
),
"Dias con Glucómetro",
dcc.Slider(
id="glucosa-slider",
id="min_glucosa",
min=1,
max=42,
value=7,
......@@ -60,7 +57,7 @@ app.layout = html.Div(
),
"Visitas",
dcc.Slider(
id="visitas-slider",
id="min_visitas",
min=1,
max=4,
value=1,
......@@ -76,97 +73,61 @@ app.layout = html.Div(
@app.callback(
Output("multi-chart", "figure"),
Input("comida-slider", "value"),
Input("glucosa-slider", "value"),
Input("visitas-slider", "value"),
Input("min_comida", "value"),
Input("min_glucosa", "value"),
Input("min_visitas", "value"),
)
def update_charts(comidaslider, glucosaslider, visitaslider):
filtered_data = data.query(
"Selectedfoods >= @comidaslider"
)
def update_charts(min_comida, min_glucosa, min_visitas):
total_data = len(data.index)
comidas_chart_figure = go.Figure(go.Indicator(
mode = "gauge+number",
value = filtered_data["medibles"].count(),
domain = {'x': [0, 1], 'y': [0, 1]},
title = {'text': "Ptes"},
gauge = {'axis': {'range': [None, total_data]}, 'shape': 'bullet'}))
glucosa_data = data.query("Days_glucose >= @glucosaslider")
glucosa_chart_figure = go.Figure(go.Indicator(
mode = "gauge+number",
value = glucosa_data["medibles"].count(),
domain = {'x': [0, 1], 'y': [0, 1]},
title = {'text': "Ptes"},
gauge = {'axis': {'range': [None, total_data]}, 'shape': 'bullet'}))
visitas_data = data.query("Days_glucose >= @visitaslider")
visitas_chart_figure = go.Figure(go.Indicator(
mode = "gauge+number",
value = visitas_data["medibles"].count(),
domain = {'x': [0, 1], 'y': [0, 1]},
title = {'text': "Ptes"},
gauge = {'axis': {'range': [None, total_data]}, 'shape': 'bullet'}))
multi = go.Figure()
comidas_data = data.query("Selectedfoods >= @comidaslider")
comidas_data = data.query("Selectedfoods >= @min_comida")
multi.add_trace(go.Indicator(
mode = "number+gauge+delta", value = comidas_data["medibles"].count(),
delta = {'reference': 200},
domain = {'x': [0.25, 1], 'y': [0.08, 0.25]},
mode = "number+gauge", value = comidas_data["medibles"].count(),
domain = {'x': [0.25, 1], 'y': [0.8, 0.95]},
title = {'text': "Con comidas"},
gauge = {
'shape': "bullet",
'axis': {'range': [None, total_data]},
'threshold': {
'line': {'color': "black", 'width': 2},
'thickness': 0.75,
'value': total_data*0.75},
'steps': [
{'range': [0, total_data*0.25], 'color': "gray"},
{'range': [total_data*0.25, total_data*0.75], 'color': "lightgray"}],
'bar': {'color': "black"}}))
{'range': [0, total_data*0.1], 'color': "red"},
{'range': [total_data*0.1, total_data*0.75], 'color': "yellow"},
{'range': [total_data*0.75, total_data], 'color': "green"}],
'bar': {'color': "blue"}}))
glucosa_data2 = data.query("Days_glucose >= @glucosaslider")
glucosa_data = data.query("Days_glucose >= @min_glucosa")
multi.add_trace(go.Indicator(
mode = "number+gauge+delta", value = glucosa_data2["medibles"].count(),
delta = {'reference': 200},
mode = "number+gauge", value = glucosa_data["medibles"].count(),
domain = {'x': [0.25, 1], 'y': [0.4, 0.6]},
title = {'text': "Glucómetro"},
gauge = {
'shape': "bullet",
'axis': {'range': [None, total_data]},
'threshold': {
'line': {'color': "black", 'width': 2},
'thickness': 0.75,
'value': total_data*0.75},
'steps': [
{'range': [0, total_data*0.25], 'color': "gray"},
{'range': [total_data*0.25, total_data*0.75], 'color': "lightgray"}],
'bar': {'color': "black"}}))
{'range': [0, total_data*0.1], 'color': "red"},
{'range': [total_data*0.1, total_data*0.75], 'color': "yellow"},
{'range': [total_data*0.75, total_data], 'color': "green"}],
'bar': {'color': "blue"}}))
visitas_data = data.query("Nvisitas >= @visitaslider")
visitas_data = data.query("Nvisitas >= @min_visitas")
multi.add_trace(go.Indicator(
mode = "number+gauge+delta", value = visitas_data["medibles"].count(),
delta = {'reference': 200},
domain = {'x': [0.25, 1], 'y': [0.75, 0.95]},
mode = "number+gauge", value = visitas_data["medibles"].count(),
domain = {'x': [0.25, 1], 'y':[0.08, 0.25]},
title = {'text': "Visitas"},
gauge = {
'shape': "bullet",
'axis': {'range': [None, total_data]},
'threshold': {
'line': {'color': "black", 'width': 2},
'thickness': 0.75,
'value': total_data*0.75},
'steps': [
{'range': [0, total_data*0.25], 'color': "gray"},
{'range': [total_data*0.25, total_data*0.75], 'color': "lightgray"}],
'bar': {'color': "black"}}))
{'range': [0, total_data*0.1], 'color': "red"},
{'range': [total_data*0.1, total_data*0.75], 'color': "yellow"},
{'range': [total_data*0.75, total_data], 'color': "green"}],
'bar': {'color': "blue"}}))
return multi
......
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