Skip to content

Commit 52fe1d1

Browse files
committed
a fixes for redraw calls in plotly_selecting handlers
1 parent d2bd951 commit 52fe1d1

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/plots/cartesian/dragbox.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
226226
updateSubplots([0, 0, pw, ph]);
227227
dragOptions.moveFn(dragDataNow.dx, dragDataNow.dy);
228228
}
229+
230+
// TODO should we try to "re-select" under select/lasso modes?
229231
}
230232
};
231233
};

src/plots/cartesian/select.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var throttle = require('../../lib/throttle');
2020
var makeEventData = require('../../components/fx/helpers').makeEventData;
2121
var getFromId = require('./axis_ids').getFromId;
2222
var clearGlCanvases = require('../../lib/clear_gl_canvases');
23+
2324
var redrawReglTraces = require('../../plot_api/subroutines').redrawReglTraces;
2425

2526
var constants = require('./constants');
@@ -669,7 +670,7 @@ function updateSelectedState(gd, searchTraces, eventData) {
669670
// before anything else, update preGUI if necessary
670671
for(i = 0; i < searchTraces.length; i++) {
671672
var fullInputTrace = searchTraces[i].cd[0].trace._fullInput;
672-
var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid];
673+
var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid] || {};
673674
if(tracePreGUI.selectedpoints === undefined) {
674675
tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null;
675676
}

src/plots/plots.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var Lib = require('../lib');
1919
var Color = require('../components/color');
2020
var BADNUM = require('../constants/numerical').BADNUM;
2121

22-
var axisIDs = require('../plots/cartesian/axis_ids');
22+
var axisIDs = require('./cartesian/axis_ids');
2323

2424
var animationAttrs = require('./animation_attributes');
2525
var frameAttrs = require('./frame_attributes');
@@ -476,6 +476,15 @@ plots.supplyDefaults = function(gd, opts) {
476476
// clean subplots and other artifacts from previous plot calls
477477
plots.cleanPlot(newFullData, newFullLayout, oldFullData, oldFullLayout);
478478

479+
// clear selection outline until we implement persistent selection,
480+
// don't clear them though when drag handlers (e.g. listening to
481+
// `plotly_selecting`) update the graph.
482+
// we should try to come up with a better solution when implementing
483+
// https://github.com/plotly/plotly.js/issues/1851
484+
if(oldFullLayout._zoomlayer && !gd._dragging) {
485+
oldFullLayout._zoomlayer.selectAll('.select-outline').remove();
486+
}
487+
479488
// relink functions and _ attributes to promote consistency between plots
480489
relinkPrivateKeys(newFullLayout, oldFullLayout);
481490

@@ -779,10 +788,6 @@ plots.cleanPlot = function(newFullData, newFullLayout, oldFullData, oldFullLayou
779788
oldFullLayout._infolayer.select('.cb' + oldUid).remove();
780789
}
781790
}
782-
783-
if(oldFullLayout._zoomlayer) {
784-
oldFullLayout._zoomlayer.selectAll('.select-outline').remove();
785-
}
786791
};
787792

788793
plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {

0 commit comments

Comments
 (0)