Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to z-order manipulation #63

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
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
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 @@

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 @@
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 @@
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 @@

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 @@
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 @@
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 @@

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 @@
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
Loading