Skip to content

Commit

Permalink
Add dendrogram viewer to Chart Studio exporter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Aug 1, 2024
1 parent 8e19610 commit 18e651e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
16 changes: 15 additions & 1 deletion glue_plotly/web/export_plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from glue.core.layout import Rectangle, snap_to_grid

from glue_plotly.common import histogram, profile, scatter2d, \
from glue_plotly.common import dendrogram, histogram, profile, scatter2d, \
data_count, layers_to_export, base_rectilinear_axis

SYM = {'o': 'circle', 's': 'square', '+': 'cross', '^': 'triangle-up',
Expand Down Expand Up @@ -141,6 +141,20 @@ def export_profile(viewer):
return traces, xaxis, yaxis


def export_dendrogram(viewer):
traces = []
layers = layers_to_export(viewer)
add_data_label = data_count(layers) > 1
for layer in layers:
data = layer.mpl_artists[0].get_xydata()
trace = dendrogram.trace_for_layer(layer.state, data, add_data_label=add_data_label)
traces.append(trace)

Check warning on line 151 in glue_plotly/web/export_plotly.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/web/export_plotly.py#L145-L151

Added lines #L145 - L151 were not covered by tests

config = dendrogram.layout_config_from_mpl(viewer)

Check warning on line 153 in glue_plotly/web/export_plotly.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/web/export_plotly.py#L153

Added line #L153 was not covered by tests

return traces, config["xaxis"], config["yaxis"]

Check warning on line 155 in glue_plotly/web/export_plotly.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/web/export_plotly.py#L155

Added line #L155 was not covered by tests


def build_plotly_call(app):
args = []
layout = {'showlegend': True, 'barmode': 'overlay', 'bargap': 0,
Expand Down
8 changes: 8 additions & 0 deletions glue_plotly/web/qt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from glue_plotly.web.export_plotly import export_dendrogram


def setup():

from glue.config import exporters
Expand All @@ -6,6 +9,11 @@ def setup():
export_profile)
from glue_plotly.web.qt.exporter import save_plotly

try:
from glue_qt.plugins.dendro_viewer import DendrogramViewer
DISPATCH[DendrogramViewer] = export_dendrogram
except ImportError:
pass

Check warning on line 16 in glue_plotly/web/qt/__init__.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/web/qt/__init__.py#L15-L16

Added lines #L15 - L16 were not covered by tests
from glue_qt.viewers.scatter import ScatterViewer
from glue_qt.viewers.histogram import HistogramViewer
from glue_qt.viewers.profile import ProfileViewer
Expand Down

0 comments on commit 18e651e

Please sign in to comment.