Skip to content

Commit

Permalink
Update logic for fetching layer hover data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Nov 27, 2024
1 parent cff540c commit b411788
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion glue_plotly/common/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,9 @@ def traces(viewer, secondary_x=False, secondary_y=False, hover_selections=None,
traces += traces_for_nonpixel_subset_layer(viewer.state, layer.state, full_view, transpose)

for layer in layers['scatter']:
hover_data = hover_selections[layer.state.layer.label] if hover_selections else None

Check warning on line 420 in glue_plotly/common/image.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/common/image.py#L420

Added line #L420 was not covered by tests
traces += traces_for_scatter_layer(viewer.state, layer.state,
hover_data=hover_selections[layer.state.layer.label],
hover_data=hover_data,
add_data_label=add_data_label)

if secondary_x or secondary_y:
Expand Down
5 changes: 2 additions & 3 deletions glue_plotly/html_exporters/jupyter/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def on_cancel():

with self.viewer.output_widget:
display(self.save_hover_dialog)

Check warning on line 43 in glue_plotly/html_exporters/jupyter/image.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/html_exporters/jupyter/image.py#L42-L43

Added lines #L42 - L43 were not covered by tests
else:
self.checked_dictionary = None

def save_figure(self, filepath):

Expand All @@ -67,10 +65,11 @@ def save_figure(self, filepath):
layout = go.Layout(**config)
fig = go.Figure(layout=layout)

checked_dictionary = self.save_hover_dialog.checked_dictionary if hasattr(self, 'save_hover_dialog') else None
traces_to_add = traces(self.viewer,
secondary_x=secondary_x,
secondary_y=secondary_y,
hover_selections=self.save_hover_dialog.checked_dictionary,
hover_selections=checked_dictionary,
add_data_label=add_data_label)
fig.add_traces(traces_to_add)

Expand Down
4 changes: 3 additions & 1 deletion glue_plotly/html_exporters/jupyter/scatter2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ def save_figure(self, filepath):

layers = layers_to_export(self.viewer)
add_data_label = data_count(layers) > 1
checked_dictionary = self.save_hover_dialog.checked_dictionary if hasattr(self, 'save_hover_dialog') else None
for layer in layers:
hover_data = checked_dictionary[layer.layer.label] if checked_dictionary is not None else None
traces = traces_for_layer(self.viewer,
layer.state,
hover_data=self.save_hover_dialog.checked_dictionary[layer.state.layer.label],
hover_data=hover_data,
add_data_label=add_data_label)
fig.add_traces(traces)

Expand Down
4 changes: 3 additions & 1 deletion glue_plotly/html_exporters/jupyter/scatter3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ def save_figure(self, filepath):

layers = layers_to_export(self.viewer)
add_data_label = data_count(layers) > 1
checked_dictionary = self.save_hover_dialog.checked_dictionary if hasattr(self, 'save_hover_dialog') else None
for layer in layers:
hover_data = checked_dictionary[layer.layer.label] if checked_dictionary is not None else None
traces = traces_for_layer(self.viewer.state,
layer.state,
hover_data=self.save_hover_dialog.checked_dictionary[layer.state.layer.label],
hover_data=hover_data,
add_data_label=add_data_label)
for trace in traces:
fig.add_trace(trace)
Expand Down

0 comments on commit b411788

Please sign in to comment.