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

Request type colors #1221

Merged
merged 12 commits into from
Jun 2, 2022
Merged
2 changes: 2 additions & 0 deletions server/dash/dashboards/neighborhood.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from design import apply_figure_style
from design import CONFIG_OPTIONS
from design import DISCRETE_COLORS
from design import DISCRETE_COLORS_MAP
from design import LABELS


Expand Down Expand Up @@ -90,6 +91,7 @@ def update_council_figure(selected_council):
y="counts",
color="type_name",
color_discrete_sequence=DISCRETE_COLORS,
color_discrete_map = DISCRETE_COLORS_MAP,
labels=LABELS,
title="Request type trend for " + selected_council
)
Expand Down
5 changes: 4 additions & 1 deletion server/dash/dashboards/neighborhood_recent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from app import app, batch_get_data
from config import API_HOST
from dash.dependencies import Input, Output
from design import CONFIG_OPTIONS, DISCRETE_COLORS, LABELS, apply_figure_style
from design import CONFIG_OPTIONS, DISCRETE_COLORS, LABELS, apply_figure_style, DISCRETE_COLORS_MAP
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
from flask import request

pretty_columns = {
Expand Down Expand Up @@ -66,6 +66,7 @@ def populate_options():
y="srnumber",
color="typeName",
color_discrete_sequence=DISCRETE_COLORS,
color_discrete_map = DISCRETE_COLORS_MAP,
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
labels=LABELS,
)

Expand All @@ -83,7 +84,9 @@ def populate_options():
figure_df,
names="typeName",
values="srnumber",
color = 'typeName',
color_discrete_sequence=DISCRETE_COLORS,
color_discrete_map = DISCRETE_COLORS_MAP,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

labels=LABELS,
hole=.3,
)
Expand Down
28 changes: 25 additions & 3 deletions server/dash/dashboards/overview.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import textwrap


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete extra new line

import dash_core_components as dcc
import dash_html_components as html
# from dash import Dash, html, dcc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete? It also looks like there are some other test-related lines to delete.

import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
Expand All @@ -11,6 +13,13 @@
from design import CONFIG_OPTIONS
from design import DISCRETE_COLORS
from design import LABELS
from design import DISCRETE_COLORS_MAP



#TODO: Remove this after testing
# app = Dash(__name__)



# TITLE
Expand Down Expand Up @@ -88,13 +97,18 @@
print(" * Downloading data for dataframe")
query_string = "/reports?field=type_name&filter=created_date>=2016-01-01"
df3 = pd.read_json(API_HOST + query_string)
df3 = df3.groupby(['type_name'])['counts'].sum().to_frame()
df3.index = df3.index.map(lambda x: '<br>'.join(textwrap.wrap(x, width=16)))
df3 = df3.groupby(['type_name'], as_index=False)['counts'].sum()
#df3 = df3.groupby(['type_name'])['counts'].sum().to_frame()
#df3.index = df3.index.map(lambda x: '<br>'.join(textwrap.wrap(x, width=16)))
print(df3['type_name'])
print(" * TESTING IF CHANGES ARE ACTUALLY DEPLOYED ON DOCKER")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need these lines?

fig3 = px.pie(
df3,
names=df3.index,
names='type_name',
values='counts',
color_discrete_sequence=DISCRETE_COLORS,
color = 'type_name',
color_discrete_map = DISCRETE_COLORS_MAP,
labels=LABELS,
hole=.3,
title="Total Requests by Type",
Expand Down Expand Up @@ -134,7 +148,12 @@
apply_figure_style(fig5)
apply_figure_style(fig6)


## CHANGE THIS BACK TO just "layout = html.Div" or layout = html.Div([


# LAYOUT
# app.layout = html.Div([
layout = html.Div([
html.H1(title),
html.P("The figures below represent the total number of 311 requests made across LA County from 2016-2021. In 2020, we saw an all-time high with more than 1.4 million requests.", style={'padding':'20px', 'font-size':'18px', 'font-style':'italic'}),
Expand Down Expand Up @@ -186,3 +205,6 @@
responsive=True,
),
])

# if __name__ == '__main__':
# app.run_server(debug=True)
5 changes: 4 additions & 1 deletion server/dash/dashboards/recent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import plotly.graph_objects as go

from config import API_HOST
from design import CONFIG_OPTIONS, DISCRETE_COLORS, LABELS, apply_figure_style
from design import CONFIG_OPTIONS, DISCRETE_COLORS, LABELS, apply_figure_style, DISCRETE_COLORS_MAP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same note about alphabetized ordering


# TITLE
title = "RECENT 311 REQUESTS"
Expand All @@ -33,6 +33,7 @@
y="counts",
color="type_name",
color_discrete_sequence=DISCRETE_COLORS,
color_discrete_map = DISCRETE_COLORS_MAP,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing

labels=LABELS,
)

Expand All @@ -50,7 +51,9 @@
pie_df,
names="type_name",
values="counts",
color='type_name',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this file is using double quotes, so let's keep it consistent.

color_discrete_sequence=DISCRETE_COLORS,
color_discrete_map = DISCRETE_COLORS_MAP,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing

labels=LABELS,
hole=.3,
)
Expand Down
20 changes: 19 additions & 1 deletion server/dash/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@
}


# TODO: Fixing multiple streetlights and waterwaste color
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
# Need to add another discrete color
DISCRETE_COLORS_MAP = {
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
"Graffiti":"#BF82BA",
"Homeless Encampment":"#11975F",
"Animal Remains":"#267370",
"Bulky Items": "#D05F4E",
"Electronic Waste": "#AE3D51",
"Illegal Dumping": "#685DB1",
"Metal/Appliances": "#8B508B",
"Single Streetlight": "#79B74E",
"Multiple Streetlights": "#EDAD08",
"Water Waste": "#EDAD08",
"Other": "#1D6996",
"Feedback": "#E17C05"
}


def apply_figure_style(fig):

fig.update_layout(
Expand All @@ -57,7 +75,7 @@ def apply_figure_style(fig):
title_yanchor='top',
font_family="Roboto, Arial",
font_color="#ECECEC",
colorway=DISCRETE_COLORS,
#colorway=DISCRETE_COLORS,
joshuayhwu marked this conversation as resolved.
Show resolved Hide resolved
margin_l=10,
margin_r=10,
legend_font_size=11,
Expand Down