Skip to content

Commit

Permalink
Fix up some issues with z-order manipulation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed May 10, 2024
1 parent 0f8f7e5 commit 77063b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
9 changes: 4 additions & 5 deletions glue_plotly/viewers/histogram/dotplot_layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, view, viewer_state, layer_state=None, layer=None):

self._viewer_state.add_global_callback(self._update_dotplot)
self.state.add_global_callback(self._update_dotplot)
self.state.add_callback("zorder", self._update_zorder)

Check warning on line 43 in glue_plotly/viewers/histogram/dotplot_layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/histogram/dotplot_layer_artist.py#L43

Added line #L43 was not covered by tests

def _get_dots(self):
return self.view.figure.select_traces(dict(meta=self._dots_id))
Expand Down Expand Up @@ -126,11 +127,12 @@ def _update_data(self):
self._dots_id = dots[0].meta if dots else None
self.view.figure.add_traces(dots)

def _update_zorder(self):
def _update_zorder(self, *args):
current_traces = self.view.figure.data

Check warning on line 131 in glue_plotly/viewers/histogram/dotplot_layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/histogram/dotplot_layer_artist.py#L131

Added line #L131 was not covered by tests
traces = [self.view.selection_layer]
for layer in self.view.layers:
traces += list(layer.traces())
self.view.figure.data = traces
self.view.figure.data = traces + [t for t in current_traces if t not in traces]

Check warning on line 135 in glue_plotly/viewers/histogram/dotplot_layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/histogram/dotplot_layer_artist.py#L135

Added line #L135 was not covered by tests

def _update_dotplot(self, force=False, **kwargs):
if (self._viewer_state.hist_x_min is None or
Expand All @@ -156,9 +158,6 @@ def _update_dotplot(self, force=False, **kwargs):
if force or len(changed & VISUAL_PROPERTIES) > 0:
self._update_visual_attributes(changed, force=force)

if force or "zorder" in changed:
self._update_zorder()

def update(self):
self.state.reset_cache()
self._update_dotplot(force=True)
9 changes: 4 additions & 5 deletions glue_plotly/viewers/histogram/layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, view, viewer_state, layer_state=None, layer=None):

self._viewer_state.add_global_callback(self._update_histogram)
self.state.add_global_callback(self._update_histogram)
self.state.add_callback("zorder", self._update_zorder)

Check warning on line 38 in glue_plotly/viewers/histogram/layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/histogram/layer_artist.py#L38

Added line #L38 was not covered by tests

def _get_bars(self):
return self.view.figure.select_traces(dict(meta=self._bars_id))
Expand Down Expand Up @@ -122,11 +123,12 @@ def _update_data(self):
self._bars_id = bars[0].meta if bars else None
self.view.figure.add_traces(bars)

def _update_zorder(self):
def _update_zorder(self, *args):
current_traces = self.view.figure.data

Check warning on line 127 in glue_plotly/viewers/histogram/layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/histogram/layer_artist.py#L127

Added line #L127 was not covered by tests
traces = [self.view.selection_layer]
for layer in self.view.layers:
traces += list(layer.traces())
self.view.figure.data = traces
self.view.figure.data = traces + [t for t in current_traces if t not in traces]

Check warning on line 131 in glue_plotly/viewers/histogram/layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/histogram/layer_artist.py#L131

Added line #L131 was not covered by tests

def _update_histogram(self, force=False, **kwargs):
if (self._viewer_state.hist_x_min is None or
Expand All @@ -152,9 +154,6 @@ def _update_histogram(self, force=False, **kwargs):
if force or len(changed & VISUAL_PROPERTIES) > 0:
self._update_visual_attributes(changed, force=force)

if force or "zorder" in changed:
self._update_zorder()

def update(self):
self.state.reset_cache()
self._update_histogram(force=True)
9 changes: 4 additions & 5 deletions glue_plotly/viewers/scatter/layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(self, view, viewer_state, layer_state=None, layer=None):

self._viewer_state.add_global_callback(self._update_display)
self.state.add_global_callback(self._update_display)
self.state.add_callback("zorder", self._update_zorder)

Check warning on line 72 in glue_plotly/viewers/scatter/layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/scatter/layer_artist.py#L72

Added line #L72 was not covered by tests

self.view = view

Expand Down Expand Up @@ -166,14 +167,12 @@ def _update_display(self, force=False, **kwargs):
if force or len(changed & LINE_PROPERTIES) > 0:
self._update_lines(changed, force=force)

if force or "zorder" in changed:
self._update_zorder()

def _update_zorder(self):
def _update_zorder(self, *args):
current_traces = self.view.figure.data

Check warning on line 171 in glue_plotly/viewers/scatter/layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/scatter/layer_artist.py#L170-L171

Added lines #L170 - L171 were not covered by tests
traces = [self.view.selection_layer]
for layer in self.view.layers:
traces += list(layer.traces())
self.view.figure.data = traces
self.view.figure.data = traces + [t for t in current_traces if t not in traces]

Check warning on line 175 in glue_plotly/viewers/scatter/layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/scatter/layer_artist.py#L175

Added line #L175 was not covered by tests

def _update_lines(self, changed, force=False):
scatter = self._get_scatter()
Expand Down

0 comments on commit 77063b9

Please sign in to comment.