Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c342abf

Browse files
committed
changed the html code for plot functin vs iplot
1 parent a918639 commit c342abf

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

plotly/offline/offline.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def init_notebook_mode():
7373

7474

7575
def _plot_html(figure_or_data, show_link, link_text,
76-
validate, default_width, default_height):
76+
validate, default_width, default_height, **kwargs):
7777

7878
figure = tools.return_figure_from_figure_or_data(figure_or_data, validate)
7979

@@ -121,6 +121,42 @@ def _plot_html(figure_or_data, show_link, link_text,
121121
layout=jlayout,
122122
config=jconfig)
123123

124+
if kwargs and kwargs['browser']:
125+
plotly_html_div = (
126+
''
127+
'<div id="{id}" style="height: {height}; width: {width};" '
128+
'class="plotly-graph-div">'
129+
'</div>'
130+
'<script type="text/javascript">'
131+
'window.PLOTLYENV=window.PLOTLYENV || {{}};'
132+
'window.PLOTLYENV.BASE_URL="' + plotly_platform_url + '";'
133+
'{script}'
134+
'</script>'
135+
'').format(
136+
id=plotdivid, script=script,
137+
height=height, width=width)
138+
139+
return plotly_html_div, plotdivid, width, height
140+
141+
else:
142+
plotly_html_div = (
143+
''
144+
'<div id="{id}" style="height: {height}; width: {width};" '
145+
'class="plotly-graph-div">'
146+
'</div>'
147+
'<script type="text/javascript">'
148+
'require(["plotly"], function(Plotly) {{'
149+
'window.PLOTLYENV=window.PLOTLYENV || {{}};'
150+
'window.PLOTLYENV.BASE_URL="' + plotly_platform_url + '";'
151+
'{script}'
152+
'}});'
153+
'</script>'
154+
'').format(
155+
id=plotdivid, script=script,
156+
height=height, width=width)
157+
158+
return plotly_html_div, plotdivid, width, height
159+
124160
plotly_html_div = (
125161
''
126162
'<div id="{id}" style="height: {height}; width: {width};" '
@@ -258,7 +294,7 @@ def plot(figure_or_data,
258294

259295
plot_html, plotdivid, width, height = _plot_html(
260296
figure_or_data, show_link, link_text, validate,
261-
'100%', '100%')
297+
'100%', '100%', browser=True)
262298

263299
resize_script = ''
264300
if width == '100%' or height == '100%':

0 commit comments

Comments
 (0)