@@ -379,6 +379,7 @@ function hover(gd, evt, subplot) {
379379 curvenum ,
380380 cd ,
381381 trace ,
382+ subplotId ,
382383 subploti ,
383384 mode ,
384385 xval ,
@@ -468,7 +469,8 @@ function hover(gd, evt, subplot) {
468469 if ( ! cd || ! cd [ 0 ] || ! cd [ 0 ] . trace || cd [ 0 ] . trace . visible !== true ) continue ;
469470
470471 trace = cd [ 0 ] . trace ;
471- subploti = subplots . indexOf ( getSubplot ( trace ) ) ;
472+ subplotId = getSubplot ( trace ) ;
473+ subploti = subplots . indexOf ( subplotId ) ;
472474
473475 // within one trace mode can sometimes be overridden
474476 mode = hovermode ;
@@ -495,6 +497,11 @@ function hover(gd, evt, subplot) {
495497 text : undefined
496498 } ;
497499
500+ // add ref to subplot object (non-cartesian case)
501+ if ( fullLayout [ subplotId ] ) {
502+ pointData . subplot = fullLayout [ subplotId ] . _subplot ;
503+ }
504+
498505 closedataPreviousLength = hoverData . length ;
499506
500507 // for a highlighting array, figure out what
@@ -545,7 +552,6 @@ function hover(gd, evt, subplot) {
545552 hoverData . splice ( 0 , closedataPreviousLength ) ;
546553 distance = hoverData [ 0 ] . distance ;
547554 }
548-
549555 }
550556
551557 // nothing left: remove all labels and quit
@@ -583,31 +589,35 @@ function hover(gd, evt, subplot) {
583589 // other people and send it to the event
584590 for ( itemnum = 0 ; itemnum < hoverData . length ; itemnum ++ ) {
585591 var pt = hoverData [ itemnum ] ;
592+
586593 var out = {
587594 data : pt . trace . _input ,
588595 fullData : pt . trace ,
589596 curveNumber : pt . trace . index ,
590- pointNumber : pt . index ,
591- x : pt . xVal ,
592- y : pt . yVal ,
593- xaxis : pt . xa ,
594- yaxis : pt . ya
597+ pointNumber : pt . index
595598 } ;
596- if ( pt . zLabelVal !== undefined ) out . z = pt . zLabelVal ;
599+
600+ if ( pt . trace . _module . eventData ) out = pt . trace . _module . eventData ( out , pt ) ;
601+ else {
602+ out . x = pt . xVal ;
603+ out . y = pt . yVal ;
604+ out . xaxis = pt . xa ;
605+ out . yaxis = pt . ya ;
606+
607+ if ( pt . zLabelVal !== undefined ) out . z = pt . zLabelVal ;
608+ }
609+
597610 newhoverdata . push ( out ) ;
598611 }
612+
599613 gd . _hoverdata = newhoverdata ;
600614
601615 if ( ! hoverChanged ( gd , evt , oldhoverdata ) ) return ;
602616
603- /* Emit the custom hover handler. Bind this like:
604- * gd.on('hover.plotly', function(extras) {
605- * // do something with extras.data
606- * });
607- */
608617 if ( oldhoverdata ) {
609618 gd . emit ( 'plotly_unhover' , { points : oldhoverdata } ) ;
610619 }
620+
611621 gd . emit ( 'plotly_hover' , {
612622 points : gd . _hoverdata ,
613623 xaxes : xaArray ,
@@ -620,7 +630,7 @@ function hover(gd, evt, subplot) {
620630// look for either .subplot (currently just ternary)
621631// or xaxis and yaxis attributes
622632function getSubplot ( trace ) {
623- return trace . subplot || ( trace . xaxis + trace . yaxis ) ;
633+ return trace . subplot || ( trace . xaxis + trace . yaxis ) || trace . geo ;
624634}
625635
626636fx . getDistanceFunction = function ( mode , dx , dy , dxy ) {
@@ -724,6 +734,7 @@ function cleanPoint(d, hovermode) {
724734 if ( infomode . indexOf ( 'text' ) === - 1 ) d . text = undefined ;
725735 if ( infomode . indexOf ( 'name' ) === - 1 ) d . name = undefined ;
726736 }
737+
727738 return d ;
728739}
729740
0 commit comments