Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pmall
app_OP
Commits
a3b1ae67
Commit
a3b1ae67
authored
Jul 28, 2020
by
Samuël Weber
Browse files
do not use Store
parent
cafe8695
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/app_estimateOP.py
View file @
a3b1ae67
...
...
@@ -20,7 +20,6 @@ NCLICKED = 0
layout
=
dbc
.
Container
(
id
=
"container-results"
,
children
=
[
dcc
.
Store
(
id
=
'memory-op'
),
dbc
.
Row
([
dbc
.
Col
(
id
=
"upload-col"
,
...
...
@@ -87,23 +86,25 @@ layout = dbc.Container(
html
.
Div
(
id
=
'output-data-op'
,
children
=
[
dash_table
.
DataTable
(
id
=
"datatable-op"
,
sort_action
=
"native"
,
sort_mode
=
"multi"
,
filter_action
=
'native'
,
page_size
=
5
,
export_columns
=
'all'
,
export_format
=
"xlsx"
,
style_cell
=
{
'overflow'
:
'hidden'
,
'textOverflow'
:
'ellipsis'
,
'maxWidth'
:
0
,
},
),
dcc
.
Loading
(
dash_table
.
DataTable
(
id
=
"datatable-op"
,
sort_action
=
"native"
,
sort_mode
=
"multi"
,
filter_action
=
'native'
,
page_size
=
5
,
export_columns
=
'all'
,
export_format
=
"xlsx"
,
style_cell
=
{
'overflow'
:
'hidden'
,
'textOverflow'
:
'ellipsis'
,
'maxWidth'
:
0
,
},
),
)
]
),
className
=
'col-
9
'
className
=
'col-
10
'
),
],
className
=
"justify-content-center"
...
...
@@ -196,25 +197,6 @@ def update_output(content, name, clicked):
)
return
(
data
,
columns
,
flash
)
@
app
.
callback
(
Output
(
'memory-op'
,
'data'
),
[
Input
(
'datatable'
,
'derived_virtual_data'
),
Input
(
'option-OPtype'
,
'value'
),
])
def
update_storage
(
dfpm
,
OPtype
):
if
dfpm
is
None
or
len
(
dfpm
)
==
0
:
raise
PreventUpdate
dfpm
=
pd
.
DataFrame
(
dfpm
)
dfpm
[
"Date"
]
=
pd
.
to_datetime
(
dfpm
[
"Date"
])
dfop
=
pyOPestimator
.
get_op_from_pm10
(
dfpm
,
OPtype
)
factors
=
list
(
dfop
.
drop
([
"Date"
,
"month"
,
"PM10"
,
"totalOP"
],
axis
=
1
).
columns
)
# dfop = dfop.melt(id_vars=["Date", "totalOP", "month", "PM10"], var_name="Factor",
# value_name="OP")
return
dfop
.
to_dict
(
'record'
)
@
app
.
callback
(
Output
(
'graph-abs'
,
'figure'
),
[
Input
(
'datatable'
,
'derived_virtual_data'
),
...
...
@@ -275,14 +257,21 @@ def update_graph(dfpm, OPtype, temporality):
Output
(
'datatable-op'
,
'columns'
)
],
[
Input
(
'memory-op'
,
'data'
)
Input
(
'datatable'
,
'derived_virtual_data'
),
Input
(
'option-OPtype'
,
'value'
),
],
[
State
(
'option-OPtype'
,
'value'
),
]
)
def
add_op_to_datatable
(
dfop
,
OPtype
):
df
=
pd
.
DataFrame
(
dfop
)
def
add_op_to_datatable
(
dfpm
,
OPtype
):
if
dfpm
is
None
or
len
(
dfpm
)
==
0
:
raise
PreventUpdate
dfpm
=
pd
.
DataFrame
(
dfpm
)
dfpm
[
"Date"
]
=
pd
.
to_datetime
(
dfpm
[
"Date"
])
dfop
=
pyOPestimator
.
get_op_from_pm10
(
dfpm
,
OPtype
)
factors
=
list
(
dfop
.
drop
([
"Date"
,
"month"
,
"PM10"
,
"totalOP"
],
axis
=
1
).
columns
)
df
=
dfop
.
copy
()
df
[
"Date"
]
=
pd
.
to_datetime
(
df
[
"Date"
])
df
[
"total_{}"
.
format
(
OPtype
)]
=
df
[
"totalOP"
]
df
.
drop
(
"totalOP"
,
axis
=
1
,
inplace
=
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