Skip to content

Commit 09d3cf2

Browse files
committed
Add y-axis label for each variable
1 parent d492b34 commit 09d3cf2

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

visualizations.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ def _get_line_hovertext(column: str) -> str:
174174
)
175175

176176

177+
def _get_axis_unit_for_column(column: str) -> str:
178+
units = {
179+
"Total Population": "People",
180+
"Total Worked from Home": "People",
181+
"Total With Public Assistance": "People",
182+
"Median Household Income": "Dollars",
183+
"Median Rent": "Dollars",
184+
}
185+
186+
if column not in units:
187+
raise ValueError(f"Unknown variable: {column}")
188+
189+
return units[column]
190+
191+
177192
def get_line_graph(name: str, col: str) -> go.Figure:
178193
df = be.get_data_for_name(name)
179194
df["Year"] = df["Year"].astype(int)
@@ -241,6 +256,7 @@ def get_line_graph(name: str, col: str) -> go.Figure:
241256
),
242257
yaxis=dict(
243258
tickformat=",",
259+
title=_get_axis_unit_for_column(col),
244260
),
245261
legend=dict(
246262
orientation="h",

0 commit comments

Comments
 (0)