Skip to content

Commit 5125981

Browse files
committed
Use clearEntireSelection flag in cartesian/select [1852]
- Reason: more efficient than the extra hack for scattergl for the case when no point is selected at all.
1 parent 4f0a05d commit 5125981

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/plots/cartesian/select.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,12 @@ function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines) {
356356
searchInfo = searchTraces[i];
357357
trace = searchInfo.cd[0].trace;
358358

359-
// Start new selection if needed
360-
if(!retainSelection) {
359+
// Clear old selection if needed
360+
if(!retainSelection || clearEntireSelection) {
361361
searchInfo._module.toggleSelected(searchInfo, false);
362362
if(outlines) outlines.remove();
363+
364+
if(clearEntireSelection) continue;
363365
}
364366

365367
// Determine clicked points,
@@ -384,23 +386,9 @@ function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines) {
384386
allSelectionItems = allSelectionItems.concat(fillSelectionItem(traceSelection, searchInfo));
385387
}
386388

387-
// TODO Use the clearEntireSelection flag now
388-
// Hack to achieve regl traces to set selectBatch to null in case no point is selected anymore
389-
// TODO check in advance if a click clear the entire selection, because in this
390-
// case just call toggleSelected(searchInfo, false) on all traces and be done. The `shouldSelect` above might
391-
// become obsolete.
392-
if(allSelectionItems.length === 0) {
393-
for(i = 0; i < searchTraces.length; i++) {
394-
searchTraces[i]._module.toggleSelected(searchTraces[i], false);
395-
}
396-
}
397-
398389
// Grand selection state update needs to be done once for the entire plot
399390
eventData = {points: allSelectionItems};
400391
updateSelectedState(gd, searchTraces, eventData);
401-
402-
// Remove outlines if no point is selected anymore
403-
if(allSelectionItems.length === 0 && outlines) outlines.remove();
404392
}
405393

406394
function clickedPtsFor(searchInfo, hoverData) {

0 commit comments

Comments
 (0)