-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update deephaven-plugin to latest, fixed API breaking changes
Also fixed minor style issues
- Loading branch information
Showing
3 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
from deephaven.plugin import Registration | ||
from deephaven.plugin import Registration, Callback | ||
from plotly import io as pio | ||
|
||
__version__ = "0.1.0" | ||
|
||
|
||
def _init_theme(): | ||
# Set the Deephaven style globally | ||
from . import theme_deephaven | ||
pio.templates.default = "deephaven" | ||
# Disable default renderer to ignore figure.show() | ||
pio.renderers.default = None | ||
|
||
|
||
class PlotlyRegistration(Registration): | ||
@classmethod | ||
def register_into(cls, callback: Registration.Callback) -> None: | ||
def register_into(cls, callback: Callback) -> None: | ||
_init_theme() | ||
from . import figure_type | ||
callback.register(figure_type.FigureType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
from plotly.graph_objects import Figure | ||
from deephaven.plugin.object import Exporter, ObjectType | ||
import json | ||
from deephaven.plugin.object_type import Exporter, FetchOnlyObjectType | ||
|
||
# Name of the plotly figure object that was exported | ||
NAME = "plotly.figure" | ||
|
||
|
||
def _export_figure(figure): | ||
return figure.to_json().encode() | ||
|
||
class FigureType(ObjectType): | ||
|
||
class FigureType(FetchOnlyObjectType): | ||
@property | ||
def name(self) -> str: | ||
return NAME | ||
|
||
def is_type(self, object) -> bool: | ||
return isinstance(object, Figure) | ||
def is_type(self, obj) -> bool: | ||
return isinstance(obj, Figure) | ||
|
||
def to_bytes(self, exporter: Exporter, figure: Figure) -> bytes: | ||
return _export_figure(figure) |