Skip to content

Commit 497f3ed

Browse files
committed
Fix iplot resize in classic notebook that was broken by
#1250
1 parent be25c50 commit 497f3ed

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: plotly/offline/offline.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ def get_plotlyjs():
9898
return plotlyjs
9999

100100

101-
def _build_resize_script(plotdivid):
101+
def _build_resize_script(plotdivid, plotly_root='Plotly'):
102102
resize_script = (
103103
'<script type="text/javascript">'
104104
'window.addEventListener("resize", function(){{'
105-
'Plotly.Plots.resize(document.getElementById("{id}"));}});'
105+
'{plotly_root}.Plots.resize(document.getElementById("{id}"));}});'
106106
'</script>'
107-
).format(id=plotdivid)
107+
).format(plotly_root=plotly_root, id=plotdivid)
108108
return resize_script
109109

110110

@@ -450,7 +450,8 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
450450
)
451451
resize_script = ''
452452
if width == '100%' or height == '100%':
453-
resize_script = _build_resize_script(plotdivid)
453+
resize_script = _build_resize_script(
454+
plotdivid, 'window._Plotly')
454455

455456
display_bundle['text/html'] = plot_html + resize_script
456457
display_bundle['text/vnd.plotly.v1+html'] = plot_html + resize_script

0 commit comments

Comments
 (0)