Skip to content

Commit 4b1c90e

Browse files
committed
geo.visible false should override template.layout.geo.show*
1 parent f89a5ae commit 4b1c90e

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/plots/plots.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,29 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
14461446

14471447
var template = layoutIn.template;
14481448
if(Lib.isPlainObject(template)) {
1449+
if( // geo.visible false should override template.layout.geo.show* - see issue 4482
1450+
layoutIn.geo &&
1451+
layoutIn.geo.visible === false &&
1452+
template.layout &&
1453+
template.layout.geo
1454+
) {
1455+
// make a copy
1456+
var newTemplate = Lib.extendDeep({}, template);
1457+
1458+
// override show*
1459+
newTemplate.layout.geo.showcoastlines = false;
1460+
newTemplate.layout.geo.showcountries = false;
1461+
newTemplate.layout.geo.showframe = false;
1462+
newTemplate.layout.geo.showlakes = false;
1463+
newTemplate.layout.geo.showland = false;
1464+
newTemplate.layout.geo.showocean = false;
1465+
newTemplate.layout.geo.showrivers = false;
1466+
newTemplate.layout.geo.showsubunits = false;
1467+
1468+
// set ref to copy
1469+
template = newTemplate;
1470+
}
1471+
14491472
layoutOut.template = template;
14501473
layoutOut._template = template.layout;
14511474
layoutOut._dataTemplate = template.data;

test/jasmine/tests/geo_test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,51 @@ describe('Test Geo layout defaults', function() {
688688
});
689689
});
690690

691+
describe('geo visible false', function() {
692+
var gd;
693+
694+
beforeEach(function() { gd = createGraphDiv(); });
695+
696+
afterEach(destroyGraphDiv);
697+
698+
it('should override template.layout.geo.show*', function(done) {
699+
var keys = [
700+
'showcoastlines',
701+
'showcountries',
702+
'showframe',
703+
'showland',
704+
'showlakes',
705+
'showocean',
706+
'showrivers',
707+
'showsubunits'
708+
];
709+
710+
var layout = {
711+
geo: { visible: false },
712+
template: {
713+
layout: {
714+
geo: {}
715+
}
716+
}
717+
};
718+
719+
keys.forEach(function(k) {
720+
layout.template.layout.geo[k] = true;
721+
});
722+
723+
var data = [{ lon: [0], lat: [0], type: 'scattergeo' }];
724+
725+
Plotly.plot(gd, data, layout)
726+
.then(function() {
727+
keys.forEach(function(k) {
728+
expect(gd._fullLayout.template.layout.geo[k]).toBe(false, k);
729+
});
730+
})
731+
.catch(failTest)
732+
.then(done);
733+
});
734+
});
735+
691736
describe('geojson / topojson utils', function() {
692737
function _locationToFeature(topojson, loc, locationmode) {
693738
var trace = { locationmode: locationmode };

0 commit comments

Comments
 (0)