Skip to content

Commit 127ebc5

Browse files
committed
Don't clobber the Notebook's require/requirejs/define instances
1 parent 0dded42 commit 127ebc5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

plotly/offline/offline.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def init_notebook_mode():
6161

6262
global __PLOTLY_OFFLINE_INITIALIZED
6363
if not __PLOTLY_OFFLINE_INITIALIZED:
64-
display(HTML('<script type="text/javascript">' +
65-
# ipython's includes `require` as a global, which
66-
# conflicts with plotly.js. so, unrequire it.
67-
'require=requirejs=define=undefined;' +
68-
'</script>' +
69-
'<script type="text/javascript">' +
64+
display(HTML("<script type='text/javascript'>" +
65+
"define('plotly', function(require, exports, module) {" +
7066
get_plotlyjs() +
71-
'</script>'))
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)