Skip to content

Commit 47876b5

Browse files
committed
remove references to showLink and linkText
1 parent a293de3 commit 47876b5

5 files changed

Lines changed: 12 additions & 121 deletions

File tree

plotly/io/_html.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,10 @@ def to_html(
179179
else:
180180
div_height = str(div_height) + "px"
181181

182-
# ## Get platform URL ##
183-
if config.get("showLink", False) or config.get("showSendToCloud", False):
184-
# Figure is going to include a Chart Studio link or send-to-cloud button,
185-
# So we need to configure the PLOTLYENV.BASE_URL property
186-
base_url_line = """
187-
window.PLOTLYENV.BASE_URL='{plotly_platform_url}';\
188-
""".format(plotly_platform_url=config.get("plotlyServerURL", "https://plot.ly"))
189-
else:
190-
# Figure is not going to include a Chart Studio link or send-to-cloud button,
191-
# In this case we don't want https://plot.ly to show up anywhere in the HTML
192-
# output
182+
# Remove plotlyServerURL from config if showSendToCloud is False,
183+
# so that a Plotly URL does not appear in the HTML output
184+
if not config.get("showSendToCloud", False):
193185
config.pop("plotlyServerURL", None)
194-
config.pop("linkText", None)
195-
config.pop("showLink", None)
196-
base_url_line = ""
197186

198187
# ## Build script body ##
199188
# This is the part that actually calls Plotly.js
@@ -324,7 +313,7 @@ def to_html(
324313
<div id="{id}" class="plotly-graph-div" \
325314
style="height:100%; width:100%;"></div>\
326315
<script>\
327-
window.PLOTLYENV=window.PLOTLYENV || {{}};{base_url_line}\
316+
window.PLOTLYENV=window.PLOTLYENV || {{}};\
328317
{script};\
329318
</script>\
330319
</div>""".format(
@@ -333,7 +322,6 @@ def to_html(
333322
id=plotdivid,
334323
width=div_width,
335324
height=div_height,
336-
base_url_line=base_url_line,
337325
script=script,
338326
).strip()
339327

plotly/offline/offline.py

Lines changed: 7 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -156,35 +156,9 @@ def _get_jconfig(config=None):
156156
else:
157157
clean_config = {}
158158

159-
plotly_platform_url = tools.get_config_plotly_server_url()
160-
161-
if not clean_config.get("plotlyServerURL", None):
162-
clean_config["plotlyServerURL"] = plotly_platform_url
163-
164-
if (
165-
plotly_platform_url != "https://plot.ly"
166-
and clean_config.get("linkText", None) == "Export to plot.ly"
167-
):
168-
link_domain = plotly_platform_url.replace("https://", "").replace("http://", "")
169-
link_text = clean_config["linkText"].replace("plot.ly", link_domain)
170-
clean_config["linkText"] = link_text
171-
172159
return clean_config
173160

174161

175-
# Build script to set global PlotlyConfig object. This must execute before
176-
# plotly.js is loaded.
177-
_window_plotly_config = """\
178-
<script>\
179-
window.PlotlyConfig = {MathJaxConfig: 'local'};\
180-
</script>"""
181-
182-
_mathjax_config = """\
183-
<script>\
184-
if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}\
185-
</script>"""
186-
187-
188162
def get_image_download_script(caller):
189163
"""
190164
This function will return a script that will download an image of a Plotly
@@ -286,8 +260,6 @@ def init_notebook_mode(connected=False):
286260

287261
def iplot(
288262
figure_or_data,
289-
show_link=False,
290-
link_text="Export to plot.ly",
291263
validate=True,
292264
image=None,
293265
filename="plot_image",
@@ -306,10 +278,6 @@ def iplot(
306278
graph descriptions.
307279
308280
Keyword arguments:
309-
show_link (default=False) -- display a link in the bottom-right corner of
310-
of the chart that will export the chart to
311-
Plotly Cloud or Plotly Enterprise
312-
link_text (default='Export to plot.ly') -- the text of export link
313281
validate (default=True) -- validate that all of the keys in the figure
314282
are valid? omit if your version of plotly.js
315283
has become outdated with your version of
@@ -325,9 +293,7 @@ def iplot(
325293
will be saved to. The extension should not be included.
326294
image_height (default=600) -- Specifies the height of the image in `px`.
327295
image_width (default=800) -- Specifies the width of the image in `px`.
328-
config (default=None) -- Plot view options dictionary. Keyword arguments
329-
`show_link` and `link_text` set the associated options in this
330-
dictionary if it doesn't contain them already.
296+
config (default=None) -- Plot view options dictionary.
331297
auto_play (default=True) -- Whether to automatically start the animation
332298
sequence on page load, if the figure contains frames. Has no effect if
333299
the figure does not contain frames.
@@ -364,14 +330,12 @@ def iplot(
364330
"""
365331
import plotly.io as pio
366332

333+
config = dict(config) if config else {}
334+
367335
ipython = get_module("IPython")
368336
if not ipython:
369337
raise ImportError("`iplot` can only run inside an IPython Notebook.")
370338

371-
config = dict(config) if config else {}
372-
config.setdefault("showLink", show_link)
373-
config.setdefault("linkText", link_text)
374-
375339
# Get figure
376340
figure = tools.return_figure_from_figure_or_data(figure_or_data, validate)
377341

@@ -393,8 +357,6 @@ def iplot(
393357

394358
def plot(
395359
figure_or_data,
396-
show_link=False,
397-
link_text="Export to plot.ly",
398360
validate=True,
399361
output_type="file",
400362
include_plotlyjs=True,
@@ -430,10 +392,6 @@ def plot(
430392
graph descriptions.
431393
432394
Keyword arguments:
433-
show_link (default=False) -- display a link in the bottom-right corner of
434-
of the chart that will export the chart to Plotly Cloud or
435-
Plotly Enterprise
436-
link_text (default='Export to plot.ly') -- the text of export link
437395
validate (default=True) -- validate that all of the keys in the figure
438396
are valid? omit if your version of plotly.js has become outdated
439397
with your version of graph_reference.json or if you need to include
@@ -499,9 +457,7 @@ def plot(
499457
image will be saved to. The extension should not be included.
500458
image_height (default=600) -- Specifies the height of the image in `px`.
501459
image_width (default=800) -- Specifies the width of the image in `px`.
502-
config (default=None) -- Plot view options dictionary. Keyword arguments
503-
`show_link` and `link_text` set the associated options in this
504-
dictionary if it doesn't contain them already.
460+
config (default=None) -- Plot view options dictionary.
505461
include_mathjax (False | 'cdn' | path - default=False) --
506462
Specifies how the MathJax.js library is included in the output html
507463
file or div string. MathJax is required in order to display labels
@@ -544,6 +500,8 @@ def plot(
544500
"""
545501
import plotly.io as pio
546502

503+
config = dict(config) if config else {}
504+
547505
# Output type
548506
if output_type not in ["div", "file"]:
549507
raise ValueError(
@@ -557,11 +515,6 @@ def plot(
557515
)
558516
filename += ".html"
559517

560-
# Config
561-
config = dict(config) if config else {}
562-
config.setdefault("showLink", show_link)
563-
config.setdefault("linkText", link_text)
564-
565518
figure = tools.return_figure_from_figure_or_data(figure_or_data, validate)
566519
width = figure.get("layout", {}).get("width", "100%")
567520
height = figure.get("layout", {}).get("height", "100%")
@@ -608,8 +561,6 @@ def plot_mpl(
608561
resize=False,
609562
strip_style=False,
610563
verbose=False,
611-
show_link=False,
612-
link_text="Export to plot.ly",
613564
validate=True,
614565
output_type="file",
615566
include_plotlyjs=True,
@@ -635,10 +586,6 @@ def plot_mpl(
635586
resize (default=False) -- allow plotly to choose the figure size.
636587
strip_style (default=False) -- allow plotly to choose style options.
637588
verbose (default=False) -- print message.
638-
show_link (default=False) -- display a link in the bottom-right corner of
639-
of the chart that will export the chart to Plotly Cloud or
640-
Plotly Enterprise
641-
link_text (default='Export to plot.ly') -- the text of export link
642589
validate (default=True) -- validate that all of the keys in the figure
643590
are valid? omit if your version of plotly.js has become outdated
644591
with your version of graph_reference.json or if you need to include
@@ -692,8 +639,6 @@ def plot_mpl(
692639
plotly_plot = tools.mpl_to_plotly(mpl_fig, resize, strip_style, verbose)
693640
return plot(
694641
plotly_plot,
695-
show_link,
696-
link_text,
697642
validate,
698643
output_type,
699644
include_plotlyjs,
@@ -711,8 +656,6 @@ def iplot_mpl(
711656
resize=False,
712657
strip_style=False,
713658
verbose=False,
714-
show_link=False,
715-
link_text="Export to plot.ly",
716659
validate=True,
717660
image=None,
718661
image_filename="plot_image",
@@ -738,10 +681,6 @@ def iplot_mpl(
738681
resize (default=False) -- allow plotly to choose the figure size.
739682
strip_style (default=False) -- allow plotly to choose style options.
740683
verbose (default=False) -- print message.
741-
show_link (default=False) -- display a link in the bottom-right corner of
742-
of the chart that will export the chart to
743-
Plotly Cloud or Plotly Enterprise
744-
link_text (default='Export to plot.ly') -- the text of export link
745684
validate (default=True) -- validate that all of the keys in the figure
746685
are valid? omit if your version of plotly.js
747686
has become outdated with your version of
@@ -775,8 +714,6 @@ def iplot_mpl(
775714
plotly_plot = tools.mpl_to_plotly(mpl_fig, resize, strip_style, verbose)
776715
return iplot(
777716
plotly_plot,
778-
show_link,
779-
link_text,
780717
validate,
781718
image=image,
782719
filename=image_filename,
@@ -789,8 +726,6 @@ def enable_mpl_offline(
789726
resize=False,
790727
strip_style=False,
791728
verbose=False,
792-
show_link=False,
793-
link_text="Export to plot.ly",
794729
validate=True,
795730
):
796731
"""
@@ -827,6 +762,6 @@ def enable_mpl_offline(
827762
formatter.for_type(
828763
matplotlib.figure.Figure,
829764
lambda fig: iplot_mpl(
830-
fig, resize, strip_style, verbose, show_link, link_text, validate
765+
fig, resize, strip_style, verbose, validate
831766
),
832767
)

plotly/tools.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -603,29 +603,3 @@ def create_trisurf(*args, **kwargs):
603603

604604
return create_trisurf(*args, **kwargs)
605605

606-
607-
def get_config_plotly_server_url():
608-
"""
609-
Function to get the .config file's 'plotly_domain' without importing
610-
the chart_studio package. This property is needed to compute the default
611-
value of the plotly.js config plotlyServerURL, so it is independent of
612-
the chart_studio integration and still needs to live in
613-
614-
Returns
615-
-------
616-
str
617-
"""
618-
config_file = os.path.join(PLOTLY_DIR, ".config")
619-
default_server_url = "https://plot.ly"
620-
if not os.path.exists(config_file):
621-
return default_server_url
622-
with open(config_file, "rt") as f:
623-
try:
624-
config_dict = json.load(f)
625-
if not isinstance(config_dict, dict):
626-
config_dict = {}
627-
except Exception:
628-
# TODO: issue a warning and bubble it up
629-
config_dict = {}
630-
631-
return config_dict.get("plotly_domain", default_server_url)

tests/test_core/test_offline/test_offline.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,12 @@ def test_div_output(self):
281281
self.assertTrue(html.startswith("<div") and html.endswith("</div>"))
282282

283283
def test_config(self):
284-
config = dict(linkText="Plotly rocks!", showLink=True, editable=True)
284+
config = dict(editable=True)
285285
html = self._read_html(
286286
plotly.offline.plot(
287287
fig, config=config, auto_open=False, filename=html_filename
288288
)
289289
)
290-
self.assertIn('"linkText": "Plotly rocks!"', html)
291-
self.assertIn('"showLink": true', html)
292290
self.assertIn('"editable": true', html)
293291

294292
def test_config_bad_options(self):

tests/test_io/test_renderers.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ def test_plotly_mimetype_renderer_mimetype(fig1, renderer):
9696
pio.renderers.default = renderer
9797
expected = {plotly_mimetype: json.loads(pio.to_json(fig1, remove_uids=False))}
9898

99-
expected[plotly_mimetype]["config"] = {"plotlyServerURL": "https://plot.ly"}
100-
10199
pio.renderers.render_on_display = False
102100

103101
with mock.patch("IPython.display.display") as mock_display:
@@ -117,8 +115,6 @@ def test_plotly_mimetype_renderer_show(fig1, renderer):
117115
pio.renderers.default = renderer
118116
expected = {plotly_mimetype: json.loads(pio.to_json(fig1, remove_uids=False))}
119117

120-
expected[plotly_mimetype]["config"] = {"plotlyServerURL": "https://plot.ly"}
121-
122118
with mock.patch("IPython.display.display") as mock_display:
123119
pio.show(fig1)
124120

0 commit comments

Comments
 (0)