Skip to content

Commit cacc76b

Browse files
committed
fixups & 🔒 for plotlyServerUrl
1 parent 468b844 commit cacc76b

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

src/plot_api/plot_config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ module.exports = {
2121
// no interactivity, for export or image generation
2222
staticPlot: false,
2323

24+
// base url for the 'Edit in Chart Studio' (aka sendDataToCloud) mode bar button
25+
// and the showLink/sendData on-graph link
26+
plotlyServerUrl: 'https://plot.ly',
27+
2428
/*
2529
* we can edit titles, move annotations, etc - sets all pieces of `edits`
2630
* unless a separate `edits` config item overrides individual parts

src/plots/plots.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,7 @@ function positionPlayWithData(gd, container) {
214214
plots.sendDataToCloud = function(gd) {
215215
gd.emit('plotly_beforeexport');
216216

217-
var baseUrl = (
218-
(window.PLOTLYENV && window.PLOTLYENV.BASE_URL) ||
219-
(gd.framework.getConfig().plotlyServerUrl) ||
220-
'https://plot.ly'
221-
);
217+
var baseUrl = (window.PLOTLYENV || {}).BASE_URL || gd._context.plotlyServerUrl;
222218

223219
var hiddenformDiv = d3.select(gd)
224220
.append('div')

test/jasmine/tests/config_test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,33 @@ describe('config argument', function() {
470470
var editBox = document.getElementsByClassName('plugin-editable editable')[0];
471471
expect(editBox).toBeUndefined();
472472
});
473+
});
474+
475+
describe('plotlyServerUrl:', function() {
476+
var gd;
477+
478+
beforeEach(function() {
479+
gd = createGraphDiv();
480+
});
473481

482+
afterEach(destroyGraphDiv);
474483

484+
it('should default to plotly cloud', function(done) {
485+
Plotly.plot(gd, [], {})
486+
.then(function() {
487+
expect(gd._context.plotlyServerUrl).toBe('https://plot.ly');
488+
})
489+
.catch(failTest)
490+
.then(done);
491+
});
492+
493+
it('can be set to other base urls', function(done) {
494+
Plotly.plot(gd, [], {}, {plotlyServerUrl: 'dummy'})
495+
.then(function() {
496+
expect(gd._context.plotlyServerUrl).toBe('dummy');
497+
})
498+
.catch(failTest)
499+
.then(done);
500+
});
475501
});
476502
});

0 commit comments

Comments
 (0)