Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c653188

Browse filesBrowse files
committed
export to enterprise; update link text the plotly.js way.
1 parent a47c761 commit c653188
Copy full SHA for c653188

File tree

1 file changed

+21
-8
lines changed
Filter options

1 file changed

+21
-8
lines changed

‎plotly/offline.py

Copy file name to clipboardExpand all lines: plotly/offline.py
+21-8Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,35 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly'):
8787
jdata = json.dumps(data, cls=utils.PlotlyJSONEncoder)
8888
jlayout = json.dumps(layout, cls=utils.PlotlyJSONEncoder)
8989

90+
if show_link is False:
91+
link_text = ''
92+
93+
plotly_platform_url = py.get_config().get('plotly_domain',
94+
'https://plot.ly')
95+
if (plotly_platform_url != 'https://plot.ly' and
96+
link_text == 'Export to plot.ly'):
97+
98+
link_domain = plotly_platform_url\
99+
.replace('https://', '')\
100+
.replace('http://', '')
101+
link_text = link_text.replace('plot.ly', link_domain)
102+
103+
display(HTML(
104+
'<script type="text/javascript">'
105+
'window.PLOTLYENV={"BASE_URL": "' + plotly_platform_url + '"};'
106+
'Plotly.LINKTEXT = "' + link_text + '";'
107+
'</script>'
108+
))
109+
90110
script = '\n'.join([
91111
'Plotly.plot("{id}", {data}, {layout}).then(function() {{',
92112
' $(".{id}.loading").remove();',
93-
' $(".link--embedview").text("{link_text}");'
113+
'}})'
94114
]).format(id=plotdivid,
95115
data=jdata,
96116
layout=jlayout,
97117
link_text=link_text)
98118

99-
if not show_link:
100-
script += '\n'.join([
101-
' $("{} .link--embedview").remove();'.format(plotdivid),
102-
'\n});'])
103-
else:
104-
script += '\n});'
105-
106119
display(HTML(''
107120
'<div class="{id} loading" style="color: rgb(50,50,50);">'
108121
'Drawing...</div>'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.