Skip to content

Commit

Permalink
Make color and size optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rht committed Jan 28, 2024
1 parent 14da5b6 commit 5e3900d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mesa/experimental/components/altair.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@ def portray(g):
x=alt.X("x", axis=None),
# no y-axis label
y=alt.Y("y", axis=None),
size=alt.Size("size"),
color=alt.Color("color"),
)
# .configure_view(strokeOpacity=0) # hide grid/chart lines
)

has_color = hasattr(all_agent_data[0], "color")
if has_color:
chart = chart.encode(color=alt.Color("color"))

has_size = hasattr(all_agent_data[0], "size")
if has_size:
chart = chart.encode(size=alt.Size("size"))

return chart

0 comments on commit 5e3900d

Please sign in to comment.