Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Christophe Benz
observatoire-dash
Commits
9c950a56
Commit
9c950a56
authored
Jan 10, 2020
by
Pierre Dittgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use camel cases in Python names
parent
1dceb447
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
app.py
app.py
+7
-7
No files found.
app.py
View file @
9c950a56
...
...
@@ -25,7 +25,7 @@ def noneIfEmpty(val):
return
None
if
val
==
""
else
val
def
compute
DepD
ropdown
O
ptions
(
reg_code
=
None
):
def
compute
_dept_d
ropdown
_o
ptions
(
reg_code
=
None
):
"""Compute department dropdown option list."""
dep_list
=
[
{
"label"
:
dep
[
1
],
"value"
:
dep
[
0
]}
...
...
@@ -34,7 +34,7 @@ def computeDepDropdownOptions(reg_code=None):
return
[{
"label"
:
"-- département --"
,
"value"
:
""
}]
+
dep_list
def
compute
BarF
igure
(
reg_code
=
None
,
dep_code
=
None
):
def
compute
_bar_f
igure
(
reg_code
=
None
,
dep_code
=
None
):
"""Build a bar figure from given region and department code."""
df
=
app_data
.
df
...
...
@@ -62,8 +62,8 @@ app.layout = html.Div(
],
value
=
""
,
),
dcc
.
Dropdown
(
id
=
"dep_dd"
,
options
=
compute
DepD
ropdown
O
ptions
(),
value
=
""
,),
dcc
.
Graph
(
id
=
"type_bar"
,
figure
=
compute
BarF
igure
()),
dcc
.
Dropdown
(
id
=
"dep_dd"
,
options
=
compute
_dept_d
ropdown
_o
ptions
(),
value
=
""
,),
dcc
.
Graph
(
id
=
"type_bar"
,
figure
=
compute
_bar_f
igure
()),
]
)
...
...
@@ -72,9 +72,9 @@ app.layout = html.Div(
Output
(
component_id
=
"dep_dd"
,
component_property
=
"options"
),
[
Input
(
component_id
=
"reg_dd"
,
component_property
=
"value"
)],
)
def
update_dep_dropdown_options
(
reg_code
):
def
update_dep
t
_dropdown_options
(
reg_code
):
"""Update department list when a region has been chosen."""
return
compute
DepD
ropdown
O
ptions
(
reg_code
=
noneIfEmpty
(
reg_code
))
return
compute
_dept_d
ropdown
_o
ptions
(
reg_code
=
noneIfEmpty
(
reg_code
))
@
app
.
callback
(
...
...
@@ -95,7 +95,7 @@ def update_dep_dropdown_value(reg_code):
)
def
update_type_bar
(
reg_code
,
dep_code
):
"""Update bar chart when one dropdown value changes."""
return
compute
BarF
igure
(
return
compute
_bar_f
igure
(
reg_code
=
noneIfEmpty
(
reg_code
),
dep_code
=
noneIfEmpty
(
dep_code
)
)
...
...
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