Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cards revision #134

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions transmonee_dashboard/src/transmonee_dashboard/pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
"HT_INS_COV",
# indicators for sub-topic-2
"CME_MRY0T4",
"CME_TMY0T4",
"CME_MRM0",
"MNCH_MMR",
"MNCH_SAB",
Expand Down Expand Up @@ -1200,6 +1201,7 @@
{"Participation": "Education access and participation"},
{"Quality": "Learning quality and skills"},
{"System": "Education system"},
{"Leisure": "Leisure and Culture"},
],
"Family Environment and Protection": [
{"Violence": "Violence against Children and Women"},
Expand Down Expand Up @@ -1232,15 +1234,15 @@
"Participation and Civil Rights": [
{"Registration": "Birth registration and identity"},
{"Information": "Information, Internet and Protection of privacy"},
{"Leisure": "Education, Leisure, and Culture"},
],
}

dict_topics_subtopics = {
"Education, Leisure, and Culture": [
"Education access and participation",
"Learning quality and skills",
"Education System",
"Education system",
"Leisure and Culture",
],
"Family Environment and Protection": [
"Violence against Children and Women",
Expand Down Expand Up @@ -1273,7 +1275,6 @@
"Participation and Civil Rights": [
"Birth registration and identity",
"Information, Internet and Protection of privacy",
"Education, Leisure, and Culture",
],
}

Expand Down Expand Up @@ -1404,10 +1405,9 @@ def get_sector(subtopic):
df_topics_subtopics.dropna(subset=["Issue"], inplace=True)
df_sources = pd.merge(df_topics_subtopics, snapshot_df, how="outer", on=["Code"])
# assign source = TMEE to all indicators without a source since they all come from excel data collection files
df_sources.fillna("TMEE", inplace=True)
df_sources["Source"].fillna("TMEE", inplace=True)
# Concatenate sectors/subtopics dictionary value lists
sitan_subtopics = sum(dict_topics_subtopics.values(), [])

df_sources.rename(
columns={
"Name_x": "Indicator",
Expand Down
261 changes: 131 additions & 130 deletions transmonee_dashboard/src/transmonee_dashboard/pages/base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@

# set defaults
pio.templates.default = "plotly_white"
px.defaults.color_continuous_scale = px.colors.sequential.BuGn
px.defaults.color_continuous_scale = px.colors.sequential.Viridis
# this predefined series contains 10 different colors.
# px.defaults.color_discrete_sequence = px.colors.qualitative.G10
px.defaults.color_discrete_sequence = [
"#1cabe2",
"#80bd41",
Expand All @@ -60,73 +62,131 @@


def make_area(area_name):
area = dbc.Card(
[
dbc.CardHeader(
id={"type": "area_title", "index": area_name},
),
dbc.CardBody(
[
dcc.Dropdown(
id={"type": "area_options", "index": area_name},
className="dcc_control",
),
html.Br(),
dbc.RadioItems(
id={"type": "area_types", "index": area_name},
# TODO: read chart types from config when we add more types
options=[
{"label": "Line", "value": "line"},
{"label": "Bar", "value": "bar"},
],
inline=True,
),
dcc.Graph(
id={"type": "area", "index": area_name},
),
dbc.Checklist(
options=[
{
"label": "Exclude outliers ",
"value": 1,
}
],
value=[1],
id={
"type": "exclude_outliers_toggle",
"index": area_name,
},
switch=True,
style={
"paddingLeft": 20,
},
),
html.Br(),
dbc.RadioItems(
id={"type": "area_breakdowns", "index": area_name},
inline=True,
),
html.Div(
fa("fas fa-info-circle"),
id=f"{area_name.lower()}_info",
className="float-right",
),
dbc.Popover(
[
dbc.PopoverHeader("Sources"),
dbc.PopoverBody(
id={"type": "area_sources", "index": area_name},
),
],
id="hover",
target=f"{area_name.lower()}_info",
trigger="hover",
),
]
),
],
id={"type": "area_parent", "index": area_name},
)
if area_name == "MAIN":
area = dbc.Card(
[
dbc.CardHeader(
id={"type": "area_title", "index": area_name},
),
dbc.CardBody(
[
dcc.Dropdown(
id={
"type": "area_options",
"index": area_name,
},
style={
"zIndex": "11",
},
),
dbc.FormGroup(
[
dbc.Checkbox(
id="latest-data-toggle",
className="custom-control-input",
),
dbc.Label(
"Show latest year",
html_for="latest-data-toggle",
className="custom-control-label",
color="primary",
),
],
className="custom-control custom-switch m-2",
check=True,
inline=True,
),
# dcc.Graph(id={"type": "area", "index": area_name}),
dcc.Graph(id="main_area"),
html.Div(
fa("fas fa-info-circle"),
id="main_area_info",
className="float-right",
),
dbc.Popover(
[
dbc.PopoverHeader("Sources"),
dbc.PopoverBody(
# id={"type": "area_sources", "index": area_name},
id="main_area_sources"
),
],
id="hover",
target=f"{area_name.lower()}_area_info",
trigger="hover",
),
]
),
],
)
else:
area = dbc.Card(
[
dbc.CardHeader(
id={"type": "area_title", "index": area_name},
),
dbc.CardBody(
[
dcc.Dropdown(
id={"type": "area_options", "index": area_name},
className="dcc_control",
),
html.Br(),
dbc.RadioItems(
id={"type": "area_types", "index": area_name},
# TODO: read chart types from config when we add more types
options=[
{"label": "Line", "value": "line"},
{"label": "Bar", "value": "bar"},
],
inline=True,
),
dcc.Graph(
id={"type": "area", "index": area_name},
),
dbc.Checklist(
options=[
{
"label": "Exclude outliers ",
"value": 1,
}
],
value=[1],
id={
"type": "exclude_outliers_toggle",
"index": area_name,
},
switch=True,
style={
"paddingLeft": 20,
},
),
html.Br(),
dbc.RadioItems(
id={"type": "area_breakdowns", "index": area_name},
inline=True,
),
html.Div(
fa("fas fa-info-circle"),
id=f"{area_name.lower()}_info",
className="float-right",
),
dbc.Popover(
[
dbc.PopoverHeader("Sources"),
dbc.PopoverBody(
id={"type": "area_sources", "index": area_name},
),
],
id="hover",
target=f"{area_name.lower()}_info",
trigger="hover",
),
]
),
],
id={"type": "area_parent", "index": area_name},
)
return area


Expand Down Expand Up @@ -282,66 +342,9 @@ def get_base_layout(**kwargs):
justify="center",
),
html.Br(),
# start filter controls row
dbc.Row(
[
dbc.Col(
dbc.Card(
[
dbc.CardHeader(
id={"type": "area_title", "index": "MAIN"},
),
dbc.CardBody(
[
dcc.Dropdown(
id={
"type": "area_options",
"index": "MAIN",
},
style={
"zIndex": "11",
},
),
dbc.FormGroup(
[
dbc.Checkbox(
id="latest-data-toggle",
className="custom-control-input",
),
dbc.Label(
"Show latest year",
html_for="latest-data-toggle",
className="custom-control-label",
color="primary",
),
],
className="custom-control custom-switch m-2",
check=True,
inline=True,
),
dcc.Graph(id="main_area"),
html.Div(
fa("fas fa-info-circle"),
id="main_area_info",
className="float-right",
),
dbc.Popover(
[
dbc.PopoverHeader("Sources"),
dbc.PopoverBody(id="main_area_sources"),
],
id="hover",
target="main_area_info",
trigger="hover",
),
]
),
],
),
),
],
dbc.CardDeck(
[make_area(area) for area in ["MAIN"]],
),
# end filter controls row
html.Br(),
dbc.CardDeck(
[make_area(area) for area in ["AREA_1", "AREA_2"]],
Expand Down Expand Up @@ -1027,9 +1030,7 @@ def set_default_compare(
Input("latest-data-toggle", "checked"),
Input("store", "data"),
],
[
State("indicators", "data"),
],
State("indicators", "data"),
)
def main_figure(indicator, latest_data, selections, indicators_dict):

Expand Down
Loading