Skip to content

Commit

Permalink
Merge pull request #155 from iantei/fix_ca_ebike_stacked_bar_charts
Browse files Browse the repository at this point in the history
Fix: for labeled and labeled & inferred bars generation broken for `ca-ebike`
  • Loading branch information
shankari authored Jan 8, 2025
2 parents e1de8e5 + 696fe87 commit f07ed03
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions viz_scripts/scaffolding.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ def mapping_color_labels(labels = {}, unique_keys = []):
purpose_values = [mode["value"] for mode in labels["PURPOSE"]] if "PURPOSE" in labels else []
replaced_values = [mode["value"] for mode in labels["REPLACED_MODE"]] if "REPLACED_MODE" in labels else []

# Append 'other' to the list if not present
for values in [mode_values, purpose_values, replaced_values]:
if "other" not in values:
values.append("other")

# Mapping between mode values and base_mode OR baseMode (backwards compatibility)
value_to_basemode = {mode["value"]: mode.get("base_mode", mode.get("baseMode", "UNKNOWN")) for mode in labels["MODE"]}
# Assign colors to mode, replaced, purpose, and sensed values
Expand Down Expand Up @@ -340,6 +345,10 @@ def translate_values_to_labels(labels, language="en"):
# Mapping between values and translations for display on plots (for Replaced mode)
values_to_translations_replaced = mapping_labels(labels, "REPLACED_MODE")

# Add "other": "Other" to the values_to_translations_* dictionary if "other" key is unavailable
for dict_update in [values_to_translations_mode, values_to_translations_purpose, values_to_translations_replaced]:
dict_update.setdefault("other", "Other")

return values_to_translations_mode, values_to_translations_purpose, values_to_translations_replaced

# Function: Maps survey answers to colors.
Expand Down

0 comments on commit f07ed03

Please sign in to comment.