Skip to content

Commit

Permalink
Merge pull request #3139 from plotly/transform-visibility
Browse files Browse the repository at this point in the history
fix for transforms operating on auto-invisible traces
  • Loading branch information
alexcjohnson authored Oct 23, 2018
2 parents 0b99103 + 6f9f298 commit 117fbaa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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

0 comments on commit 117fbaa

Please sign in to comment.