コード例 #1
0
ファイル: view.py プロジェクト: mutesasira/cehs
    reference_year=reference_date.dropdown_objects[0].value,
    reference_month=reference_date.dropdown_objects[1].value,
)

init_data_set = define_datasets(static=static, dfs=dfs, **CONTROLS)

########################################
#              DATACARDS               #
########################################

# DATACARD 1 #

country_overview_scatter = ChartDataCard(
    title=
    "Overview: Across the country, the number of $label$ changed by between 04-2019 and 04-2020",
    fig_title="Total number of $label$ across the country",
    data=init_data_set,
    data_transform=scatter_country_plot,
    fig_type="Scatter",
)

country_overview_scatter.set_colors({
    "fig": {
        2018: "rgb(185, 221, 241)",
        2019: "rgb(106, 155, 195)",
        2020: "rgb(200, 19, 60)",
    }
})

# DATACARD 2 #

country_overview_map = MapDataCard(
コード例 #2
0
@timeit
def scatter_reporting_district_plot_tooltip(data):

    data_in = data.get("reporting_district")
    data_out = reporting_count_transform_tooltip(data_in.copy())

    return data_out


# DATACARD 7 #

stacked_bar_district = ChartDataCard(
    data=init_data_set,
    data_transform=scatter_reporting_district_plot,
    fig_title="$label$",
    fig_object="Scatter",
    trace_params=scatter_reporting_district_plot_tooltip(init_data_set),
)

stacked_bar_district.set_colors({
    "fig": {
        "Percentage of facilities expected to report which reported on their 105-1 form":
        "rgb(106, 155, 195)",
        "Percentage of reporting facilities that reported a value of one or above for this indicator":
        "rgb(200, 19, 60)",
    },
    "title": "white",
    "subtitle": "rgb(34, 94, 140)",
})
コード例 #3
0
compare_map = MapDataCard(
    data=init_data_set,
    data_transform=map_country_compare_plot,
    geodata=shapefile,
    locations="id",
    map_tolerance=0.005,
)

bar_chart_ranks_bottom = ChartDataCard(
    data=init_data_set,
    data_transform=bar_country_compare_plot,
    fig_object="Bar",
    bar_mode="overlay",
    fig_orientation="h",
    trace_params={
        "textposition": "inside",
        "texttemplate": "%{x:%}",
        "marker": {
            "color": "rgb(211, 41, 61)"
        },
        "showlegend": False,
        "hoverinfo": "none",
    },
)

trends_map_compare = CardLayout(
    title="$label$",
    elements=[compare_map, bar_chart_ranks_bottom],
    dropdown=dropdown,
)
コード例 #4
0
period_map = MapDataCard(
    data=init_data_set,
    data_transform=map_country_dated_plot,
    geodata=shapefile,
    locations="id",
    map_tolerance=0.005,
)

bar_chart_ranks_bottom = ChartDataCard(
    data=init_data_set,
    data_transform=bar_country_dated_plot,
    fig_object="Bar",
    fig_orientation="h",
    trace_params={
        "textposition": "inside",
        "texttemplate": "%{x:,.0}",
        "marker": {
            "color": "rgb(184, 190, 200)"
        },
        "showlegend": False,
        "hoverinfo": "none",
    },
)

trends_map_period = CardLayout(
    title="$label$",
    elements=[period_map, bar_chart_ranks_bottom],
    dropdown=dropdown,
)
コード例 #5
0
# DATACARD 1 #

db = Database()

# TODO The class would need to include this title function by default to avoid repetition

default_title = get_title_country_overview(
    scatter_country_plot(init_data_set),
    db.get_indicator_view(DEFAULTS.get("indicator")),
    **DEFAULTS,
)

country_overview_scatter = ChartDataCard(
    title=default_title,
    fig_title="$label$",
    data=init_data_set,
    data_transform=scatter_country_plot,
    fig_type="Scatter",
)

country_overview_scatter.set_colors({
    "fig": {
        YEARS[0]: "rgb(185, 221, 241)",
        YEARS[1]: "rgb(106, 155, 195)",
        YEARS[2]: "rgb(13, 119, 65)",
        YEARS[3]: "rgb(200, 19, 60)",
    },
    "title": "white",
    "subtitle": "rgb(34, 94, 140)",
})
コード例 #6
0
    return title


# DATACARD 3 #

db = Database()

default_title = get_title_district_overview(
    scatter_district_plot(init_data_set),
    db.get_indicator_view(DEFAULTS.get("indicator")),
    **DEFAULTS,
)

district_overview_scatter = ChartDataCard(
    title=default_title,
    fig_title="$label$",
    data=init_data_set,
    data_transform=scatter_district_plot,
    fig_type="Scatter",
)

district_overview_scatter.set_colors({
    "fig": {
        YEARS[0]: "rgb(185, 221, 241)",
        YEARS[1]: "rgb(106, 155, 195)",
        YEARS[2]: "rgb(13, 119, 65)",
        YEARS[3]: "rgb(200, 19, 60)",
    },
})
コード例 #7
0
    visible_id=False,
)

tree_map_district = AreaDataCard(
    fig_title="$label$",
    data=init_data_set,
    data_transform=tree_map_district_dated_plot,
    fig_object="Treemap",
    dropdown=dropdown,
)

tree_map_district.set_colors({"fig": ["#e2d5d1", "#96c0e0", "#3c6792"]})


facility_scatter = ChartDataCard(
    fig_title="$label$",
    data=init_data_set,
    data_transform=scatter_facility_plot,
)

facility_scatter.set_colors(
    {
        "fig": {
            YEARS[0]: "rgb(185, 221, 241)",
            YEARS[1]: "rgb(106, 155, 195)",
            YEARS[2]: "rgb(13, 119, 65)",
            YEARS[3]: "rgb(200, 19, 60)",
        },
    }
)