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({
3737 if ( ! e ) window . event ;
3838 if ( e . shiftKey ) {
3939 x . highlight . persistent = true ;
40+ x . highlight . persistentShift = true ;
4041 } else {
4142 x . highlight . persistent = false ;
43+ x . highlight . persistentShift = false ;
4244 }
4345 } ;
4446
@@ -354,6 +356,17 @@ HTMLWidgets.widget({
354356
355357 var selectionChange = function ( e ) {
356358
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+
357370 // array of "event objects" tracking the selection history
358371 // this is used to avoid adding redundant selections
359372 var selectionHistory = crosstalk . var ( "plotlySelectionHistory" ) . get ( ) || [ ] ;
You can’t perform that action at this time.
0 commit comments