Skip to content
Closed
2 changes: 1 addition & 1 deletion src/plots/cartesian/type_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function getFirstNonEmptyTrace(data, id, axLetter) {

if(trace.type === 'splom' &&
trace._length > 0 &&
trace['_' + axLetter + 'axes'][id]
(trace['_' + axLetter + 'axes'] || {})[id]
) {
return trace;
}
Expand Down
35 changes: 35 additions & 0 deletions test/jasmine/tests/splom_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,41 @@ describe('@gl Test splom interactions:', function() {
.catch(failTest)
.then(done);
});

it('should toggle trace correctly', function(done) {
var fig = Lib.extendDeep({}, require('@mocks/splom_iris.json'));

function _assert(msg, exp) {
for(var i = 0; i < 3; i++) {
var draw = gd.calcdata[i][0].t._scene.draw;
expect(draw).toHaveBeenCalledTimes(exp[i], msg + ' - trace ' + i);
draw.calls.reset();
}
}

Plotly.plot(gd, fig).then(function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is broken on master, consider this a bug fix.

spyOn(gd.calcdata[0][0].t._scene, 'draw');
spyOn(gd.calcdata[1][0].t._scene, 'draw');
spyOn(gd.calcdata[2][0].t._scene, 'draw');

return Plotly.restyle(gd, 'visible', 'legendonly', [0, 2]);
})
.then(function() {
_assert('0-2 legendonly', [0, 1, 0]);

return Plotly.restyle(gd, 'visible', false);
})
.then(function() {
_assert('all gone', [0, 0, 0]);

return Plotly.restyle(gd, 'visible', true);
})
.then(function() {
_assert('all back', [1, 1, 1]);
})
.catch(failTest)
.then(done);
});
});

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