Skip to content

Commit 66478b7

Browse files
committed
Add missing encode for plotly serializer
1 parent 71e3d7d commit 66478b7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

simvue/serialization.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def _serialize_plotly_figure(data: typing.Any) -> typing.Optional[tuple[str, str
9999
return None
100100
mimetype = "application/vnd.plotly.v1+json"
101101
data = plotly.io.to_json(data, engine="json")
102+
mfile = BytesIO()
103+
mfile.write(data.encode())
104+
mfile.seek(0)
105+
data = mfile.read()
102106
return data, mimetype
103107

104108

@@ -111,7 +115,7 @@ def _serialize_matplotlib(data: typing.Any) -> typing.Optional[tuple[str, str]]:
111115
mimetype = "application/vnd.plotly.v1+json"
112116
data = plotly.io.to_json(plotly.tools.mpl_to_plotly(data.gcf()), engine="json")
113117
mfile = BytesIO()
114-
mfile.write(data)
118+
mfile.write(data.encode())
115119
mfile.seek(0)
116120
data = mfile.read()
117121
return data, mimetype
@@ -126,7 +130,7 @@ def _serialize_matplotlib_figure(data: typing.Any) -> typing.Optional[tuple[str,
126130
mimetype = "application/vnd.plotly.v1+json"
127131
data = plotly.io.to_json(plotly.tools.mpl_to_plotly(data), engine="json")
128132
mfile = BytesIO()
129-
mfile.write(data)
133+
mfile.write(data.encode())
130134
mfile.seek(0)
131135
data = mfile.read()
132136
return data, mimetype

0 commit comments

Comments
 (0)