Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
inventario
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jose Luis Gordillo Ruiz
inventario
Commits
5280905b
Commit
5280905b
authored
Jul 25, 2024
by
Jose Luis Gordillo Ruiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
versión de trabajo inicial con tres medidores en un panel
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
173 additions
and
0 deletions
+173
-0
dinamyc.py
+173
-0
No files found.
dinamyc.py
0 → 100644
View file @
5280905b
import
pandas
as
pd
from
dash
import
Dash
,
Input
,
Output
,
dcc
,
html
import
plotly.graph_objects
as
go
data
=
(
pd
.
read_csv
(
"inventario.csv"
)
)
comidas
=
[
10
,
20
,
30
,
40
]
glucometro
=
[
14
,
28
,
42
]
visitas
=
[
1
,
2
,
3
,
4
]
external_stylesheets
=
[
{
"href"
:
(
"https://fonts.googleapis.com/css2?"
"family=Lato:wght@400;700&display=swap"
),
"rel"
:
"stylesheet"
,
},
]
app
=
Dash
(
__name__
,
external_stylesheets
=
external_stylesheets
)
app
.
title
=
"Nutridmex. Inventario de datos"
app
.
layout
=
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
P
(
children
=
"🥑"
,
className
=
"header-emoji"
),
html
.
H1
(
children
=
"Inventario de datos"
,
className
=
"header-title"
),
html
.
P
(
children
=
(
"Recuento de los datos asociados a cada participante "
),
className
=
"header-description"
,
),
],
className
=
"header"
,
),
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
Div
(
children
=
"Mínimo de comidas"
,
className
=
"menu-title"
),
dcc
.
Dropdown
(
id
=
"comidas-filter"
,
options
=
[
{
"label"
:
comida
,
"value"
:
comida
}
for
comida
in
comidas
],
value
=
10
,
clearable
=
False
,
className
=
"dropdown"
,
),
]
),
html
.
Div
(
children
=
[
html
.
Div
(
children
=
"Dias con glucómetro"
,
className
=
"menu-title"
),
dcc
.
Dropdown
(
id
=
"glucosa-filter"
,
options
=
[
{
"label"
:
dia
,
"value"
:
dia
,
}
for
dia
in
glucometro
],
value
=
14
,
clearable
=
False
,
searchable
=
False
,
className
=
"dropdown"
,
),
],
),
html
.
Div
(
children
=
[
html
.
Div
(
children
=
"Visitas"
,
className
=
"menu-title"
),
dcc
.
Dropdown
(
id
=
"visitas-filter"
,
options
=
[
{
"label"
:
visita
,
"value"
:
visita
,
}
for
visita
in
visitas
],
value
=
4
,
clearable
=
False
,
searchable
=
False
,
className
=
"dropdown"
,
),
],
),
],
className
=
"menu"
,
),
html
.
Div
(
children
=
[
html
.
Div
(
children
=
dcc
.
Graph
(
id
=
"comidas-chart"
,
config
=
{
"displayModeBar"
:
False
},
),
className
=
"card"
,
),
html
.
Div
(
children
=
dcc
.
Graph
(
id
=
"glucosa-chart"
,
config
=
{
"displayModeBar"
:
False
},
),
className
=
"card"
,
),
html
.
Div
(
children
=
dcc
.
Graph
(
id
=
"visitas-chart"
,
config
=
{
"displayModeBar"
:
False
},
),
className
=
"card"
,
)
],
className
=
"wrapper"
,
),
]
)
@app.callback
(
Output
(
"comidas-chart"
,
"figure"
),
Output
(
"glucosa-chart"
,
"figure"
),
Output
(
"visitas-chart"
,
"figure"
),
Input
(
"comidas-filter"
,
"value"
),
Input
(
"glucosa-filter"
,
"value"
),
Input
(
"visitas-filter"
,
"value"
),
)
def
update_charts
(
ncomidas
,
glucosa
,
nvisitas
):
filtered_data
=
data
.
query
(
"medibles >= @ncomidas"
)
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 >= @glucosa"
)
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 >= @nvisitas"
)
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'
}))
return
comidas_chart_figure
,
glucosa_chart_figure
,
visitas_chart_figure
if
__name__
==
"__main__"
:
app
.
run_server
(
debug
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment