Skip to content

Commit 8ef5cb3

Browse files
committed
fix and 🔒 splom trace visible toggling
1 parent 9c8ba02 commit 8ef5cb3

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/plots/cartesian/type_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function getFirstNonEmptyTrace(data, id, axLetter) {
108108

109109
if(trace.type === 'splom' &&
110110
trace._length > 0 &&
111-
trace['_' + axLetter + 'axes'][id]
111+
(trace['_' + axLetter + 'axes'] || {})[id]
112112
) {
113113
return trace;
114114
}

test/jasmine/tests/splom_test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,35 @@ describe('@gl Test splom interactions:', function() {
579579
.catch(failTest)
580580
.then(done);
581581
});
582+
583+
it('should toggle trace correctly', function(done) {
584+
var fig = Lib.extendDeep({}, require('@mocks/splom_iris.json'));
585+
586+
function _assert(msg, exp) {
587+
for(var i = 0; i < 3; i++) {
588+
expect(Boolean(gd.calcdata[i][0].t._scene))
589+
.toBe(Boolean(exp[i]), msg + ' - trace ' + i);
590+
}
591+
}
592+
593+
Plotly.plot(gd, fig).then(function() {
594+
_assert('base', [1, 1, 1]);
595+
return Plotly.restyle(gd, 'visible', 'legendonly', [0, 2]);
596+
})
597+
.then(function() {
598+
_assert('0-2 legendonly', [0, 1, 0]);
599+
return Plotly.restyle(gd, 'visible', false);
600+
})
601+
.then(function() {
602+
_assert('all gone', [0, 0, 0]);
603+
return Plotly.restyle(gd, 'visible', true);
604+
})
605+
.then(function() {
606+
_assert('all back', [1, 1, 1]);
607+
})
608+
.catch(failTest)
609+
.then(done);
610+
});
582611
});
583612

584613
describe('@gl Test splom hover:', function() {

0 commit comments

Comments
 (0)