File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
Filter options
packages/python/plotly/plotly Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
Original file line number Diff line number Diff line change 2
2
All notable changes to this project will be documented in this file.
3
3
This project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
4
4
5
+
5
6
## UNRELEASED
6
7
7
8
### Fixed
@@ -11,7 +12,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
11
12
12
13
- ` text_auto ` argument to ` px.bar ` , ` px.histogram ` , ` px.density_heatmap ` , ` px.imshow ` [ #3518 ] ( https://github.com/plotly/plotly.py/issues/3518 )
13
14
- Deprecated ` ff.create_annotated_heatmap ` , ` ff.create_county_choropleth ` , ` ff.create_gantt ` [ #3518 ] ( https://github.com/plotly/plotly.py/issues/3518 )
14
-
15
+ - ` div_id ` argument to ` pio.to_html ` to optionally make its IDs deterministic [ #3487 ] ( https://github.com/plotly/plotly.py/issues/3487 )
16
+
15
17
### Updated
16
18
- Updated Plotly.js to from version 2.6.3 to version 2.8.1. See the [ plotly.js CHANGELOG] ( https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#280----2021-12-10 ) for more information. Notable changes include:
17
19
- Horizontal color bars
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 = str (uuid .uuid4 ())
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 @@ -38,3 +38,10 @@ def fig1(request):
38
38
39
39
def test_versioned_cdn_included (fig1 ):
40
40
assert plotly_cdn_url () in pio .to_html (fig1 , include_plotlyjs = "cdn" )
41
+
42
+
43
+ def test_html_deterministic (fig1 ):
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
47
+ )
You can’t perform that action at this time.
0 commit comments