Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes v2 dev website dashboard not loading #1256

Merged
merged 19 commits into from
Jul 15, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 53 additions & 8 deletions server/dash/dashboards/neighborhood_recent.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,22 @@

# Populate the neighborhood dropdown
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
def populate_options():
"""Function to populate the dropdown menu with a list of neighborhood councils.
"""Gets a list of neighborhood councils to populate the dropdown menu.

This function calls the councils API to get a list of neighborhood council and
return a unique list of council as a dictionary sorted in ascending order of requests.

Typical usage example:

Returns:
A list of dictionary mapping label and value to corresponding councilName ordered by the
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
total number of requests. For example:

[
{'label': 'Arleta', 'value': 'Arleta'},
{'label': 'Arroyo Seco', 'value': 'Arroyo Seco'},
...
]

Typical usage example:

dcc.Dropdown(
...
Expand Down Expand Up @@ -149,12 +159,19 @@ def populate_options():
Input("council_list", "value")
)
def update_table(selected_council):
"""Dash Callback Function to update the LA 311 request data table at the bottom of the dashboard.
"""Filters the LA 311 request data table based on selected_council.

This function takes the selected neighborhood council (nc) value from the "council_list" dropdown and
outputs a list of requests associated with that nc as a data table in dictionary form
with id "council_table" in the layout.

Args:
selected_council:
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
A string argument automatically detected by Dash callback function when "council_list" element is selected in the layout.

Returns:
A list of dictionary mapping column names to values. For example: [{'srnumber':1234567}, {'createdDate':'2022-07-11'}, {'closeDate':'2022-07-14'}...]
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved

Typical usage example:

dash_table.DataTable(
Expand All @@ -181,13 +198,25 @@ def update_table(selected_council):
Input("council_list", "value")
)
def update_text(selected_council):
"""Dash Callback Function to update the indicator cards at the top of the dashboard.
"""Updates the indicator cards based on data filtered by selected_council.

This function takes the selected neighborhood council (nc) value from the "council_list" dropdown and
outputs the values for the number of new requests, number of closed requests, and net change in requests
(i.e. # closed requests - # new requests) for visualizations on the indicator visuals in the layout. The
corresponding IDs of the indicator visuals are "created_txt", "closed_txt", and "net_txt".

Args:
selected_council:
A string argument automatically detected by Dash callback function when "council_list" element is selected in the layout.

Returns:
created_txt:
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
Integer for the number of new requests created since the start date.
closed_txt:
Integer for the number of close requests since the start date.
net_txt:
Integer for the difference in close requests and new requests since the start date.

Typical usage example (using net_txt as example, created_txt and closed_txt are similar):

html.Div(
Expand All @@ -202,21 +231,29 @@ def update_text(selected_council):
if create_count == 0 and close_count > 0:
return 0, 0, 0
else:
return create_count, close_count, create_count - close_count
return create_count, close_count, close_count - create_count


@app.callback(
Output("graph", "figure"),
Input("council_list", "value")
)
def update_figure(selected_council):
"""Dash Callback Function to update the Request Type Line Chart at the middle of the dashboard.
"""Updates the Request Type Line Chart based on data filtered by selected_council.

This function takes the selected neighborhood council (nc) value from the "council_list" dropdown and
outputs the request type line chart that shows the trend of of different requests types over
the time range of the data available in the selected neighborhood conucil. The line chart will
show up inside dcc.Graph object as long as id "graph" is passed in.

Args:
selected_council:
A string argument automatically detected by Dash callback function when "council_list" element is selected in the layout.

Returns:
graph:
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
Plotly line chart of the total number of requests over time (createdDate) separated by request type.

Typical usage example:

html.Div(
Expand Down Expand Up @@ -259,12 +296,20 @@ def update_figure(selected_council):
Input("council_list", "value")
)
def update_council_figure(selected_council):
"""Dash Callback Function to update the Request Type Pie Chart at the middle of the dashboard.
"""Updates the Request Type Pie Chart based on data filtered by selected_council.

This function takes the selected neighborhood council (nc) value from the "council_list" dropdown and
outputs the the pie chart showing the share of each request types. The pie chart will
show up inside dcc.Graph object as long as id "pie_graph" is passed in.

Args:
selected_council:
A string argument automatically detected by Dash callback function when "council_list" element is selected in the layout.

Returns:
pie_graph
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
Plotly pie chart for the share of different request types.

Typical usage example:

html.Div(
Expand Down