2121 )
2222}
2323
24+
25+ resize_code_strings = [
26+ 'window.addEventListener("resize", ' ,
27+ 'Plotly.Plots.resize('
28+ ]
29+
30+
2431PLOTLYJS = plotly .offline .offline .get_plotlyjs ()
2532
2633
@@ -77,10 +84,7 @@ def test_div_output(self):
7784 self .assertTrue (html .startswith ('<div>' ) and html .endswith ('</div>' ))
7885
7986 def test_autoresizing (self ):
80- resize_code_strings = [
81- 'window.addEventListener("resize", ' ,
82- 'Plotly.Plots.resize('
83- ]
87+
8488 # If width or height wasn't specified, then we add a window resizer
8589 html = self ._read_html (plotly .offline .plot (fig , auto_open = False ))
8690 for resize_code_string in resize_code_strings :
@@ -96,6 +100,28 @@ def test_autoresizing(self):
96100 for resize_code_string in resize_code_strings :
97101 self .assertNotIn (resize_code_string , html )
98102
103+ def test_autoresizing_div (self ):
104+
105+ # If width or height wasn't specified, then we add a window resizer
106+ for include_plotlyjs in [True , False ]:
107+ html = plotly .offline .plot (fig ,
108+ output_type = 'div' ,
109+ include_plotlyjs = include_plotlyjs )
110+
111+ for resize_code_string in resize_code_strings :
112+ self .assertIn (resize_code_string , html )
113+
114+ # If width or height was specified, then we don't resize
115+ html = plotly .offline .plot ({
116+ 'data' : fig ['data' ],
117+ 'layout' : {
118+ 'width' : 500 , 'height' : 500
119+ }
120+ }, output_type = 'div' )
121+
122+ for resize_code_string in resize_code_strings :
123+ self .assertNotIn (resize_code_string , html )
124+
99125 def test_config (self ):
100126 config = dict (linkText = 'Plotly rocks!' ,
101127 editable = True )
0 commit comments