@@ -259,6 +259,8 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
259
259
if ( clickmode === 'event' ) {
260
260
// TODO: remove in v2 - this was probably never intended to work as it does,
261
261
// but in case anyone depends on it we don't want to break it now.
262
+ // Note that click-to-select introduced pre v2 also emitts proper
263
+ // event data when clickmode is having 'select' in its flag list.
262
264
gd . emit ( 'plotly_selected' , undefined ) ;
263
265
}
264
266
}
@@ -528,24 +530,6 @@ function createPtNumTester(wantedPointNumber, wantedSearchInfo, subtract) {
528
530
}
529
531
530
532
function isPointOrBinSelected ( clickedPtInfo ) {
531
- // TODO improve perf
532
- // Primarily we need this function to determine if a click adds or subtracts from a selection.
533
- //
534
- // IME best user experience would be
535
- // - that Shift+Click an unselected points adds to selection
536
- // - and Shift+Click a selected point subtracts from selection.
537
- //
538
- // Several options:
539
- // 1. Avoid problem at all by binding subtract-selection-by-click operation to Shift+Alt-Click.
540
- // Slightly less intuitive. A lot of programs deselect an already selected element when you
541
- // Shift+Click it.
542
- // 2. Delegate decision to the traces module through an additional
543
- // isSelected(searchInfo, pointNumber) function. Traces like scatter or bar have
544
- // a selected flag attached to each calcData element, thus access to that information
545
- // would be fast. However, scattergl only maintains selectBatch and unselectBatch arrays.
546
- // So simply searching through those arrays in scattegl would be slow. Just imagine
547
- // a user selecting all data points with one lasso polygon. So scattergl would require some
548
- // work.
549
533
var trace = clickedPtInfo . searchInfo . cd [ 0 ] . trace ;
550
534
var ptNum = clickedPtInfo . pointNumber ;
551
535
var ptNums = clickedPtInfo . pointNumbers ;
@@ -556,6 +540,11 @@ function isPointOrBinSelected(clickedPtInfo) {
556
540
// a bin is selected, all others are as well
557
541
var ptNumToTest = ptNumsSet ? ptNums [ 0 ] : ptNum ;
558
542
543
+ // TODO potential performance improvement
544
+ // Primarily we need this function to determine if a click adds
545
+ // or subtracts from a selection.
546
+ // In cases `trace.selectedpoints` is a huge array, indexOf
547
+ // might be slow. One remedy would be to introduce a hash somewhere.
559
548
return trace . selectedpoints ? trace . selectedpoints . indexOf ( ptNumToTest ) > - 1 : false ;
560
549
}
561
550
0 commit comments