Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions fastplotlib/legends/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def __init__(
)

# for now only support lines with a single color
if np.unique(graphic.colors(), axis=0).shape[0] > 1:
if np.unique(graphic.colors.value, axis=0).shape[0] > 1:
raise ValueError("Use colorbars for multi-colored lines, not legends")

color = pygfx.Color(np.unique(graphic.colors(), axis=0).ravel())
color = pygfx.Color(np.unique(graphic.colors.value, axis=0).ravel())

self._parent = parent

Expand Down Expand Up @@ -117,7 +117,7 @@ def label(self, text: str):
self._label_world_object.geometry.set_text(text)

def _update_color(self, ev: FeatureEvent):
new_color = ev.pick_info["new_data"]
new_color = ev.info["value"]
if np.unique(new_color, axis=0).shape[0] > 1:
raise ValueError(
"LegendError: LineGraphic colors no longer appropriate for legend"
Expand All @@ -126,8 +126,8 @@ def _update_color(self, ev: FeatureEvent):
self._color = new_color[0]
self._line_world_object.material.color = pygfx.Color(self._color)

def _highlight_graphic(self, graphic, ev):
graphic_color = pygfx.Color(np.unique(graphic.colors(), axis=0).ravel())
def _highlight_graphic(self, graphic: Graphic, ev):
graphic_color = pygfx.Color(np.unique(graphic.colors.value, axis=0).ravel())

if graphic_color == self._parent.highlight_color:
graphic.colors = self._color
Expand Down Expand Up @@ -270,7 +270,7 @@ def add_graphic(self, graphic: Graphic, label: str = None):
self._graphics.append(graphic)
self._items[graphic._fpl_address] = legend_item

graphic.deleted.add_event_handler(partial(self.remove_graphic, graphic))
graphic.add_event_handler(partial(self.remove_graphic, graphic), "deleted")

self._col_counter = new_col_ix
self._row_counter = new_row_ix
Expand Down