@@ -464,6 +464,24 @@ proto.updateTraces = function(fullData, calcData) {
464
464
}
465
465
} ;
466
466
467
+ proto . emitPointAction = function ( nextSelection , eventType ) {
468
+
469
+ var curveIndex = this . _inputs [ nextSelection . trace . uid ] ;
470
+
471
+ this . graphDiv . emit ( eventType , {
472
+ points : [ {
473
+ x : nextSelection . traceCoord [ 0 ] ,
474
+ y : nextSelection . traceCoord [ 1 ] ,
475
+ curveNumber : curveIndex ,
476
+ pointNumber : nextSelection . pointIndex ,
477
+ data : this . fullData [ curveIndex ] . _input ,
478
+ fullData : this . fullData ,
479
+ xaxis : this . xaxis ,
480
+ yaxis : this . yaxis
481
+ } ]
482
+ } ) ;
483
+ } ;
484
+
467
485
proto . draw = function ( ) {
468
486
if ( this . stopped ) return ;
469
487
@@ -507,22 +525,9 @@ proto.draw = function() {
507
525
) ;
508
526
509
527
var nextSelection = result && result . object . _trace . handlePick ( result ) ;
510
- var curveIndex ;
511
528
512
529
if ( nextSelection && mouseUp ) {
513
- curveIndex = this . _inputs [ nextSelection . trace . uid ] ;
514
- this . graphDiv . emit ( 'plotly_click' , {
515
- points : [ {
516
- x : nextSelection . traceCoord [ 0 ] ,
517
- y : nextSelection . traceCoord [ 1 ] ,
518
- curveNumber : curveIndex ,
519
- pointNumber : nextSelection . pointIndex ,
520
- data : this . fullData [ curveIndex ] . _input ,
521
- fullData : this . fullData ,
522
- xaxis : this . xaxis ,
523
- yaxis : this . yaxis
524
- } ]
525
- } ) ;
530
+ this . emitPointAction ( nextSelection , 'plotly_click' ) ;
526
531
}
527
532
528
533
if ( result && result . object . _trace . hoverinfo !== 'skip' && fullLayout . hovermode ) {
@@ -554,19 +559,7 @@ proto.draw = function() {
554
559
555
560
// this needs to happen before the next block that deletes traceCoord data
556
561
// also it's important to copy, otherwise data is lost by the time event data is read
557
- curveIndex = this . _inputs [ nextSelection . trace . uid ] ;
558
- this . graphDiv . emit ( 'plotly_hover' , {
559
- points : [ {
560
- x : nextSelection . traceCoord [ 0 ] ,
561
- y : nextSelection . traceCoord [ 1 ] ,
562
- curveNumber : curveIndex ,
563
- pointNumber : nextSelection . pointIndex ,
564
- data : this . fullData [ curveIndex ] . _input ,
565
- fullData : this . fullData ,
566
- xaxis : this . xaxis ,
567
- yaxis : this . yaxis
568
- } ]
569
- } ) ;
562
+ this . emitPointAction ( nextSelection , 'plotly_hover' ) ;
570
563
571
564
var hoverinfo = selection . hoverinfo ;
572
565
if ( hoverinfo !== 'all' ) {
0 commit comments