File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
packages/python/plotly/plotly Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ def to_html(
3838 default_width = "100%" ,
3939 default_height = "100%" ,
4040 validate = True ,
41+ div_id = None ,
4142):
4243 """
4344 Convert a figure to an HTML string representation.
@@ -135,7 +136,7 @@ def to_html(
135136 fig_dict = validate_coerce_fig_to_dict (fig , validate )
136137
137138 # ## Generate div id ##
138- plotdivid = "plotly-root"
139+ plotdivid = div_id or str ( uuid . uuid4 ())
139140
140141 # ## Serialize figure ##
141142 jdata = to_json_plotly (fig_dict .get ("data" , []))
@@ -391,6 +392,7 @@ def write_html(
391392 default_width = "100%" ,
392393 default_height = "100%" ,
393394 auto_open = False ,
395+ div_id = None ,
394396):
395397 """
396398 Write a figure to an HTML file representation
@@ -512,6 +514,7 @@ def write_html(
512514 default_width = default_width ,
513515 default_height = default_height ,
514516 validate = validate ,
517+ div_id = div_id ,
515518 )
516519
517520 # Check if file is a string
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ def test_versioned_cdn_included(fig1):
4141
4242
4343def test_html_deterministic (fig1 ):
44- assert pio .to_html (fig1 , include_plotlyjs = "cdn" ) == pio .to_html (
45- fig1 , include_plotlyjs = "cdn"
44+ div_id = "plotly-root"
45+ assert pio .to_html (fig1 , include_plotlyjs = "cdn" , div_id = div_id ) == pio .to_html (
46+ fig1 , include_plotlyjs = "cdn" , div_id = div_id
4647 )
You can’t perform that action at this time.
0 commit comments