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

Skip to content

Commit b676827

Browse files
committed
use the config to set the showLink and linkText
1 parent 1ac4816 commit b676827

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

plotly/offline/offline.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
124124
jdata = json.dumps(figure.get('data', []), cls=utils.PlotlyJSONEncoder)
125125
jlayout = json.dumps(figure.get('layout', {}), cls=utils.PlotlyJSONEncoder)
126126

127-
if show_link is False:
128-
link_text = ''
127+
config = {}
128+
config['showLink'] = show_link
129+
config['linkText'] = link_text
130+
jconfig = json.dumps(config)
129131

130132
plotly_platform_url = session.get_session_config().get('plotly_domain',
131133
'https://plot.ly')
@@ -141,18 +143,17 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
141143
'<script type="text/javascript">'
142144
'window.PLOTLYENV=window.PLOTLYENV || {};'
143145
'window.PLOTLYENV.BASE_URL="' + plotly_platform_url + '";'
144-
'Plotly.LINKTEXT = "' + link_text + '";'
145146
'</script>'
146147
))
147148

148149
script = '\n'.join([
149-
'Plotly.plot("{id}", {data}, {layout}).then(function() {{',
150+
'Plotly.plot("{id}", {data}, {layout}, {config}).then(function() {{',
150151
' $(".{id}.loading").remove();',
151152
'}})'
152153
]).format(id=plotdivid,
153154
data=jdata,
154155
layout=jlayout,
155-
link_text=link_text)
156+
config=jconfig)
156157

157158
display(HTML(''
158159
'<div class="{id} loading" style="color: rgb(50,50,50);">'

0 commit comments

Comments
 (0)