@@ -73,7 +73,7 @@ def init_notebook_mode():
73
73
74
74
75
75
def _plot_html (figure_or_data , show_link , link_text ,
76
- validate , default_width , default_height ):
76
+ validate , default_width , default_height , global_requirejs ):
77
77
78
78
figure = tools .return_figure_from_figure_or_data (figure_or_data , validate )
79
79
@@ -121,17 +121,21 @@ def _plot_html(figure_or_data, show_link, link_text,
121
121
layout = jlayout ,
122
122
config = jconfig )
123
123
124
+ optional_line1 = ('require(["plotly"], function(Plotly) {{ '
125
+ if global_requirejs else '' )
126
+ optional_line2 = '}});' if global_requirejs else ''
127
+
124
128
plotly_html_div = (
125
129
''
126
130
'<div id="{id}" style="height: {height}; width: {width};" '
127
131
'class="plotly-graph-div">'
128
132
'</div>'
129
- '<script type="text/javascript">'
130
- 'require(["plotly"], function(Plotly) {{'
133
+ '<script type="text/javascript">' +
134
+ optional_line1 +
131
135
'window.PLOTLYENV=window.PLOTLYENV || {{}};'
132
136
'window.PLOTLYENV.BASE_URL="' + plotly_platform_url + '";'
133
- '{script}'
134
- '}});'
137
+ '{script}' +
138
+ optional_line2 +
135
139
'</script>'
136
140
'' ).format (
137
141
id = plotdivid , script = script ,
@@ -189,7 +193,7 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
189
193
190
194
plot_html , plotdivid , width , height = _plot_html (
191
195
figure_or_data , show_link , link_text , validate ,
192
- '100%' , 525 )
196
+ '100%' , 525 , global_requirejs = True )
193
197
194
198
display (HTML (plot_html ))
195
199
@@ -258,7 +262,7 @@ def plot(figure_or_data,
258
262
259
263
plot_html , plotdivid , width , height = _plot_html (
260
264
figure_or_data , show_link , link_text , validate ,
261
- '100%' , '100%' )
265
+ '100%' , '100%' , global_requirejs = False )
262
266
263
267
resize_script = ''
264
268
if width == '100%' or height == '100%' :
0 commit comments