@@ -810,8 +810,7 @@ function hoverDataKey(d) {
810810
811811var EXTRA_STRING_REGEX = / < e x t r a > ( [ \s \S ] * ) < \/ e x t r a > / ;
812812
813- function createHoverText ( allHoverData , opts , gd ) {
814- var hoverData = allHoverData . filter ( function ( data ) { return data . hoverinfo !== 'none' ; } ) ;
813+ function createHoverText ( hoverData , opts , gd ) {
815814 var fullLayout = gd . _fullLayout ;
816815 var hovermode = opts . hovermode ;
817816 var rotateLabels = opts . rotateLabels ;
@@ -1027,9 +1026,9 @@ function createHoverText(allHoverData, opts, gd) {
10271026 if ( helpers . isUnifiedHover ( hovermode ) ) {
10281027 // Delete leftover hover labels from other hovermodes
10291028 container . selectAll ( 'g.hovertext' ) . remove ( ) ;
1030-
1029+ var groupedHoverData = hoverData . filter ( function ( data ) { return data . hoverinfo !== 'none' ; } ) ;
10311030 // Return early if nothing is hovered on
1032- if ( hoverData . length === 0 ) return ;
1031+ if ( groupedHoverData . length === 0 ) return ;
10331032
10341033 // mock legend
10351034 var mockLayoutIn = {
@@ -1051,8 +1050,8 @@ function createHoverText(allHoverData, opts, gd) {
10511050
10521051 // prepare items for the legend
10531052 mockLegend . entries = [ ] ;
1054- for ( var j = 0 ; j < hoverData . length ; j ++ ) {
1055- var pt = hoverData [ j ] ;
1053+ for ( var j = 0 ; j < groupedHoverData . length ; j ++ ) {
1054+ var pt = groupedHoverData [ j ] ;
10561055 if ( pt . hoverinfo === 'none' ) continue ;
10571056
10581057 var texts = getHoverLabelText ( pt , true , hovermode , fullLayout , t0 ) ;
@@ -1093,7 +1092,7 @@ function createHoverText(allHoverData, opts, gd) {
10931092 var tbb = legendContainer . node ( ) . getBoundingClientRect ( ) ;
10941093 var tWidth = tbb . width + 2 * HOVERTEXTPAD ;
10951094 var tHeight = tbb . height + 2 * HOVERTEXTPAD ;
1096- var winningPoint = hoverData [ 0 ] ;
1095+ var winningPoint = groupedHoverData [ 0 ] ;
10971096 var avgX = ( winningPoint . x0 + winningPoint . x1 ) / 2 ;
10981097 var avgY = ( winningPoint . y0 + winningPoint . y1 ) / 2 ;
10991098 // When a scatter (or e.g. heatmap) point wins, it's OK for the hovelabel to occlude the bar and other points.
@@ -1108,11 +1107,11 @@ function createHoverText(allHoverData, opts, gd) {
11081107 lyTop = avgY - HOVERTEXTPAD ;
11091108 lyBottom = avgY + HOVERTEXTPAD ;
11101109 } else {
1111- lyTop = Math . min . apply ( null , hoverData . map ( function ( c ) { return Math . min ( c . y0 , c . y1 ) ; } ) ) ;
1112- lyBottom = Math . max . apply ( null , hoverData . map ( function ( c ) { return Math . max ( c . y0 , c . y1 ) ; } ) ) ;
1110+ lyTop = Math . min . apply ( null , groupedHoverData . map ( function ( c ) { return Math . min ( c . y0 , c . y1 ) ; } ) ) ;
1111+ lyBottom = Math . max . apply ( null , groupedHoverData . map ( function ( c ) { return Math . max ( c . y0 , c . y1 ) ; } ) ) ;
11131112 }
11141113 } else {
1115- lyTop = lyBottom = Lib . mean ( hoverData . map ( function ( c ) { return ( c . y0 + c . y1 ) / 2 ; } ) ) - tHeight / 2 ;
1114+ lyTop = lyBottom = Lib . mean ( groupedHoverData . map ( function ( c ) { return ( c . y0 + c . y1 ) / 2 ; } ) ) - tHeight / 2 ;
11161115 }
11171116
11181117 var lxRight , lxLeft ;
@@ -1121,11 +1120,11 @@ function createHoverText(allHoverData, opts, gd) {
11211120 lxRight = avgX + HOVERTEXTPAD ;
11221121 lxLeft = avgX - HOVERTEXTPAD ;
11231122 } else {
1124- lxRight = Math . max . apply ( null , hoverData . map ( function ( c ) { return Math . max ( c . x0 , c . x1 ) ; } ) ) ;
1125- lxLeft = Math . min . apply ( null , hoverData . map ( function ( c ) { return Math . min ( c . x0 , c . x1 ) ; } ) ) ;
1123+ lxRight = Math . max . apply ( null , groupedHoverData . map ( function ( c ) { return Math . max ( c . x0 , c . x1 ) ; } ) ) ;
1124+ lxLeft = Math . min . apply ( null , groupedHoverData . map ( function ( c ) { return Math . min ( c . x0 , c . x1 ) ; } ) ) ;
11261125 }
11271126 } else {
1128- lxRight = lxLeft = Lib . mean ( hoverData . map ( function ( c ) { return ( c . x0 + c . x1 ) / 2 ; } ) ) - tWidth / 2 ;
1127+ lxRight = lxLeft = Lib . mean ( groupedHoverData . map ( function ( c ) { return ( c . x0 + c . x1 ) / 2 ; } ) ) - tWidth / 2 ;
11291128 }
11301129
11311130 var xOffset = xa . _offset ;
0 commit comments