Skip to content

Commit 341e87f

Browse files
committed
fixed the inline download method
1 parent 78fc1d7 commit 341e87f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

plotly/offline/offline.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
232232
if not tools._ipython_imported:
233233
raise ImportError('`iplot` can only run inside an IPython Notebook.')
234234

235-
plot_html, plotdivid, width, height, plot_id = _plot_html(
235+
plot_html, plotdivid, _width, _height, plot_id = _plot_html(
236236
figure_or_data, show_link, link_text, validate,
237237
'100%', 525, global_requirejs=True, download=download_image)
238238

@@ -241,11 +241,12 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
241241
# Use the plot id to download the image now:
242242

243243
script = ('<script>'
244-
'Plotly.downloadImage(\'{plot_id}\', {{format: \'{format}\', '
245-
'height: {height}, width: {width}, filename: \'{filename}\'}});'
244+
'var div_id = document.getElementById(\'{plot_id}\');'
245+
'setTimeout(function() {{Plotly.downloadImage(div_id, {{format: \'{format}\', '
246+
'height: {height}, width: {width}, filename: \'{filename}\'}});}}, 500);'
246247
'</script>'
247-
).format(format=format, width=width, height=height,
248-
filename=filename, plot_id=plot_id)
248+
).format(format=format, width=width, height=height,
249+
filename=filename, plot_id=plot_id)
249250

250251
display(HTML(script))
251252

0 commit comments

Comments
 (0)