Skip to content

Commit 4ec7dd1

Browse files
authoredFeb 25, 2019
Merge pull request #3577 from plotly/clear-select-on-axrange-relayout
Clear selection outline during 'axrange' relayout calls
2 parents 13b925c + 35a55e1 commit 4ec7dd1

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
 

‎src/plot_api/plot_api.js

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var connectColorbar = require('../components/colorbar/connect');
3232
var initInteractions = require('../plots/cartesian/graph_interact').initInteractions;
3333
var xmlnsNamespaces = require('../constants/xmlns_namespaces');
3434
var svgTextUtils = require('../lib/svg_text_utils');
35+
var clearSelect = require('../plots/cartesian/select').clearSelect;
3536

3637
var dfltConfig = require('./plot_config').dfltConfig;
3738
var manageArrays = require('./manage_arrays');
@@ -2001,7 +2002,13 @@ function addAxRangeSequence(seq, rangesAltered) {
20012002
return Axes.draw(gd, 'redraw');
20022003
};
20032004

2005+
var _clearSelect = function(gd) {
2006+
var zoomlayer = gd._fullLayout._zoomlayer;
2007+
if(zoomlayer) clearSelect(zoomlayer);
2008+
};
2009+
20042010
seq.push(
2011+
_clearSelect,
20052012
subroutines.doAutoRangeAndConstraints,
20062013
drawAxes,
20072014
subroutines.drawData,

‎test/jasmine/tests/select_test.js

+22
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,28 @@ describe('Test select box and lasso in general:', function() {
12261226
.then(done);
12271227
});
12281228

1229+
it('@flaky should have their selection outlines cleared during *axrange* relayout calls', function(done) {
1230+
var gd = createGraphDiv();
1231+
var fig = Lib.extendDeep({}, mock);
1232+
fig.layout.dragmode = 'select';
1233+
1234+
function _drag() {
1235+
resetEvents(gd);
1236+
drag(selectPath);
1237+
return selectedPromise;
1238+
}
1239+
1240+
Plotly.plot(gd, fig)
1241+
.then(_drag)
1242+
.then(function() { assertSelectionNodes(0, 2, 'after drag 1'); })
1243+
.then(function() { return Plotly.relayout(gd, 'xaxis.range', [-5, 5]); })
1244+
.then(function() { assertSelectionNodes(0, 0, 'after axrange relayout'); })
1245+
.then(_drag)
1246+
.then(function() { assertSelectionNodes(0, 2, 'after drag 2'); })
1247+
.catch(failTest)
1248+
.then(done);
1249+
});
1250+
12291251
it('@flaky should select the right data with the corresponding select direction', function(done) {
12301252

12311253
var gd = createGraphDiv();

0 commit comments

Comments
 (0)
Please sign in to comment.