File tree 2 files changed +7
-3
lines changed
packages/python/plotly/plotly
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ def to_html(
38
38
default_width = "100%" ,
39
39
default_height = "100%" ,
40
40
validate = True ,
41
+ div_id = None ,
41
42
):
42
43
"""
43
44
Convert a figure to an HTML string representation.
@@ -135,7 +136,7 @@ def to_html(
135
136
fig_dict = validate_coerce_fig_to_dict (fig , validate )
136
137
137
138
# ## Generate div id ##
138
- plotdivid = "plotly-root"
139
+ plotdivid = div_id or str ( uuid . uuid4 ())
139
140
140
141
# ## Serialize figure ##
141
142
jdata = to_json_plotly (fig_dict .get ("data" , []))
@@ -391,6 +392,7 @@ def write_html(
391
392
default_width = "100%" ,
392
393
default_height = "100%" ,
393
394
auto_open = False ,
395
+ div_id = None ,
394
396
):
395
397
"""
396
398
Write a figure to an HTML file representation
@@ -512,6 +514,7 @@ def write_html(
512
514
default_width = default_width ,
513
515
default_height = default_height ,
514
516
validate = validate ,
517
+ div_id = div_id ,
515
518
)
516
519
517
520
# 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):
41
41
42
42
43
43
def 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
46
47
)
You can’t perform that action at this time.
0 commit comments