Skip to content

geo.visible false should override template.layout.geo.show* #4483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/plots/geo/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
var isClipped = geoLayoutOut._isClipped = !!constants.lonaxisSpan[projType];

var visible = coerce('visible');
if(visible === false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still incorrect when the visible=false came from the template (which we still need a test for - showing that all the show* end up true in that case). I guess the condition here should be if(geoLayoutIn.visible === false)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 639913e.

// should override template.layout.geo.show* - see issue 4482

// make a copy
var newTemplate = Lib.extendDeep({}, geoLayoutOut._template);

// override show*
newTemplate.showcoastlines = false;
newTemplate.showcountries = false;
newTemplate.showframe = false;
newTemplate.showlakes = false;
newTemplate.showland = false;
newTemplate.showocean = false;
newTemplate.showrivers = false;
newTemplate.showsubunits = false;
if(newTemplate.lonaxis) newTemplate.lonaxis.showgrid = false;
if(newTemplate.lataxis) newTemplate.lataxis.showgrid = false;

// set ref to copy
geoLayoutOut._template = newTemplate;
}

var show;

for(var i = 0; i < axesNames.length; i++) {
Expand Down
18 changes: 17 additions & 1 deletion test/jasmine/tests/geo_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ describe('Test Geo layout defaults', function() {
});
});

describe('geo.visible should override show* defaults', function() {
describe('geo.visible should override show* defaults even with template any show* is true', function() {
var keys = [
'lonaxis.showgrid',
'lataxis.showgrid',
Expand Down Expand Up @@ -652,6 +652,22 @@ describe('Test Geo layout defaults', function() {

it('- base case', function() {
layoutIn = {
template: {
layout: {
geo: {
showcoastlines: true,
showcountries: true,
showframe: true,
showland: true,
showlakes: true,
showocean: true,
showrivers: true,
showsubunits: true,
lonaxis: { showgrid: true },
lataxis: { showgrid: true }
}
}
},
geo: { visible: false }
};

Expand Down