@@ -772,12 +772,9 @@ function _hover(gd, evt, subplot, noHoverEvent) {
772772 hoverdistance : fullLayout . hoverdistance
773773 } ;
774774
775- var actualHoverData = hoverData . filter ( function ( d ) {
776- return d . hoverinfo !== 'none' ;
777- } ) ;
778- var hoverLabels = actualHoverData . length && createHoverText ( actualHoverData , labelOpts , gd ) ;
775+ var hoverLabels = createHoverText ( hoverData , labelOpts , gd ) ;
779776
780- if ( hoverLabels && ! helpers . isUnifiedHover ( hovermode ) ) {
777+ if ( ! helpers . isUnifiedHover ( hovermode ) ) {
781778 hoverAvoidOverlaps ( hoverLabels , rotateLabels ? 'xa' : 'ya' , fullLayout ) ;
782779 alignHoverText ( hoverLabels , rotateLabels , fullLayout . _invScaleX , fullLayout . _invScaleY ) ;
783780 } // TODO: tagName hack is needed to appease geo.js's hack of using evt.target=true
@@ -1025,14 +1022,11 @@ function createHoverText(hoverData, opts, gd) {
10251022
10261023 // Show a single hover label
10271024 if ( helpers . isUnifiedHover ( hovermode ) ) {
1028- var unifiedHoverData = hoverData . filter ( function ( d ) {
1029- return d . hoverinfo !== 'none' ;
1030- } ) ;
10311025 // Delete leftover hover labels from other hovermodes
10321026 container . selectAll ( 'g.hovertext' ) . remove ( ) ;
10331027
10341028 // Return early if nothing is hovered on
1035- if ( unifiedHoverData . length === 0 ) return ;
1029+ if ( hoverData . length === 0 ) return ;
10361030
10371031 // mock legend
10381032 var mockLayoutIn = {
@@ -1054,11 +1048,14 @@ function createHoverText(hoverData, opts, gd) {
10541048
10551049 // prepare items for the legend
10561050 mockLegend . entries = [ ] ;
1057- for ( var j = 0 ; j < unifiedHoverData . length ; j ++ ) {
1058- var texts = getHoverLabelText ( unifiedHoverData [ j ] , true , hovermode , fullLayout , t0 ) ;
1051+ for ( var j = 0 ; j < hoverData . length ; j ++ ) {
1052+ var pt = hoverData [ j ] ;
1053+ if ( pt . hoverinfo === 'none' ) continue ;
1054+
1055+ var texts = getHoverLabelText ( pt , true , hovermode , fullLayout , t0 ) ;
10591056 var text = texts [ 0 ] ;
10601057 var name = texts [ 1 ] ;
1061- var pt = unifiedHoverData [ j ] ;
1058+
10621059 pt . name = name ;
10631060 if ( name !== '' ) {
10641061 pt . text = name + ' : ' + text ;
@@ -1093,7 +1090,7 @@ function createHoverText(hoverData, opts, gd) {
10931090 var tbb = legendContainer . node ( ) . getBoundingClientRect ( ) ;
10941091 var tWidth = tbb . width + 2 * HOVERTEXTPAD ;
10951092 var tHeight = tbb . height + 2 * HOVERTEXTPAD ;
1096- var winningPoint = unifiedHoverData [ 0 ] ;
1093+ var winningPoint = hoverData [ 0 ] ;
10971094 var avgX = ( winningPoint . x0 + winningPoint . x1 ) / 2 ;
10981095 var avgY = ( winningPoint . y0 + winningPoint . y1 ) / 2 ;
10991096 // When a scatter (or e.g. heatmap) point wins, it's OK for the hovelabel to occlude the bar and other points.
@@ -1108,11 +1105,11 @@ function createHoverText(hoverData, opts, gd) {
11081105 lyTop = avgY - HOVERTEXTPAD ;
11091106 lyBottom = avgY + HOVERTEXTPAD ;
11101107 } else {
1111- lyTop = Math . min . apply ( null , unifiedHoverData . map ( function ( c ) { return Math . min ( c . y0 , c . y1 ) ; } ) ) ;
1112- lyBottom = Math . max . apply ( null , unifiedHoverData . map ( function ( c ) { return Math . max ( c . y0 , c . y1 ) ; } ) ) ;
1108+ lyTop = Math . min . apply ( null , hoverData . map ( function ( c ) { return Math . min ( c . y0 , c . y1 ) ; } ) ) ;
1109+ lyBottom = Math . max . apply ( null , hoverData . map ( function ( c ) { return Math . max ( c . y0 , c . y1 ) ; } ) ) ;
11131110 }
11141111 } else {
1115- lyTop = lyBottom = Lib . mean ( unifiedHoverData . map ( function ( c ) { return ( c . y0 + c . y1 ) / 2 ; } ) ) - tHeight / 2 ;
1112+ lyTop = lyBottom = Lib . mean ( hoverData . map ( function ( c ) { return ( c . y0 + c . y1 ) / 2 ; } ) ) - tHeight / 2 ;
11161113 }
11171114
11181115 var lxRight , lxLeft ;
@@ -1121,11 +1118,11 @@ function createHoverText(hoverData, opts, gd) {
11211118 lxRight = avgX + HOVERTEXTPAD ;
11221119 lxLeft = avgX - HOVERTEXTPAD ;
11231120 } else {
1124- lxRight = Math . max . apply ( null , unifiedHoverData . map ( function ( c ) { return Math . max ( c . x0 , c . x1 ) ; } ) ) ;
1125- lxLeft = Math . min . apply ( null , unifiedHoverData . map ( function ( c ) { return Math . min ( c . x0 , c . x1 ) ; } ) ) ;
1121+ lxRight = Math . max . apply ( null , hoverData . map ( function ( c ) { return Math . max ( c . x0 , c . x1 ) ; } ) ) ;
1122+ lxLeft = Math . min . apply ( null , hoverData . map ( function ( c ) { return Math . min ( c . x0 , c . x1 ) ; } ) ) ;
11261123 }
11271124 } else {
1128- lxRight = lxLeft = Lib . mean ( unifiedHoverData . map ( function ( c ) { return ( c . x0 + c . x1 ) / 2 ; } ) ) - tWidth / 2 ;
1125+ lxRight = lxLeft = Lib . mean ( hoverData . map ( function ( c ) { return ( c . x0 + c . x1 ) / 2 ; } ) ) - tWidth / 2 ;
11291126 }
11301127
11311128 var xOffset = xa . _offset ;
0 commit comments