Election Page
The page of the app that generates the data table view.
Setup some of the key data contiaining objects
layout
def layout():Call self as a function.
Global Variables
Dash Callbacks
Create interactivity in the data table
update_election_bar
def update_election_bar(
data_type:str, # User input of type of data
election:str, # A string contiaining the election type
loc_selection:str, # The selected locations, may be none
init_load:str, # An empty dictionary always, triggers initial load
elecYear:str, # The year of the election
geo_input:str, # User input from the geography dropdown
)->Figure: # Returns a graph object figure after being updated and the dynamic titleUpdates the focus election variable on the bar plot
Election Map Click
Update the bar graph base on the map click
map_click
def map_click(
clickData:dict, # The currently clicked location on the map
selectedData:dict, # The currently selected locations on the map
)->[<class 'str'>]: # Returns the new value for the dropdownThis function updates the elections barplot based on the map click data, only a single location selected for this one