Skip to content
Merged

Test #25

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "funcnodes-plotly"
version = "0.3.0"
version = "0.3.1"
description = ""
readme = "README.md"
classifiers = [
Expand Down
25 changes: 24 additions & 1 deletion src/funcnodes_plotly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from exposedfunctionality.function_parser.types import add_type
from . import plots, layout, figure, express
import os
import json

import funcnodes_pandas # noqa: F401
import funcnodes_numpy # noqa: F401
Expand Down Expand Up @@ -38,6 +39,7 @@ def figureencoder(figure: go.Figure, preview: bool = False) -> Tuple[Any, bool]:
data=figure.to_plotly_json(),
handeled=True,
done=False,
continue_preview=False,
)
return fn.Encdata(
data=figure,
Expand All @@ -48,6 +50,27 @@ def figureencoder(figure: go.Figure, preview: bool = False) -> Tuple[Any, bool]:
fn.JSONEncoder.add_encoder(figureencoder)


def figure_byte_encoder(figure: go.Figure, preview) -> fn.BytesEncdata:
if isinstance(figure, go.Figure):
return fn.BytesEncdata(
data=json.dumps(
fn.JSONEncoder.apply_custom_encoding(figure, preview=preview)
).encode("utf-8"),
handeled=True,
mime="application/json",
)
return fn.BytesEncdata(
data=figure,
handeled=False,
)


fn.ByteEncoder.add_encoder(
figure_byte_encoder,
enc_cls=[go.Figure],
)


NODE_SHELF = fn.Shelf(
nodes=[],
name="Plotly",
Expand All @@ -66,4 +89,4 @@ def figureencoder(figure: go.Figure, preview: bool = False) -> Tuple[Any, bool]:
}


__version__ = "0.3.0"
__version__ = "0.3.1"
6 changes: 5 additions & 1 deletion src/react_plugin/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ class LRUCache<K, V> {
// Create a global LRU cache instance
const globalPlotlyImageCache = new LRUCache<string, string>();

const renderpluginfactory = ({ React }: v1_types.RenderPluginFactoryProps) => {
const renderpluginfactory = ({
React,
}: // _fnrf_zst,
// NodeContext,
v1_types.RenderPluginFactoryProps) => {
const RenderFigure = ({
data,
layout,
Expand Down
Loading