Skip to content

fix for transforms operating on auto-invisible traces #3139

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 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,8 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout, fullLayout) {
fullTrace._expandedIndex = cnt;

if(fullTrace.transforms && fullTrace.transforms.length) {
var sdInvisible = trace.visible !== false && fullTrace.visible === false;

var expandedTraces = applyTransforms(fullTrace, dataOut, layout, fullLayout);

for(var j = 0; j < expandedTraces.length; j++) {
Expand All @@ -964,6 +966,17 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout, fullLayout) {
// to promote consistency between update calls
uid: fullTrace.uid + j
};

// If the first supplyDefaults created `visible: false`,
// clear it before running supplyDefaults a second time,
// because sometimes there are items we still want to coerce
// inside trace modules before determining that the trace is
// again `visible: false`, for example partial visibilities
// in `splom` traces.
if(sdInvisible && expandedTrace.visible === false) {
delete expandedTrace.visible;
}

plots.supplyTraceDefaults(expandedTrace, fullExpandedTrace, cnt, fullLayout, i);

// relink private (i.e. underscore) keys expanded trace to full expanded trace so
Expand Down
31 changes: 31 additions & 0 deletions test/jasmine/tests/splom_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,37 @@ describe('Test splom trace defaults:', function() {
});

expect(gd._fullData[0].visible).toBe(false);

// make sure these are still coerced - so you can get back via GUI!
expect(gd._fullData[0].showupperhalf).toBe(false);
expect(gd._fullData[0].showlowerhalf).toBe(false);
expect(gd._fullData[0].diagonal.visible).toBe(false);
});

it('still coerces partial visibilities even if all are false with transforms', function() {
_supply({
dimensions: [{
values: [1, 2, 3]
}],
showupperhalf: false,
showlowerhalf: false,
diagonal: {visible: false},
transforms: [{
type: 'filter',
target: 'dimensions[0].values',
operation: '>',
value: 2
}]
});

expect(gd._fullData[0].visible).toBe(false);

expect(gd._fullData[0].transforms[0].enabled).toBe(true);

// make sure these are still coerced - so you can get back via GUI!
expect(gd._fullData[0].showupperhalf).toBe(false);
expect(gd._fullData[0].showlowerhalf).toBe(false);
expect(gd._fullData[0].diagonal.visible).toBe(false);
});

it('should set `visible: false` to values-less dimensions', function() {
Expand Down