Skip to content

Commit

Permalink
Nits
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed May 2, 2024
1 parent 3ba6e78 commit d11f9b9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/viser/_gui_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/viser/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
6 changes: 4 additions & 2 deletions src/viser/client/src/WebsocketInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/viser/client/src/WebsocketMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*
* (automatically generated)
*/
export interface SetupPlotlyMessage {
type: "SetupPlotlyMessage";
export interface RunJavascriptMessage {
type: "RunJavascriptMessage";
source: string;
}
/** Message for a posed viewer camera.
Expand Down Expand Up @@ -837,7 +837,7 @@ export interface SetGuiPanelLabelMessage {
}

export type Message =
| SetupPlotlyMessage
| RunJavascriptMessage
| ViewerCameraMessage
| ScenePointerMessage
| ScenePointerEnableMessage
Expand Down

0 comments on commit d11f9b9

Please sign in to comment.