Exemple #1
0
 def candidate_selected(selected_mec_id, include_pacs, contest):
     if contest is None:
         contest = "Mayor - City of St. Louis"
     contest_name = mec_query.get_standard_contest_name(contest)
     if selected_mec_id != "all":
         color_prop = "mec_donations_" + selected_mec_id
         if "include_pacs" in include_pacs:
             color_prop = color_prop + "_with_pacs"
         hideout = bootstrap_stuff.build_choropleth_hideout(color_prop)
         return (
             True,
             [],  # [bootstrap_stuff.get_candidate_info_card(candidate_row)],
             hideout,
             hideout,
             hideout,
             [plotting.build_contest_info_graph(contest)
              ],  # Change this to candidate info at some point
         )
     color_prop = "total_monetary_donations_" + contest_name
     if "include_pacs" in include_pacs:
         color_prop = color_prop + "_with_pacs"
     hideout = bootstrap_stuff.build_choropleth_hideout(color_prop)
     return (
         False,
         [],
         hideout,
         hideout,
         hideout,
         [plotting.build_contest_info_graph(contest)],
     )
Exemple #2
0
 def candidate_selected(selected_mec_id, contest):
     if contest is None:
         contest = "Mayor - City of St. Louis"
     contest_name = mec_query.get_standard_contest_name(contest)
     if selected_mec_id != "all":
         color_prop = "mec_donations_" + selected_mec_id
         hideout = bootstrap_stuff.build_choropleth_hideout(color_prop)
         return (
             True,
             [],  # [bootstrap_stuff.get_candidate_info_card(candidate_row)],
             hideout,
             hideout,
             hideout,
         )
     hideout = bootstrap_stuff.build_choropleth_hideout(
         "total_monetary_donations_" + contest_name)
     return (False, [], hideout, hideout, hideout)
Exemple #3
0
def get_neighborhood_geojson():
    ns = Namespace("dlx", "choropleth")
    neighborhoods_geobuf_path = "static/geobuf/neighborhoods-and-municipalities.pbf"
    neighborhoods_geojson = dl.GeoJSON(
        format="geobuf",
        options=dict(style=ns("style")),
        hoverStyle=arrow_function(dict(weight=5, color="#666", dashArray="")),
        hideout=bootstrap_stuff.build_choropleth_hideout(
            "total_monetary_donations"),
        id="neighborhood-geojson",
    )
    return neighborhoods_geojson
Exemple #4
0
def get_precinct_geojson():
    ns = Namespace("dlx", "choropleth")
    precincts_geobuf_path = "dsadata/static/geobuf/stl-city-and-county-precincts.pbf"
    precincts_geojson = dl.GeoJSON(
        format="geobuf",
        options=dict(style=ns("style")),
        hoverStyle=arrow_function(dict(weight=5, color="#666", dashArray="")),
        hideout=bootstrap_stuff.build_choropleth_hideout(
            "total_monetary_donations"),
        id="precincts-geojson",
    )
    return precincts_geojson
Exemple #5
0
def get_neighborhood_geojson():
    ns = Namespace("dlx", "choropleth")
    neighborhoods_geojson = dl.GeoJSON(
        format="geobuf",
        options=dict(style=ns("style")),
        hoverStyle=arrow_function(dict(weight=5, color="#666", dashArray="")),
        zoomToBoundsOnClick=
        False,  # when true, zooms to bounds of feature (e.g. polygon) on click
        hideout=bootstrap_stuff.build_choropleth_hideout(
            "total_monetary_donations"),
        id="neighborhood-geojson",
    )
    return neighborhoods_geojson
Exemple #6
0
def get_precinct_overlay():
    # original file was wrong hand rule, whis one was rewound with geojson-rewind:
    precinct_pbf_url = "dsadata/static/geobuf/stl-city-precincts.pbf"
    ns = Namespace("dlx", "choropleth")
    precincts = dl.GeoJSON(
        url=precinct_pbf_url,
        format="geobuf",
        options=dict(style=ns("style")),
        zoomToBoundsOnClick=True,
        hoverStyle=arrow_function(dict(weight=4, fillOpacity=0.2,
                                       dashArray="")),
        hideout=bootstrap_stuff.build_choropleth_hideout("total_donations"),
        id="precincts-geojson",
    )
    precinct_overlay = dl.Overlay(precincts, name="precincts", checked=False)
    return precinct_overlay
Exemple #7
0
def get_zip_geojson():
    ns = Namespace("dlx", "choropleth")
    zip_geojson = dl.GeoJSON(
        format="geobuf",
        options=dict(style=ns("style")),  # how to style each polygon
        # options=dict(style=dict(color="blue")),
        zoomToBounds=
        False,  # when true, zooms to bounds when data changes (e.g. on load)
        zoomToBoundsOnClick=
        False,  # when true, zooms to bounds of feature (e.g. polygon) on click
        hoverStyle=arrow_function(dict(weight=5, color="#666", dashArray="")),
        hideout=bootstrap_stuff.build_choropleth_hideout(
            "total_monetary_donations"),
        id="zip-geojson",
    )
    return zip_geojson