diff --git a/transmonee_dashboard/src/transmonee_dashboard/components.py b/transmonee_dashboard/src/transmonee_dashboard/components.py index 4fe945c4..ea56bde8 100755 --- a/transmonee_dashboard/src/transmonee_dashboard/components.py +++ b/transmonee_dashboard/src/transmonee_dashboard/components.py @@ -37,6 +37,57 @@ def make_brand(**kwargs): ) +@component +def make_header_nav(**kwargs): + return html.Header( + id="header", + className="header", + children=[ + html.Div( + className="container-fluid", + children=[ + html.Div( + className="row", + children=[ + html.Nav( + className="col-12", + id=server.config["NAVBAR_CONTAINER_ID"], + ) + ], + ) + ], + ), + ], + **kwargs, + ) + + +@component +def make_header_nav_old(**kwargs): + return html.Header( + id="header", + className="header", + children=[ + + html.Div( + className="header__bottom", + children=[ + html.Div( + className="header__inner", + children=[ + html.Nav( + className="header__navigation", + id=server.config["NAVBAR_CONTAINER_ID"], + ) + ], + ) + ], + ), + ], + **kwargs, + ) + + @component def make_header(**kwargs): return html.Header( diff --git a/transmonee_dashboard/src/transmonee_dashboard/index.py b/transmonee_dashboard/src/transmonee_dashboard/index.py index c4d9c382..e781187d 100755 --- a/transmonee_dashboard/src/transmonee_dashboard/index.py +++ b/transmonee_dashboard/src/transmonee_dashboard/index.py @@ -4,6 +4,7 @@ from .utils import DashRouter, DashNavBar from .pages import ( child_education, + health, # child_protection, # child_health, # child_poverty, @@ -31,6 +32,7 @@ # ("", home.get_layout), # ("overview", overview.get_layout), ("", child_education.get_layout), + ("health", health.get_layout), # ("child-education", child_education.get_layout), # ("child-protection", child_protection.get_layout), @@ -53,7 +55,7 @@ # is a string corresponding to path of the route (will be prefixed with # 'routes_pathname_prefix') and 'display' is a valid value for the `children` # keyword argument for a Dash component (ie a Dash Component or a string). -nav_items = ( +nav_items_old = ( ("", html.Div([fa("fas fa-home"), "Home"]), []), ("overview", html.Div([fa("fas fa-info-circle"), "Overview"]), []), ( @@ -108,6 +110,13 @@ # ("resources", html.Div([fa("fas fa-database"), "Resources"]), []), ) +nav_items = ( + + ("", html.Div([fa("fas fa-info-circle"), "Education"]), []), + ("health", html.Div([fa("fas fa-medkit"), "Health"]), []), + # ("protection", html.Div([fa("fas fa-bullseye"), "Protection"]), []), +) + nav_items_full_names = { "education": "Education", "child-protection": "Family environment and protection from violence and harmful practices", diff --git a/transmonee_dashboard/src/transmonee_dashboard/layouts.py b/transmonee_dashboard/src/transmonee_dashboard/layouts.py index 0597f65e..1da80059 100755 --- a/transmonee_dashboard/src/transmonee_dashboard/layouts.py +++ b/transmonee_dashboard/src/transmonee_dashboard/layouts.py @@ -7,7 +7,7 @@ import dash_html_components as html import dash_bootstrap_components as dbc -from .components import make_footer, make_header, make_sidebar +from .components import make_footer, make_header, make_sidebar, make_header_nav from .components import fa @@ -48,7 +48,7 @@ def main_default_layout(): return html.Div( [ - # make_header(), + make_header_nav(), html.Br(), dcc.Store(id="store"), dbc.Container( diff --git a/transmonee_dashboard/src/transmonee_dashboard/pages/__init__.py b/transmonee_dashboard/src/transmonee_dashboard/pages/__init__.py index d7a496b2..5ad01330 100755 --- a/transmonee_dashboard/src/transmonee_dashboard/pages/__init__.py +++ b/transmonee_dashboard/src/transmonee_dashboard/pages/__init__.py @@ -43,7 +43,7 @@ def get_endpoint(endpoint_id="UNICEF"): def get_search_countries(countries_cl): all_countries = {"label": "All", "value": "All"} countries_list = [] - #print(countries_cl) + # print(countries_cl) # countries_list = [ # { # "label": key, @@ -56,27 +56,26 @@ def get_search_countries(countries_cl): return countries_list -def _add_tree_level(tree_node, parent_code, codes): - for c in codes: - if "parent" in c and c["parent"] == parent_code: - if "children" not in tree_node: - tree_node["children"] = [] - tree_node["children"].append({"key": c["id"], "title": c["name"]}) - _add_tree_level(tree_node["children"][-1], c["id"], codes) - - def get_codelist(agency, id, version="latest"): cl_id = f"{agency}|{id}|{version}" if cl_id in codelists: - #print("CL " + id + " already downloaded") + # print("CL " + id + " already downloaded") return codelists[cl_id] - #print("CL " + id + " new downloaded") + # print("CL " + id + " new downloaded") cl = Codelist.Codelist() cl.download_codelist(get_endpoint(), agency, id, version=version) codelists[cl_id] = cl.get_codes() return cl.get_codes() +def _add_tree_level(tree_node, parent_code, codes): + for c in codes: + if "parent" in c and c["parent"] == parent_code: + if "children" not in tree_node: + tree_node["children"] = [] + tree_node["children"].append({"key": c["id"], "title": c["name"]}) + _add_tree_level(tree_node["children"][-1], c["id"], codes) + def get_selection_tree(ref_area_cl): codes = get_codelist(ref_area_cl["agency"], ref_area_cl["id"]) @@ -120,6 +119,16 @@ def get_dataset(cfg_data, years=None, countries=[], recent_data=False): return df +def get_col_unique(df: Dataflow, col_id: str) -> list: + if not col_id in df: + return [] + #Unique and remove nans + ret = df[col_id].unique() + ret = ret[~pd.isnull(ret)] + return ret + + + # def get_dataflow_struct(cfg_data): # df_id = f'{get_endpoint()} | {cfg_data["agency"]} | {cfg_data["id"]} | {cfg_data["version"]}' # if df_id in sdmx_dataflows_structs: diff --git a/transmonee_dashboard/src/transmonee_dashboard/pages/base_page.py b/transmonee_dashboard/src/transmonee_dashboard/pages/base_page.py index 260b27a2..c440953a 100644 --- a/transmonee_dashboard/src/transmonee_dashboard/pages/base_page.py +++ b/transmonee_dashboard/src/transmonee_dashboard/pages/base_page.py @@ -34,7 +34,8 @@ get_dataset, get_search_countries, # get_indicator_name, - get_codelist + get_codelist, + get_col_unique ) # set defaults @@ -42,6 +43,14 @@ px.defaults.color_continuous_scale = px.colors.sequential.BuGn px.defaults.color_discrete_sequence = px.colors.qualitative.Dark24 +#language shouold be read from a param if forced or from the browser +lang = "en" +# move this elsewhere +translations = { + "en": {"REF_AREA": "Geographic areas"}, + "pt": {"REF_AREA": "Geographic areas [PT]"} +} + colours = [ "primary", "success", @@ -144,7 +153,7 @@ def make_area(area_name): }, switch=True, # style=exclude_outliers_style, - style={"display":"none"} + style={"display": "none"} ), html.Br(), @@ -180,6 +189,7 @@ def get_base_layout(**kwargs): cfg = kwargs.get("cfg") main_title = cfg["main_title"] cl_indicators = get_codelist("BRAZIL_CO", "CL_BRAZILCO_INDICATORS") + cl_units = get_codelist("UNICEF", "CL_UNIT_MEASURE") selection_tree = get_selection_tree(cfg["ddl_ref_areas_cl"]) ''' @@ -286,7 +296,7 @@ def get_base_layout(**kwargs): # style=country_dropdown_style, # ), dbc.DropdownMenu( - label=f"Countries: {'len(countries)'}", + label=f"{translations[lang]['REF_AREA']}: {'len(countries)'}", id="collapse-countries-button", className="m-2", color="info", @@ -300,7 +310,8 @@ def get_base_layout(**kwargs): # checked=["0"], checked=selection_tree["checked"], # selected=[], - expanded=["0"], + # expanded=["0", "BR"], + expanded=selection_tree["checked"], # data=[] data=selection_tree["data"], ), @@ -511,7 +522,6 @@ def apply_filters( # ctx = dash.callback_context # selected = ctx.triggered[0]["prop_id"].split(".")[0] - # selections = dict( # theme=current_theme, # indicators_dict=indicators, @@ -540,7 +550,7 @@ def apply_filters( f"Years: {selected_years[0]} - {selected_years[-1]}", # "Countries: {}".format(country_text), # "Countries: {}".format("UPDATED"), - f"Countries: {str(len(sel_country_codes))} selected", + f"{translations[lang]['REF_AREA']}: {str(len(sel_country_codes))} selected", ) @@ -588,7 +598,6 @@ def indicator_card( ) # def show_cards(selections, current_cards, indicators_dict): def show_cards(selections, current_cards, page_cfg): - cards = [ indicator_card( selections, @@ -730,6 +739,7 @@ def main_figure(indicator, show_historical_data, selections, cfg): ref_areas = selections["countries"] cl_countries = get_codelist("BRAZIL_CO", "CL_BRAZIL_REF_AREAS") + cl_units = get_codelist("UNICEF", "CL_UNIT_MEASURE") if latest_data: data = get_dataset(series, recent_data=True, countries=ref_areas) @@ -741,8 +751,12 @@ def main_figure(indicator, show_historical_data, selections, cfg): return EMPTY_CHART, "" df_countries = pd.DataFrame(columns=["name", "id"], data=cl_countries) + df_units = pd.DataFrame(columns=["name", "id"], data=cl_units) data = data.merge(df_countries, how="left", left_on="REF_AREA", right_on="id") + # data = data.drop(columns=["id"]) + # data = data.rename(columns={"name":"REF_AREA_NAME"}) + # data = data.merge(cl_units, how="left", left_on="UNIT_MEASURE", right_on="id") DEFAULT_LABELS = { "REF_AREA": "Geographic area", @@ -763,6 +777,13 @@ def main_figure(indicator, show_historical_data, selections, cfg): # if len(data[data["CODE"] == indicator]["Unit_name"].astype(str).unique()) > 0 # else "" # ) + + # TODO this code seems to be duplicated in area_figure, merge the code + source = "" + sources = get_col_unique(data, "DATA_SOURCE") + if len(sources) > 0: + source = ", ".join(sources) + # df_indicator_sources = df_sources[df_sources["Code"] == indicator] # unique_indicator_sources = df_indicator_sources["Source_Full"].unique() # source = ( @@ -800,7 +821,6 @@ def main_figure(indicator, show_historical_data, selections, cfg): # layout=main_figure.layout, # ) - source = "" source_link = "" return main_figure, html.A(html.P(source), href=source_link, target="_blank") @@ -861,6 +881,7 @@ def area_figure( cl_countries = get_codelist("BRAZIL_CO", "CL_BRAZIL_REF_AREAS") df_countries = pd.DataFrame(columns=["name", "id"], data=cl_countries) + df_countries = df_countries.rename(columns={"name":"REF_AREA_l"}) data = data.merge(df_countries, how="left", left_on="REF_AREA", right_on="id") @@ -895,6 +916,12 @@ def area_figure( # if len(data[data["CODE"] == indicator]["Unit_name"].astype(str).unique()) > 0 # else "" # ) + + # TODO this code seems to be duplicated in main_figure, merge the code + source = "" + sources = get_col_unique(data, "DATA_SOURCE") + if len(sources) > 0: + source = ", ".join(sources) # df_indicator_sources = df_sources[df_sources["Code"] == indicator] # unique_indicator_sources = df_indicator_sources["Source_Full"].unique() # source = ( @@ -908,7 +935,6 @@ def area_figure( # else "" # ) - source = "" source_link = "" # options["labels"] = DEFAULT_LABELS.copy() @@ -920,6 +946,7 @@ def area_figure( "AGE": "Current age", "EDUCATION_LEVEL": "Education level", "TIME_PERIOD": "Time period", + "REF_AREA_l":"Geographic area" } options["labels"] = DEFAULT_LABELS.copy() @@ -933,6 +960,7 @@ def area_figure( ind = list(data["INDICATOR"].unique())[0] indicator_name = next(item for item in cl_indicators if item["id"] == ind) indicator_name = indicator_name["name"] + # cl_countries = get_codelist("BRAZIL_CO", "CL_BRAZIL_REF_AREAS") # set the chart title, wrap the text when the indicator name is too long chart_title = textwrap.wrap( diff --git a/transmonee_dashboard/src/transmonee_dashboard/pages/child_education.py b/transmonee_dashboard/src/transmonee_dashboard/pages/child_education.py index 4f46841e..0ee163fa 100644 --- a/transmonee_dashboard/src/transmonee_dashboard/pages/child_education.py +++ b/transmonee_dashboard/src/transmonee_dashboard/pages/child_education.py @@ -132,7 +132,7 @@ "graphs": { "bar": { "options": dict( - x="name", + x="REF_AREA_l", y="OBS_VALUE", barmode="group", # text="TIME_PERIOD", @@ -174,7 +174,7 @@ "graphs": { "bar": { "options": dict( - x="name", + x="REF_AREA_l", y="OBS_VALUE", barmode="group", # text="TIME_PERIOD", @@ -290,7 +290,7 @@ "graphs": { "bar": { "options": dict( - x="name", + x="REF_AREA_l", y="OBS_VALUE", barmode="group", # text="TIME_PERIOD", @@ -367,7 +367,7 @@ "graphs": { "bar": { "options": dict( - x="name", + x="REF_AREA_l", y="OBS_VALUE", barmode="group", # text="TIME_PERIOD", diff --git a/transmonee_dashboard/src/transmonee_dashboard/pages/health.py b/transmonee_dashboard/src/transmonee_dashboard/pages/health.py new file mode 100644 index 00000000..3e7107d8 --- /dev/null +++ b/transmonee_dashboard/src/transmonee_dashboard/pages/health.py @@ -0,0 +1,720 @@ +from collections import defaultdict +import plotly.express as px + +# from . import data, years +from .base_page import get_base_layout + +cfg = { + "ddl_ref_areas_cl": { + "agency": "BRAZIL_CO", + "id": "CL_BRAZIL_REF_AREAS", + }, + "main_title": "Health", + "THEMES": { + "IMMUNIZATION": { + "NAME": "Immunization", + "CARDS": [ + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "IMUNOPOLIO", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "% of Polio immunization coverage", + }, + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "IMUNOTRIPLICED1", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "% of Triple Viral D1 immunization coverage (Measles, mumps, and rubella)", + }, + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "IMUNOTRIPLICEDTP", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "% of Triple bacterial DTP immunization coverage (Diphtheria, tetanus, and whooping cough)", + } + ], + "MAIN": { + "options": { + "locations": "REF_AREA", + "featureidkey": "id", + "color": "OBS_VALUE", + "color_continuous_scale": "gnbu", + "mapbox_style": "carto-positron", + "zoom": 3, + "center": {"lat": -11.7462, "lon": -53.222}, + "opacity": 0.5, + "labels": { + "OBS_VALUE": "Value", + "REF_AREA": "ISO3 Code", + "TIME_PERIOD": "Year", + # "REF_AREA": "Country", + "name": "Country" + }, + "hover_data": { + "OBS_VALUE": True, + "REF_AREA": False, + "name": True, + "TIME_PERIOD": True, + }, + "animation_frame": "TIME_PERIOD", + "height": 750}, + "name": "Immunization", + # "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Primary to upper secondary aged Children and Adolescents", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "IMUNOPOLIO", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - early years of elementary school" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "IMUNOTRIPLICED1", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - final years of Elementary School" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "IMUNOTRIPLICEDTP", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - High School" + }, + ], + }, + "AREA_1": { + "name": "Education entry and transition", + "graphs": { + "bar": { + "options": dict( + x="REF_AREA_l", + y="OBS_VALUE", + barmode="group", + # text="TIME_PERIOD", + text="OBS_VALUE", + hover_name="TIME_PERIOD", + ), + # "compare": "Sex", + }, + "line": { + "options": dict( + x="TIME_PERIOD", + y="OBS_VALUE", + color="name", + hover_name="name", + line_shape="spline", + render_mode="svg", + ), + "trace_options": dict(mode="lines+markers"), + }, + }, + "default_graph": "bar", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "IMUNOPOLIO", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - final years of elementary school 1" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "IMUNOTRIPLICED1", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - early years of elementary school 2" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "IMUNOTRIPLICEDTP", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - early years of elementary school 2" + }, + ], + "default": "EDUNF_ROFST_L1", + }, + "AREA_2": { + "name": "Education entry and transition", + "graphs": { + "bar": { + "options": dict( + x="REF_AREA_l", + y="OBS_VALUE", + barmode="group", + # text="TIME_PERIOD", + text="OBS_VALUE", + hover_name="TIME_PERIOD", + ), + # "compare": "Sex", + }, + "line": { + "options": dict( + x="TIME_PERIOD", + y="OBS_VALUE", + color="name", + hover_name="name", + line_shape="spline", + render_mode="svg", + ), + "trace_options": dict(mode="lines+markers"), + }, + }, + "default_graph": "bar", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "IMUNOTRIPLICED1", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + } + ], + "default": "EDUNF_ROFST_L1", + }, + + }, + "MNCH": { + "NAME": "Maternal, Newborn and Child Health", + "CARDS": [ + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "PREMATUROPORCENTAGEM", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "TDIANOSFINAISPUB", + "suffix": "% of premature births - less than 37 weeks", + }, + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "MORTALIDADEINFANTIL", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Infant mortality rate", + }, + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "RAZAOMORTALIDADEMAT", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Maternal mortality ratio", + } + + ], + + "MAIN": { + "options": { + "locations": "REF_AREA", + "featureidkey": "id", + "color": "OBS_VALUE", + "color_continuous_scale": "gnbu", + "mapbox_style": "carto-positron", + "zoom": 3, + "center": {"lat": -11.7462, "lon": -53.222}, + "opacity": 0.5, + "labels": { + "OBS_VALUE": "Value", + "REF_AREA": "ISO3 Code", + "TIME_PERIOD": "Year", + # "REF_AREA": "Country", + "name": "Country" + }, + "hover_data": { + "OBS_VALUE": True, + "REF_AREA": False, + "name": True, + "TIME_PERIOD": True, + }, + "animation_frame": "TIME_PERIOD", + "height": 750}, + "name": "Maternal, Newborn and Child Health", + # "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Primary to upper secondary aged Children and Adolescents", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14", "AGE": "Y10T14", + "EDUCATION_LEVEL": "_T"}, + "label": "Children born alive to mothers 10 to 14 years of age" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14PERCENTAGEM", "AGE": "Y10T14", + "EDUCATION_LEVEL": "_T"}, + "label": "% of live births to mothers aged 10 to 14 years" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14PERCENTAGEM", "AGE": "Y15T19", + "EDUCATION_LEVEL": "_T"}, + "label": "% of live births to mothers aged 15 to 19 years" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PREMATUROPORCENTAGEM", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "% of premature births - less than 37 weeks" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADEINFANTIL", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "Infant mortality rate" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADEINFANCIAMENOR5", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "Childhood mortality rate - under 5 years old" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADENEONATAL", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "Neonatal mortality rate - 0 to 27 days" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "RAZAOMORTALIDADEMAT", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "Maternal mortality ratio" + }, + ], + + }, + + "AREA_1": { + "name": "Mortality", + "graphs": { + "bar": { + "options": dict( + x="REF_AREA_l", + y="OBS_VALUE", + barmode="group", + # text="TIME_PERIOD", + text="OBS_VALUE", + hover_name="TIME_PERIOD", + ), + # "compare": "Sex", + }, + "line": { + "options": dict( + x="TIME_PERIOD", + y="OBS_VALUE", + color="name", + hover_name="name", + line_shape="spline", + render_mode="svg", + ), + "trace_options": dict(mode="lines+markers"), + }, + }, + + "default_graph": "bar", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADEINFANTIL", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADEINFANCIAMENOR5", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADENEONATAL", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "RAZAOMORTALIDADEMAT", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + }, + ], + }, + + "AREA_2": { + "name": "Births", + "graphs": { + "bar": { + "options": dict( + x="name", + y="OBS_VALUE", + barmode="group", + # text="TIME_PERIOD", + text="OBS_VALUE", + hover_name="TIME_PERIOD", + ), + # "compare": "Sex", + }, + "line": { + "options": dict( + x="TIME_PERIOD", + y="OBS_VALUE", + color="name", + hover_name="name", + line_shape="spline", + render_mode="svg", + ), + "trace_options": dict(mode="lines+markers"), + }, + }, + "default_graph": "bar", + + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14", "AGE": "Y10T14", + "EDUCATION_LEVEL": "_T"}, + "label": "Children born alive to mothers 10 to 14 years of age" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14PERCENTAGEM", "AGE": "Y10T14", + "EDUCATION_LEVEL": "_T"}, + "label": "% of live births to mothers aged 10 to 14 years" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14", "AGE": "Y15T19", + "EDUCATION_LEVEL": "_T"}, + "label": "Children born alive to mothers 15 to 19 years of age" + }, + + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14PERCENTAGEM", "AGE": "Y15T19", + "EDUCATION_LEVEL": "_T"}, + "label": "% of live births to mothers aged 15 to 19 years" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PREMATUROPORCENTAGEM", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + }, + + ], + }, + + "AREA_3": { + "name": "Maternal, Newborn and Child Health", + "graphs": { + "bar": { + "options": dict( + x="name", + y="OBS_VALUE", + barmode="group", + # text="TIME_PERIOD", + text="OBS_VALUE", + hover_name="TIME_PERIOD", + ), + # "compare": "Sex", + }, + "line": { + "options": dict( + x="TIME_PERIOD", + y="OBS_VALUE", + color="name", + hover_name="name", + line_shape="spline", + render_mode="svg", + ), + "trace_options": dict(mode="lines+markers"), + }, + }, + "default_graph": "bar", + + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14", "AGE": "Y10T14", + "EDUCATION_LEVEL": "_T"}, + "label": "Children born alive to mothers 10 to 14 years of age" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14PERCENTAGEM", "AGE": "Y10T14", + "EDUCATION_LEVEL": "_T"}, + "label": "% of live births to mothers aged 10 to 14 years" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "NASCIMENTOS10A14PERCENTAGEM", "AGE": "Y15T19", + "EDUCATION_LEVEL": "_T"}, + "label": "% of live births to mothers aged 15 to 19 years" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PREMATUROPORCENTAGEM", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "% of premature births - less than 37 weeks" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADEINFANTIL", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "Infant mortality rate" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADEINFANCIAMENOR5", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "Childhood mortality rate - under 5 years old" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "MORTALIDADENEONATAL", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "Neonatal mortality rate - 0 to 27 days" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "RAZAOMORTALIDADEMAT", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + "label": "Maternal mortality ratio" + }, + ], + } + + }, + "VECTOR_DISEASE": { + "NAME": "Vector-borne diseases", + "CARDS": [ + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "DENGUEINCIDENCIA", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Dengue incidence rate", + }, + + ], + "MAIN": { + "options": { + "locations": "REF_AREA", + "featureidkey": "id", + "color": "OBS_VALUE", + "color_continuous_scale": "gnbu", + "mapbox_style": "carto-positron", + "zoom": 3, + "center": {"lat": -11.7462, "lon": -53.222}, + "opacity": 0.5, + "labels": { + "OBS_VALUE": "Value", + "REF_AREA": "ISO3 Code", + "TIME_PERIOD": "Year", + # "REF_AREA": "Country", + "name": "Country" + }, + "hover_data": { + "OBS_VALUE": True, + "REF_AREA": False, + "name": True, + "TIME_PERIOD": True, + }, + "animation_frame": "TIME_PERIOD", + "height": 750}, + "name": "Vector-borne diseases", + # "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Primary to upper secondary aged Children and Adolescents", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "DENGUEINCIDENCIA", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - early years of elementary school" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "DENGUETOTAL", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - final years of Elementary School" + }, + ], + }, + "AREA_1": { + "name": "Vector-borne diseases", + "graphs": { + "bar": { + "options": dict( + x="REF_AREA_l", + y="OBS_VALUE", + barmode="group", + # text="TIME_PERIOD", + text="OBS_VALUE", + hover_name="TIME_PERIOD", + ), + # "compare": "Sex", + }, + "line": { + "options": dict( + x="TIME_PERIOD", + y="OBS_VALUE", + color="name", + hover_name="name", + line_shape="spline", + render_mode="svg", + ), + "trace_options": dict(mode="lines+markers"), + }, + }, + "default_graph": "bar", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "DENGUEINCIDENCIA", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - final years of elementary school 1" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "DENGUETOTAL", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - early years of elementary school 2" + }, + ], + }, + }, + + "NUTRITION": { + "NAME": "Nutrition", + "CARDS": [ + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "PESO0A5", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Overweight: % of children aged 0 to 5 years with high weight for their age" + }, + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "PESO5A9", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Overweight: % of children aged 5 to 9 years who are overweight for their age", + }, + {"data": {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": { + "REF_AREA": "BR", + "INDICATOR": "PESOADOLESCENTES", + "AGE": "_T", + "EDUCATION_LEVEL": "_T" + }, + "lastnobservations": 1}, + "name": "", + "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Overweight: overweight adolescents aged 10 to 19", + }, + + ], + "MAIN": { + "options": { + "locations": "REF_AREA", + "featureidkey": "id", + "color": "OBS_VALUE", + "color_continuous_scale": "gnbu", + "mapbox_style": "carto-positron", + "zoom": 3, + "center": {"lat": -11.7462, "lon": -53.222}, + "opacity": 0.5, + "labels": { + "OBS_VALUE": "Value", + "REF_AREA": "ISO3 Code", + "TIME_PERIOD": "Year", + # "REF_AREA": "Country", + "name": "Country" + }, + "hover_data": { + "OBS_VALUE": True, + "REF_AREA": False, + "name": True, + "TIME_PERIOD": True, + }, + "animation_frame": "TIME_PERIOD", + "height": 750}, + "name": "Nutrition", + # "indicator": "EDUNF_OFST_L1,EDUNF_OFST_L2,EDUNF_OFST_L3", + "suffix": "Primary to upper secondary aged Children and Adolescents", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PESO0A5", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - early years of elementary school" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PESO5A9", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - final years of Elementary School" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PESOADOLESCENTES", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - final years of Elementary School" + }, + ], + }, + "AREA_1": { + "name": "Nutrition", + "graphs": { + "bar": { + "options": dict( + x="name", + y="OBS_VALUE", + barmode="group", + # text="TIME_PERIOD", + text="OBS_VALUE", + hover_name="TIME_PERIOD", + ), + # "compare": "Sex", + }, + "line": { + "options": dict( + x="TIME_PERIOD", + y="OBS_VALUE", + color="name", + hover_name="name", + line_shape="spline", + render_mode="svg", + ), + "trace_options": dict(mode="lines+markers"), + }, + }, + "default_graph": "bar", + "data": [ + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PESO0A5", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - final years of elementary school 1" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PESO5A9", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - early years of elementary school 2" + }, + {"agency": "BRAZIL_CO", "id": "BRAZIL_CO", "version": "1.0", + "dq": {"REF_AREA": "", "INDICATOR": "PESOADOLESCENTES", "AGE": "_T", + "EDUCATION_LEVEL": "_T"}, + # "label": "% of school dropout - early years of elementary school 2" + }, + ], + }, + + }, + } +} + + +def get_layout(**kwargs): + # kwargs["indicators"] = indicators_dict + # kwargs["main_title"] = main_title + # kwargs["main_title"] = cfg["main_title"] + kwargs["cfg"] = cfg + return get_base_layout(**kwargs)