@@ -813,10 +813,7 @@ function hoverDataKey(d) {
813
813
814
814
var EXTRA_STRING_REGEX = / < e x t r a > ( [ \s \S ] * ) < \/ e x t r a > / ;
815
815
816
- function createHoverText ( allHoverData , opts , gd ) {
817
- var hoverData = allHoverData . filter ( function ( d ) {
818
- return d . hoverinfo !== 'none' ;
819
- } ) ;
816
+ function createHoverText ( hoverData , opts , gd ) {
820
817
var fullLayout = gd . _fullLayout ;
821
818
var hovermode = opts . hovermode ;
822
819
var rotateLabels = opts . rotateLabels ;
@@ -1028,11 +1025,14 @@ function createHoverText(allHoverData, opts, gd) {
1028
1025
1029
1026
// Show a single hover label
1030
1027
if ( helpers . isUnifiedHover ( hovermode ) ) {
1028
+ var unifiedHoverData = hoverData . filter ( function ( d ) {
1029
+ return d . hoverinfo !== 'none' ;
1030
+ } ) ;
1031
1031
// Delete leftover hover labels from other hovermodes
1032
1032
container . selectAll ( 'g.hovertext' ) . remove ( ) ;
1033
1033
1034
1034
// Return early if nothing is hovered on
1035
- if ( hoverData . length === 0 ) return ;
1035
+ if ( unifiedHoverData . length === 0 ) return ;
1036
1036
1037
1037
// mock legend
1038
1038
var mockLayoutIn = {
@@ -1054,11 +1054,11 @@ function createHoverText(allHoverData, opts, gd) {
1054
1054
1055
1055
// prepare items for the legend
1056
1056
mockLegend . entries = [ ] ;
1057
- for ( var j = 0 ; j < hoverData . length ; j ++ ) {
1058
- var texts = getHoverLabelText ( hoverData [ j ] , true , hovermode , fullLayout , t0 ) ;
1057
+ for ( var j = 0 ; j < unifiedHoverData . length ; j ++ ) {
1058
+ var texts = getHoverLabelText ( unifiedHoverData [ j ] , true , hovermode , fullLayout , t0 ) ;
1059
1059
var text = texts [ 0 ] ;
1060
1060
var name = texts [ 1 ] ;
1061
- var pt = hoverData [ j ] ;
1061
+ var pt = unifiedHoverData [ j ] ;
1062
1062
pt . name = name ;
1063
1063
if ( name !== '' ) {
1064
1064
pt . text = name + ' : ' + text ;
@@ -1093,7 +1093,7 @@ function createHoverText(allHoverData, opts, gd) {
1093
1093
var tbb = legendContainer . node ( ) . getBoundingClientRect ( ) ;
1094
1094
var tWidth = tbb . width + 2 * HOVERTEXTPAD ;
1095
1095
var tHeight = tbb . height + 2 * HOVERTEXTPAD ;
1096
- var winningPoint = hoverData [ 0 ] ;
1096
+ var winningPoint = unifiedHoverData [ 0 ] ;
1097
1097
var avgX = ( winningPoint . x0 + winningPoint . x1 ) / 2 ;
1098
1098
var avgY = ( winningPoint . y0 + winningPoint . y1 ) / 2 ;
1099
1099
// When a scatter (or e.g. heatmap) point wins, it's OK for the hovelabel to occlude the bar and other points.
@@ -1108,11 +1108,11 @@ function createHoverText(allHoverData, opts, gd) {
1108
1108
lyTop = avgY - HOVERTEXTPAD ;
1109
1109
lyBottom = avgY + HOVERTEXTPAD ;
1110
1110
} 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 ) ; } ) ) ;
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 ) ; } ) ) ;
1113
1113
}
1114
1114
} else {
1115
- lyTop = lyBottom = Lib . mean ( hoverData . map ( function ( c ) { return ( c . y0 + c . y1 ) / 2 ; } ) ) - tHeight / 2 ;
1115
+ lyTop = lyBottom = Lib . mean ( unifiedHoverData . map ( function ( c ) { return ( c . y0 + c . y1 ) / 2 ; } ) ) - tHeight / 2 ;
1116
1116
}
1117
1117
1118
1118
var lxRight , lxLeft ;
@@ -1121,11 +1121,11 @@ function createHoverText(allHoverData, opts, gd) {
1121
1121
lxRight = avgX + HOVERTEXTPAD ;
1122
1122
lxLeft = avgX - HOVERTEXTPAD ;
1123
1123
} 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 ) ; } ) ) ;
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 ) ; } ) ) ;
1126
1126
}
1127
1127
} else {
1128
- lxRight = lxLeft = Lib . mean ( hoverData . map ( function ( c ) { return ( c . x0 + c . x1 ) / 2 ; } ) ) - tWidth / 2 ;
1128
+ lxRight = lxLeft = Lib . mean ( unifiedHoverData . map ( function ( c ) { return ( c . x0 + c . x1 ) / 2 ; } ) ) - tWidth / 2 ;
1129
1129
}
1130
1130
1131
1131
var xOffset = xa . _offset ;
0 commit comments