Skip to content

Commit

Permalink
Merge pull request #78 from unicef-drp/removable_average_option
Browse files Browse the repository at this point in the history
Average line only for bar charts
  • Loading branch information
Amy-Reidy authored Aug 13, 2024
2 parents 9f0a3a9 + 26a893c commit ed3eb12
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 25 deletions.
13 changes: 12 additions & 1 deletion dash_service/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
create_subdomain_buttons,
create_indicator_buttons,
update_domain_with_url,
highlight_option
highlight_option,
average_option,
)

from dash_service.static.page_config import (
Expand Down Expand Up @@ -200,6 +201,16 @@ def update_current_indicator(dropdown_value, active_indicator_buttons, crm_view_
return indicator_button_ids[active_index]['index']
return dropdown_value # Otherwise, return the dropdown value

@callback(
Output('average_option', 'style'),
[
Input({"type": "area_breakdowns", "index": "AIO_AREA"}, "value"),
Input({"type": "area_types", "index": "AIO_AREA"}, "value"),
]
)
def show_average_option(compare, selected_type):
return average_option(compare, selected_type)

@callback(
[
Output('search_by_indicator_div', 'style'),
Expand Down
63 changes: 39 additions & 24 deletions dash_service/pages/transmonee.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,30 +1571,51 @@ def get_base_layout(**kwargs):
[
dbc.Row(
[
# Checkbox and Label
dbc.Col(
[
dbc.Checkbox(
id='show-average-checkbox',
className='custom-checkbox',
value=True,
),
html.Label(
'Show average line',
htmlFor='show-average-checkbox',
style={'margin-top':'3px', 'margin-left': '5px'}
),
],
id='average_option',
style={'display':'none'},
width='auto'
),
# Radio Items
dbc.Col(
dbc.RadioItems(
id={
"type": "area_breakdowns",
"index": "AIO_AREA",
},
value = "TOTAL",
value="TOTAL",
class_name="force-inline-control responsive-radio-items",
inline=True,
),
width="auto",
className="radio-items-col",
),
# Dropdown and label
dbc.Col(
html.Div([
html.P("Select country to highlight:", style={"margin-bottom": "10px", "margin-top": "5px", "margin-right": "5px"}),
dcc.Dropdown(
id="highlighted_country"
),
], style={"display": "none"}),
id = "highlight_option",
),
], style={"display": "none"}),
id="highlight_option",
width="auto",
),
),
],
style={"display": "flex", "align-items": "center"},
)
],
style={
Expand Down Expand Up @@ -1812,25 +1833,6 @@ def get_base_layout(**kwargs):
),
dbc.Col(
[
dbc.Row(
[
dbc.Col(
dbc.Checkbox(
id='show-average-checkbox',
className='custom-checkbox',
value=True,
),
style={"padding":"0px"},
width='auto'
),
dbc.Col(
html.Label('Show average line', htmlFor='show-average-checkbox', style={'margin-top':'3px'}),
style={"padding":"0px"},
width='auto'
),
],
style={"display":"flex", "justifyContent":"center", "marginTop":"25px"},
),
dbc.Row(
[
html.Button(
Expand Down Expand Up @@ -2718,6 +2720,19 @@ def default_compare(compare_options, selected_type, indicator):
return compare_options[0]["value"]


def average_option(compare, selected_type):
if selected_type == "bar" and compare == 'TOTAL':
return {
"padding":"0px",
"display": "flex",
"align-items": "center"
}
else:
return {
"display": "none"
}


def highlight_option(fig_type, indicator, years_slider, countries, country_group, compare):
if fig_type == "line" and indicator:
filters, country_selector, selected_years, country_text = get_filters(
Expand Down

0 comments on commit ed3eb12

Please sign in to comment.