diff --git a/src/viser/_gui_api.py b/src/viser/_gui_api.py index 2a8cb0920..4403448f7 100644 --- a/src/viser/_gui_api.py +++ b/src/viser/_gui_api.py @@ -520,6 +520,7 @@ def add_gui_plotly( aspect_ratio: Aspect ratio of the plot in the control panel (width / height). order: Optional ordering, smallest values will be displayed first. visible: Whether the component is visible. + font: Optional font to use for the plot. Returns: A handle that can be used to interact with the GUI element. @@ -558,7 +559,7 @@ def add_gui_plotly( with open(plotly_path, "r") as f: plotly_js = f.read() self._get_api()._queue( - _messages.SetupPlotlyMessage( + _messages.RunJavascriptMessage( source=plotly_js, ) ) diff --git a/src/viser/_messages.py b/src/viser/_messages.py index 0f70fb3f1..094128055 100644 --- a/src/viser/_messages.py +++ b/src/viser/_messages.py @@ -66,7 +66,7 @@ def wrapper(cls: T) -> T: @dataclasses.dataclass -class SetupPlotlyMessage(Message): +class RunJavascriptMessage(Message): """Message for setting up the Plotly.js package, via sending the plotly.min.js source code.""" diff --git a/src/viser/client/src/WebsocketInterface.tsx b/src/viser/client/src/WebsocketInterface.tsx index 7507b0f61..93e3f8f3e 100644 --- a/src/viser/client/src/WebsocketInterface.tsx +++ b/src/viser/client/src/WebsocketInterface.tsx @@ -128,8 +128,10 @@ function useMessageHandler() { return; } - // Setup the plotly.js library using the plotly.min.js code (string). - case "SetupPlotlyMessage": { + // Run some arbitrary Javascript. + // This is used for plotting, where the Python server will send over a + // copy of plotly.min.js for the currently-installed version of plotly. + case "RunJavascriptMessage": { eval(message.source); return; } diff --git a/src/viser/client/src/WebsocketMessages.tsx b/src/viser/client/src/WebsocketMessages.tsx index 723979726..801bf8e4e 100644 --- a/src/viser/client/src/WebsocketMessages.tsx +++ b/src/viser/client/src/WebsocketMessages.tsx @@ -5,8 +5,8 @@ * * (automatically generated) */ -export interface SetupPlotlyMessage { - type: "SetupPlotlyMessage"; +export interface RunJavascriptMessage { + type: "RunJavascriptMessage"; source: string; } /** Message for a posed viewer camera. @@ -837,7 +837,7 @@ export interface SetGuiPanelLabelMessage { } export type Message = - | SetupPlotlyMessage + | RunJavascriptMessage | ViewerCameraMessage | ScenePointerMessage | ScenePointerEnableMessage