From 78caba1e47518949c498e00e16dedcf4804a8712 Mon Sep 17 00:00:00 2001 From: krakentoa Date: Sun, 11 Mar 2018 16:21:49 +0000 Subject: [PATCH] make iplot include resize listener 'offline.plot' makes plotly resize a plot when the corresponding div is resized. 'offline.iplot' doesn't. The script is not included if both width and height properties in the layout are set to anything other than "100%" This pull request makes 'offline.iplot' include the same resizing script under the same conditions that 'offline.plot' does. --- plotly/offline/offline.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 6ab50476448..91adf5281ae 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -351,7 +351,17 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly', plot_html, plotdivid, width, height = _plot_html( figure_or_data, config, validate, '100%', 525, True ) - display_bundle['text/html'] = plot_html + resize_script = '' + if width == '100%' or height == '100%': + resize_script = ( + '' + '' + ).format(id=plotdivid) + + display_bundle['text/html'] = plot_html+resize_script display_bundle['text/vnd.plotly.v1+html'] = plot_html ipython_display.display(display_bundle, raw=True)