From 2cac418868a06cbef0e8ad90213bb8bb8d27a582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 20 Feb 2020 17:07:01 -0500 Subject: [PATCH] reset splom selectBatch and unselectBatch on updates --- src/traces/splom/scene_update.js | 6 ++++- test/jasmine/tests/splom_test.js | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/traces/splom/scene_update.js b/src/traces/splom/scene_update.js index b93dadecae7..7f78de04be2 100644 --- a/src/traces/splom/scene_update.js +++ b/src/traces/splom/scene_update.js @@ -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, diff --git a/test/jasmine/tests/splom_test.js b/test/jasmine/tests/splom_test.js index c10b705b246..7052124d76e 100644 --- a/test/jasmine/tests/splom_test.js +++ b/test/jasmine/tests/splom_test.js @@ -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); + }); });