File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ def to_html(
128
128
str
129
129
Representation of figure as an HTML div string
130
130
"""
131
+ from plotly .io .json import to_json_plotly
131
132
132
133
# ## Validate figure ##
133
134
fig_dict = validate_coerce_fig_to_dict (fig , validate )
@@ -136,15 +137,11 @@ def to_html(
136
137
plotdivid = str (uuid .uuid4 ())
137
138
138
139
# ## Serialize figure ##
139
- jdata = _json .dumps (
140
- fig_dict .get ("data" , []), cls = utils .PlotlyJSONEncoder , sort_keys = True
141
- )
142
- jlayout = _json .dumps (
143
- fig_dict .get ("layout" , {}), cls = utils .PlotlyJSONEncoder , sort_keys = True
144
- )
140
+ jdata = to_json_plotly (fig_dict .get ("data" , []))
141
+ jlayout = to_json_plotly (fig_dict .get ("layout" , {}))
145
142
146
143
if fig_dict .get ("frames" , None ):
147
- jframes = _json . dumps (fig_dict .get ("frames" , []), cls = utils . PlotlyJSONEncoder )
144
+ jframes = to_json_plotly (fig_dict .get ("frames" , []))
148
145
else :
149
146
jframes = None
150
147
Original file line number Diff line number Diff line change @@ -1458,6 +1458,7 @@ def request_image_with_retrying(**kwargs):
1458
1458
with retrying logic.
1459
1459
"""
1460
1460
from requests import post
1461
+ from plotly .io .json import to_json_plotly
1461
1462
1462
1463
if config .server_url :
1463
1464
server_url = config .server_url
@@ -1467,7 +1468,7 @@ def request_image_with_retrying(**kwargs):
1467
1468
)
1468
1469
1469
1470
request_params = {k : v for k , v , in kwargs .items () if v is not None }
1470
- json_str = json . dumps (request_params , cls = _plotly_utils . utils . PlotlyJSONEncoder )
1471
+ json_str = to_json_plotly (request_params )
1471
1472
response = post (server_url + "/" , data = json_str )
1472
1473
1473
1474
if response .status_code == 522 :
Original file line number Diff line number Diff line change 1
- from plotly .utils import PlotlyJSONEncoder
2
- import json
1
+ from plotly .io .json import to_json_plotly
3
2
import os
4
3
from templategen .definitions import builders
5
4
20
19
),
21
20
"w" ,
22
21
) as f :
23
- plotly_schema = json . dump ( template , f , cls = PlotlyJSONEncoder )
22
+ f . write ( to_json_plotly ( template ) )
You can’t perform that action at this time.
0 commit comments