Skip to content

Commit 0f3a048

Browse files
committed
Inject plotly.js into the output cell on every init_notebook_mode call
Fixes #458 Running init_notebook_mode injects plotly.js into the output cell. Before, if you ran it twice, it would clear the output cell on the second call and remove plotly.js from DOM. This was deceiving, because any existing plots on the page wouldn’t disappear even though their underlying plotly.js was no longer present. But, if you refresh the page, the plots would not render (as plotly.js was no longer in the output cell)
1 parent 9caf1c1 commit 0f3a048

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

plotly/offline/offline.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def init_notebook_mode():
6060
from IPython.display import HTML, display
6161

6262
global __PLOTLY_OFFLINE_INITIALIZED
63-
if not __PLOTLY_OFFLINE_INITIALIZED:
64-
display(HTML("<script type='text/javascript'>" +
65-
"define('plotly', function(require, exports, module) {" +
66-
get_plotlyjs() +
67-
"});" +
68-
"require(['plotly'], function(Plotly) {" +
69-
"window.Plotly = Plotly;" +
70-
"});" +
71-
"</script>"))
63+
# Inject plotly.js into the output cell
64+
display(HTML("<script type='text/javascript'>" +
65+
"define('plotly', function(require, exports, module) {" +
66+
get_plotlyjs() +
67+
"});" +
68+
"require(['plotly'], function(Plotly) {" +
69+
"window.Plotly = Plotly;" +
70+
"});" +
71+
"</script>"))
7272
__PLOTLY_OFFLINE_INITIALIZED = True
7373

7474

0 commit comments

Comments
 (0)