Skip to content

Commit

Permalink
Merge pull request #4595 from plotly/fix-splom-clear-select-via-api
Browse files Browse the repository at this point in the history
Reset splom selectBatch and unselectBatch on updates
  • Loading branch information
etpinard committed Feb 20, 2020
2 parents 15d75db + 2cac418 commit cef9304
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
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: []
}))
.catch(failTest)
.then(done);
});
});

0 comments on commit cef9304

Please sign in to comment.