File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,10 @@ HTMLWidgets.widget({
37
37
if ( ! e ) window . event ;
38
38
if ( e . shiftKey ) {
39
39
x . highlight . persistent = true ;
40
+ x . highlight . persistentShift = true ;
40
41
} else {
41
42
x . highlight . persistent = false ;
43
+ x . highlight . persistentShift = false ;
42
44
}
43
45
} ;
44
46
@@ -354,6 +356,17 @@ HTMLWidgets.widget({
354
356
355
357
var selectionChange = function ( e ) {
356
358
359
+ // Workaround for 'plotly_selected' now firing previously selected
360
+ // points (in addition to new ones) when holding shift key. In our case,
361
+ // we just want the new keys
362
+ if ( x . highlight . on === "plotly_selected" && x . highlight . persistentShift ) {
363
+ // https://stackoverflow.com/questions/1187518/how-to-get-the-difference-between-two-arrays-in-javascript
364
+ Array . prototype . diff = function ( a ) {
365
+ return this . filter ( function ( i ) { return a . indexOf ( i ) < 0 ; } ) ;
366
+ } ;
367
+ e . value = e . value . diff ( e . oldValue ) ;
368
+ }
369
+
357
370
// array of "event objects" tracking the selection history
358
371
// this is used to avoid adding redundant selections
359
372
var selectionHistory = crosstalk . var ( "plotlySelectionHistory" ) . get ( ) || [ ] ;
You can’t perform that action at this time.
0 commit comments