Skip to content

Commit ca9dd35

Browse files
authored
Merge pull request #622 from plotly/fix-plot-other-domain
Fix Plotting Error in other domains besides plot.ly
2 parents 81315f7 + 18de041 commit ca9dd35

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

Diff for: CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [Unreleased]
5+
## [1.12.11] - 2016-12-01
6+
### Fixed
7+
- The `link text` in the bottom right corner of the offline plots now properly displays `Export to [Domain Name]` for the given domain name set in the users' `.config` file.
68

79
## [1.12.10] - 2016-11-28
810
### Updated

Diff for: plotly/offline/offline.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,21 @@ def _plot_html(figure_or_data, config, validate, default_width,
211211
)
212212

213213
config_clean = dict((k, config[k]) for k in configkeys if k in config)
214-
215214
jconfig = json.dumps(config_clean)
216215

217216
# TODO: The get_config 'source of truth' should
218217
# really be somewhere other than plotly.plotly
219218
plotly_platform_url = plotly.plotly.get_config().get('plotly_domain',
220219
'https://plot.ly')
221220
if (plotly_platform_url != 'https://plot.ly' and
222-
link_text == 'Export to plot.ly'):
221+
config['linkText'] == 'Export to plot.ly'):
223222

224223
link_domain = plotly_platform_url\
225224
.replace('https://', '')\
226225
.replace('http://', '')
227-
link_text = link_text.replace('plot.ly', link_domain)
226+
link_text = config['linkText'].replace('plot.ly', link_domain)
228227
config['linkText'] = link_text
228+
jconfig = jconfig.replace('Export to plot.ly', link_text)
229229

230230
if 'frames' in figure_or_data:
231231
script = '''
@@ -360,13 +360,10 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
360360
display(HTML(script))
361361

362362

363-
def plot(figure_or_data,
364-
show_link=True, link_text='Export to plot.ly',
365-
validate=True, output_type='file',
366-
include_plotlyjs=True,
367-
filename='temp-plot.html', auto_open=True,
368-
image=None, image_filename='plot_image',
369-
image_width=800, image_height=600):
363+
def plot(figure_or_data, show_link=True, link_text='Export to plot.ly',
364+
validate=True, output_type='file', include_plotlyjs=True,
365+
filename='temp-plot.html', auto_open=True, image=None,
366+
image_filename='plot_image', image_width=800, image_height=600):
370367
""" Create a plotly graph locally as an HTML document or string.
371368
372369
Example:

Diff for: plotly/tests/test_core/test_offline/test_offline.py

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from nose.tools import raises
88
from unittest import TestCase
9+
from plotly.tests.utils import PlotlyTestCase
910
import json
1011

1112
import plotly
@@ -21,6 +22,7 @@
2122

2223
PLOTLYJS = plotly.offline.offline.get_plotlyjs()
2324

25+
2426
class PlotlyOfflineTestCase(TestCase):
2527
def setUp(self):
2628
pass
@@ -78,3 +80,23 @@ def test_autoresizing(self):
7880
})
7981
for resize_code_string in resize_code_strings:
8082
self.assertTrue(resize_code_string not in html)
83+
84+
85+
class PlotlyOfflineOtherDomainTestCase(PlotlyTestCase):
86+
def setUp(self):
87+
super(PlotlyOfflineOtherDomainTestCase, self).setUp()
88+
plotly.tools.set_config_file(plotly_domain='https://stage.plot.ly',
89+
plotly_api_domain='https://api-stage.plot.ly')
90+
plotly.plotly.sign_in('PlotlyTestShark', 'kI2H0E7sTZ5RM9yoaK4X')
91+
92+
def test_plot_rendered_if_non_plotly_domain(self):
93+
html = plotly.offline.plot(fig, output_type='div')
94+
95+
# test that 'Export to stage.plot.ly' is in the html
96+
self.assertTrue('Export to stage.plot.ly' in html)
97+
98+
def tearDown(self):
99+
plotly.tools.set_config_file(plotly_domain='https://plot.ly',
100+
plotly_api_domain='https://api.plot.ly')
101+
plotly.plotly.sign_in('PythonTest', '9v9f20pext')
102+
super(PlotlyOfflineOtherDomainTestCase, self).tearDown()

Diff for: plotly/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.12.10'
1+
__version__ = '1.12.11'

0 commit comments

Comments
 (0)