@@ -360,11 +360,15 @@ HTMLWidgets.widget({
360
360
_isSimpleKey : trace . _isSimpleKey
361
361
} ;
362
362
363
+ // Use pointNumber by default, but aggregated traces should emit pointNumbers
364
+ var ptNum = points [ i ] . pointNumber ;
365
+ var hasPtNum = typeof ptNum === "number" ;
366
+ var ptNum = hasPtNum ? ptNum : points [ i ] . pointNumbers ;
367
+
363
368
// selecting a point of a "simple" trace means: select the
364
369
// entire key attached to this trace, which is useful for,
365
370
// say clicking on a fitted line to select corresponding observations
366
- var pts = points [ i ] . pointNumber || points [ i ] . pointNumbers ;
367
- var key = trace . _isSimpleKey ? trace . key : Array . isArray ( pts ) ? pts . map ( function ( idx ) { return trace . key [ idx ] ; } ) : trace . key [ pts ] ;
371
+ var key = trace . _isSimpleKey ? trace . key : Array . isArray ( ptNum ) ? ptNum . map ( function ( idx ) { return trace . key [ idx ] ; } ) : trace . key [ ptNum ] ;
368
372
// http://stackoverflow.com/questions/10865025/merge-flatten-an-array-of-arrays-in-javascript
369
373
var keyFlat = trace . _isNestedKey ? [ ] . concat . apply ( [ ] , key ) : key ;
370
374
@@ -443,6 +447,8 @@ HTMLWidgets.widget({
443
447
}
444
448
}
445
449
450
+ //console.log(e.value);
451
+
446
452
// accumulate history for persistent selection
447
453
if ( ! x . highlight . persistent ) {
448
454
selectionHistory = [ event ] ;
@@ -467,7 +473,9 @@ HTMLWidgets.widget({
467
473
// Set a crosstalk variable selection value, triggering an update
468
474
var turnOn = function ( e ) {
469
475
if ( e ) {
476
+
470
477
var selectedKeys = pointsToKeys ( e . points ) ;
478
+ console . log ( selectedKeys ) ;
471
479
// Keys are group names, values are array of selected keys from group.
472
480
for ( var set in selectedKeys ) {
473
481
if ( selectedKeys . hasOwnProperty ( set ) ) {
0 commit comments