Skip to content

Reset splom selectBatch and unselectBatch on updates #4595

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
Feb 20, 2020
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
6 changes: 5 additions & 1 deletion src/traces/splom/scene_update.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ module.exports = function sceneUpdate(gd, trace) {
var splomScenes = fullLayout._splomScenes;
if(!splomScenes) splomScenes = fullLayout._splomScenes = {};

var reset = {dirty: true};
var reset = {
dirty: true,
selectBatch: [],
unselectBatch: []
};

var first = {
matrix: false,
Expand Down
41 changes: 41 additions & 0 deletions test/jasmine/tests/splom_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1837,4 +1837,45 @@ describe('Test splom select:', function() {
.catch(failTest)
.then(done);
});

it('should be able to select and then clear using API', function(done) {
function _assert(msg, exp) {
return function() {
var uid = gd._fullData[0].uid;
var scene = gd._fullLayout._splomScenes[uid];
expect(scene.selectBatch).withContext(msg + ' selectBatch').toEqual(exp.selectBatch);
expect(scene.unselectBatch).withContext(msg + ' unselectBatch').toEqual(exp.unselectBatch);
};
}

Plotly.plot(gd, [{
type: 'splom',
dimensions: [{
values: [1, 2, 3]
}, {
values: [2, 3, 0]
}]
}], {
width: 400,
height: 400,
margin: {l: 0, t: 0, r: 0, b: 0},
dragmode: 'select'
})
.then(_assert('base', {
selectBatch: [],
unselectBatch: []
}))
.then(function() { return _select([[50, 50], [195, 195]]); })
.then(_assert('after selection', {
selectBatch: [1],
unselectBatch: [0, 2]
}))
.then(function() { return Plotly.restyle(gd, 'selectedpoints', null); })
.then(_assert('after API clear', {
selectBatch: [],
unselectBatch: []
Comment on lines +1875 to +1876
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before, these used to remain [1] and [0, 2] respectively.

}))
.catch(failTest)
.then(done);
});
});