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(
128128 str
129129 Representation of figure as an HTML div string
130130 """
131+ from plotly .io .json import to_json_plotly
131132
132133 # ## Validate figure ##
133134 fig_dict = validate_coerce_fig_to_dict (fig , validate )
@@ -136,15 +137,11 @@ def to_html(
136137 plotdivid = str (uuid .uuid4 ())
137138
138139 # ## 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" , {}))
145142
146143 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" , []))
148145 else :
149146 jframes = None
150147
Original file line number Diff line number Diff line change @@ -1458,6 +1458,7 @@ def request_image_with_retrying(**kwargs):
14581458 with retrying logic.
14591459 """
14601460 from requests import post
1461+ from plotly .io .json import to_json_plotly
14611462
14621463 if config .server_url :
14631464 server_url = config .server_url
@@ -1467,7 +1468,7 @@ def request_image_with_retrying(**kwargs):
14671468 )
14681469
14691470 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 )
14711472 response = post (server_url + "/" , data = json_str )
14721473
14731474 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
32import os
43from templategen .definitions import builders
54
2019 ),
2120 "w" ,
2221 ) 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