Skip to content

Commit

Permalink
Fix iplot resize in classic notebook that was broken by GH 1250 (plot…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease authored and michaelbabyn committed Dec 22, 2018
1 parent c5ddead commit 4c0c527
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plotly/offline/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def get_plotlyjs():
return plotlyjs


def _build_resize_script(plotdivid):
def _build_resize_script(plotdivid, plotly_root='Plotly'):
resize_script = (
'<script type="text/javascript">'
'window.addEventListener("resize", function(){{'
'Plotly.Plots.resize(document.getElementById("{id}"));}});'
'{plotly_root}.Plots.resize(document.getElementById("{id}"));}});'
'</script>'
).format(id=plotdivid)
).format(plotly_root=plotly_root, id=plotdivid)
return resize_script


Expand Down Expand Up @@ -450,7 +450,8 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
)
resize_script = ''
if width == '100%' or height == '100%':
resize_script = _build_resize_script(plotdivid)
resize_script = _build_resize_script(
plotdivid, 'window._Plotly')

display_bundle['text/html'] = plot_html + resize_script
display_bundle['text/vnd.plotly.v1+html'] = plot_html + resize_script
Expand Down

0 comments on commit 4c0c527

Please sign in to comment.