Skip to content

Commit 5e3900d

Browse files
committed
Make color and size optional
1 parent 14da5b6 commit 5e3900d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mesa/experimental/components/altair.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,16 @@ def portray(g):
4444
x=alt.X("x", axis=None),
4545
# no y-axis label
4646
y=alt.Y("y", axis=None),
47-
size=alt.Size("size"),
48-
color=alt.Color("color"),
4947
)
5048
# .configure_view(strokeOpacity=0) # hide grid/chart lines
5149
)
50+
51+
has_color = hasattr(all_agent_data[0], "color")
52+
if has_color:
53+
chart = chart.encode(color=alt.Color("color"))
54+
55+
has_size = hasattr(all_agent_data[0], "size")
56+
if has_size:
57+
chart = chart.encode(size=alt.Size("size"))
58+
5259
return chart

0 commit comments

Comments
 (0)