@@ -772,12 +772,9 @@ function _hover(gd, evt, subplot, noHoverEvent) {
772
772
hoverdistance : fullLayout . hoverdistance
773
773
} ;
774
774
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 ) ;
779
776
780
- if ( hoverLabels && ! helpers . isUnifiedHover ( hovermode ) ) {
777
+ if ( ! helpers . isUnifiedHover ( hovermode ) ) {
781
778
hoverAvoidOverlaps ( hoverLabels , rotateLabels ? 'xa' : 'ya' , fullLayout ) ;
782
779
alignHoverText ( hoverLabels , rotateLabels , fullLayout . _invScaleX , fullLayout . _invScaleY ) ;
783
780
} // 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) {
1025
1022
1026
1023
// Show a single hover label
1027
1024
if ( helpers . isUnifiedHover ( hovermode ) ) {
1028
- var unifiedHoverData = hoverData . filter ( function ( d ) {
1029
- return d . hoverinfo !== 'none' ;
1030
- } ) ;
1031
1025
// Delete leftover hover labels from other hovermodes
1032
1026
container . selectAll ( 'g.hovertext' ) . remove ( ) ;
1033
1027
1034
1028
// Return early if nothing is hovered on
1035
- if ( unifiedHoverData . length === 0 ) return ;
1029
+ if ( hoverData . length === 0 ) return ;
1036
1030
1037
1031
// mock legend
1038
1032
var mockLayoutIn = {
@@ -1054,11 +1048,11 @@ function createHoverText(hoverData, opts, gd) {
1054
1048
1055
1049
// prepare items for the legend
1056
1050
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 texts = getHoverLabelText ( hoverData [ j ] , true , hovermode , fullLayout , t0 ) ;
1059
1053
var text = texts [ 0 ] ;
1060
1054
var name = texts [ 1 ] ;
1061
- var pt = unifiedHoverData [ j ] ;
1055
+ var pt = hoverData [ j ] ;
1062
1056
pt . name = name ;
1063
1057
if ( name !== '' ) {
1064
1058
pt . text = name + ' : ' + text ;
@@ -1093,7 +1087,7 @@ function createHoverText(hoverData, opts, gd) {
1093
1087
var tbb = legendContainer . node ( ) . getBoundingClientRect ( ) ;
1094
1088
var tWidth = tbb . width + 2 * HOVERTEXTPAD ;
1095
1089
var tHeight = tbb . height + 2 * HOVERTEXTPAD ;
1096
- var winningPoint = unifiedHoverData [ 0 ] ;
1090
+ var winningPoint = hoverData [ 0 ] ;
1097
1091
var avgX = ( winningPoint . x0 + winningPoint . x1 ) / 2 ;
1098
1092
var avgY = ( winningPoint . y0 + winningPoint . y1 ) / 2 ;
1099
1093
// When a scatter (or e.g. heatmap) point wins, it's OK for the hovelabel to occlude the bar and other points.
@@ -1108,11 +1102,11 @@ function createHoverText(hoverData, opts, gd) {
1108
1102
lyTop = avgY - HOVERTEXTPAD ;
1109
1103
lyBottom = avgY + HOVERTEXTPAD ;
1110
1104
} 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 ) ; } ) ) ;
1105
+ lyTop = Math . min . apply ( null , hoverData . map ( function ( c ) { return Math . min ( c . y0 , c . y1 ) ; } ) ) ;
1106
+ lyBottom = Math . max . apply ( null , hoverData . map ( function ( c ) { return Math . max ( c . y0 , c . y1 ) ; } ) ) ;
1113
1107
}
1114
1108
} else {
1115
- lyTop = lyBottom = Lib . mean ( unifiedHoverData . map ( function ( c ) { return ( c . y0 + c . y1 ) / 2 ; } ) ) - tHeight / 2 ;
1109
+ lyTop = lyBottom = Lib . mean ( hoverData . map ( function ( c ) { return ( c . y0 + c . y1 ) / 2 ; } ) ) - tHeight / 2 ;
1116
1110
}
1117
1111
1118
1112
var lxRight , lxLeft ;
@@ -1121,11 +1115,11 @@ function createHoverText(hoverData, opts, gd) {
1121
1115
lxRight = avgX + HOVERTEXTPAD ;
1122
1116
lxLeft = avgX - HOVERTEXTPAD ;
1123
1117
} 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 ) ; } ) ) ;
1118
+ lxRight = Math . max . apply ( null , hoverData . map ( function ( c ) { return Math . max ( c . x0 , c . x1 ) ; } ) ) ;
1119
+ lxLeft = Math . min . apply ( null , hoverData . map ( function ( c ) { return Math . min ( c . x0 , c . x1 ) ; } ) ) ;
1126
1120
}
1127
1121
} else {
1128
- lxRight = lxLeft = Lib . mean ( unifiedHoverData . map ( function ( c ) { return ( c . x0 + c . x1 ) / 2 ; } ) ) - tWidth / 2 ;
1122
+ lxRight = lxLeft = Lib . mean ( hoverData . map ( function ( c ) { return ( c . x0 + c . x1 ) / 2 ; } ) ) - tWidth / 2 ;
1129
1123
}
1130
1124
1131
1125
var xOffset = xa . _offset ;
0 commit comments