Skip to content

Commit cef9304

Browse files
authoredFeb 20, 2020
Merge pull request #4595 from plotly/fix-splom-clear-select-via-api
Reset splom selectBatch and unselectBatch on updates
2 parents 15d75db + 2cac418 commit cef9304

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
 

‎src/traces/splom/scene_update.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ module.exports = function sceneUpdate(gd, trace) {
2020
var splomScenes = fullLayout._splomScenes;
2121
if(!splomScenes) splomScenes = fullLayout._splomScenes = {};
2222

23-
var reset = {dirty: true};
23+
var reset = {
24+
dirty: true,
25+
selectBatch: [],
26+
unselectBatch: []
27+
};
2428

2529
var first = {
2630
matrix: false,

‎test/jasmine/tests/splom_test.js

+41
Original file line numberDiff line numberDiff line change
@@ -1837,4 +1837,45 @@ describe('Test splom select:', function() {
18371837
.catch(failTest)
18381838
.then(done);
18391839
});
1840+
1841+
it('should be able to select and then clear using API', function(done) {
1842+
function _assert(msg, exp) {
1843+
return function() {
1844+
var uid = gd._fullData[0].uid;
1845+
var scene = gd._fullLayout._splomScenes[uid];
1846+
expect(scene.selectBatch).withContext(msg + ' selectBatch').toEqual(exp.selectBatch);
1847+
expect(scene.unselectBatch).withContext(msg + ' unselectBatch').toEqual(exp.unselectBatch);
1848+
};
1849+
}
1850+
1851+
Plotly.plot(gd, [{
1852+
type: 'splom',
1853+
dimensions: [{
1854+
values: [1, 2, 3]
1855+
}, {
1856+
values: [2, 3, 0]
1857+
}]
1858+
}], {
1859+
width: 400,
1860+
height: 400,
1861+
margin: {l: 0, t: 0, r: 0, b: 0},
1862+
dragmode: 'select'
1863+
})
1864+
.then(_assert('base', {
1865+
selectBatch: [],
1866+
unselectBatch: []
1867+
}))
1868+
.then(function() { return _select([[50, 50], [195, 195]]); })
1869+
.then(_assert('after selection', {
1870+
selectBatch: [1],
1871+
unselectBatch: [0, 2]
1872+
}))
1873+
.then(function() { return Plotly.restyle(gd, 'selectedpoints', null); })
1874+
.then(_assert('after API clear', {
1875+
selectBatch: [],
1876+
unselectBatch: []
1877+
}))
1878+
.catch(failTest)
1879+
.then(done);
1880+
});
18401881
});

0 commit comments

Comments
 (0)