@@ -73,7 +73,7 @@ def init_notebook_mode():
7373
7474
7575def _plot_html (figure_or_data , show_link , link_text ,
76- validate , default_width , default_height ):
76+ validate , default_width , default_height , global_requirejs ):
7777
7878 figure = tools .return_figure_from_figure_or_data (figure_or_data , validate )
7979
@@ -121,17 +121,21 @@ def _plot_html(figure_or_data, show_link, link_text,
121121 layout = jlayout ,
122122 config = jconfig )
123123
124+ optional_line1 = ('require(["plotly"], function(Plotly) {{ '
125+ if global_requirejs else '' )
126+ optional_line2 = '}});' if global_requirejs else ''
127+ 124128 plotly_html_div = (
125129 ''
126130 '<div id="{id}" style="height: {height}; width: {width};" '
127131 'class="plotly-graph-div">'
128132 '</div>'
129- '<script type="text/javascript">'
130- 'require(["plotly"], function(Plotly) {{'
133+ '<script type="text/javascript">' +
134+ optional_line1 +
131135 'window.PLOTLYENV=window.PLOTLYENV || {{}};'
132136 'window.PLOTLYENV.BASE_URL="' + plotly_platform_url + '";'
133- '{script}'
134- '}});'
137+ '{script}' +
138+ optional_line2 +
135139 '</script>'
136140 '' ).format (
137141 id = plotdivid , script = script ,
@@ -189,7 +193,7 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
189193
190194 plot_html , plotdivid , width , height = _plot_html (
191195 figure_or_data , show_link , link_text , validate ,
192- '100%' , 525 )
196+ '100%' , 525 , global_requirejs = True )
193197
194198 display (HTML (plot_html ))
195199
@@ -258,7 +262,7 @@ def plot(figure_or_data,
258262
259263 plot_html , plotdivid , width , height = _plot_html (
260264 figure_or_data , show_link , link_text , validate ,
261- '100%' , '100%' )
265+ '100%' , '100%' , global_requirejs = False )
262266
263267 resize_script = ''
264268 if width == '100%' or height == '100%' :
0 commit comments