Table Page

The page of the app that generates the data table view.

Setup some of the key data contiaining objects


source

layout

def layout():

Call self as a function.

Global Variables

Dash Callbacks

Create interactivity in the data table

Create a callback that always triggers the map data and bargaph to update on map load

I did this as the array of callbacks are quite complex and others are triggering the maps initial load

show_doc(initial_load_table)

Update the data displayed in the table


source

update_grid

def update_grid(
    geo_input:str, # User input from the geography dropdownk
    data_type:str, # User input of type of data
    measure:str, # A string contiaining the census variable and measure split by ':'
    variable:str, # The state of the variable dropdown
    measurePop:str, # A string contiaining the population measure
    variablePop:str, # The variable to display for population dataset
    grid_rows:int, # The number of rows to display
    dataset:str, # The dataset to load
)->(<class 'dash_ag_grid.AgGrid.AgGrid'>, <class 'str'>): # Returns a graph object figure after being updated and the dynamic title

Updates the focus census variable or geography dispalayed on the map

Update the Grid row count

Needs to both: - update max input based on the geography selected - update the dash_grid size based on the selected row count


source

update_page_rows

def update_page_rows(
    geo_input:str, # User input from the geography dropdown
    dataset:str, # Currently selected dataset
)->(<class 'int'>, <class 'int'>): # New value and max size of the grid selection

Updates the page size and max of the input selection based on updated geography


source

update_page_size

def update_page_size(
    page_size:int, # The input page size
    grid_options:dict, # The current grid page size option
)->dict: # The updated grid page size option

Updates the page size of the grid based on input

Enable downloading the current csv

On click of download button, return the current csv in the dash grid


source

export_data_as_csv

def export_data_as_csv(
    n_clicks:int, # Listening for click inputs
)->bool: # Whether to download csv

Call self as a function.

data_grid.children.columnDefs
[{'field': 'Province',
  'headerName': 'Province',
  'filter': True,
  'lockPinned': True,
  'cellClass': 'lock-pinned'},
 {'field': 'Total Households', 'headerName': 'Total Households'}]