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 4 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
23 changes: 23 additions & 0 deletions src/plots/geo/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
var isClipped = geoLayoutOut._isClipped = !!constants.lonaxisSpan[projType];

var visible = coerce('visible');
if(geoLayoutIn.visible === false) {
visible = geoLayoutOut.visible = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we setting geoLayoutOut.visible = true here? Looks to me as though it doesn't matter for the end result, is that right? RCE would want the false to remain intact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad.

// 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
104 changes: 79 additions & 25 deletions 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 All @@ -650,39 +650,93 @@ describe('Test Geo layout defaults', function() {
});
}

it('- base case', function() {
layoutIn = {
geo: { visible: false }
};
[true, false, undefined].forEach(function(q) {
it('- base case | ' + q, function() {
layoutIn = {
template: {
layout: {
geo: {
Copy link
Collaborator

@alexcjohnson alexcjohnson Jan 11, 2020

Choose a reason for hiding this comment

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

sorry to be a pain, but I still don't see a test case that sets template.layout.geo.visible=false, does NOT set layout.geo.visible, and verifies that template.layout.geo.show* settings are still honored in fullLayout.geo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 9448c8f.

showcoastlines: q,
showcountries: q,
showframe: q,
showland: q,
showlakes: q,
showocean: q,
showrivers: q,
showsubunits: q,
lonaxis: { showgrid: q },
lataxis: { showgrid: q }
}
}
},
geo: { visible: false }
};

supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showsubunits: undefined
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showsubunits: undefined
});
});
});

it('- scoped case', function() {
layoutIn = {
geo: { scope: 'europe', visible: false }
};
[true, false, undefined].forEach(function(q) {
it('- scoped case', function() {
layoutIn = {
template: {
layout: {
geo: {
showcoastlines: q,
showcountries: q,
showframe: q,
showland: q,
showlakes: q,
showocean: q,
showrivers: q,
showsubunits: q,
lonaxis: { showgrid: q },
lataxis: { showgrid: q }
}
}
},
geo: { scope: 'europe', visible: false }
};

supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showframe: undefined,
showsubunits: undefined
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showframe: undefined,
showsubunits: undefined
});
});
});

it('- scope:usa case', function() {
layoutIn = {
geo: { scope: 'usa', visible: false }
};
[true, false, undefined].forEach(function(q) {
it('- scope:usa case', function() {
layoutIn = {
template: {
layout: {
geo: {
showcoastlines: q,
showcountries: q,
showframe: q,
showland: q,
showlakes: q,
showocean: q,
showrivers: q,
showsubunits: q,
lonaxis: { showgrid: q },
lataxis: { showgrid: q }
}
}
},
geo: { scope: 'usa', visible: false }
};

supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showframe: undefined,
showcoastlines: undefined,
showocean: undefined
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
_assert({
showframe: undefined,
showcoastlines: undefined,
showocean: undefined
});
});
});
});
Expand Down