@@ -1088,14 +1088,17 @@ function createHoverText(hoverData, opts, gd) {
1088
1088
var tWidth = tbb . width + 2 * HOVERTEXTPAD ;
1089
1089
var tHeight = tbb . height + 2 * HOVERTEXTPAD ;
1090
1090
var winningPoint = hoverData [ 0 ] ;
1091
- // When the scatter point wins, it's OK for the hovelabel to occlude the bar and other points.
1092
- var scatterWon = cartesianScatterPoints [ winningPoint . trace . type ] ;
1091
+ // When a scatter (or e.g. heatmap) point wins, it's OK for the hovelabel to occlude the bar and other points.
1092
+ var pointWon = ! (
1093
+ Registry . traceIs ( winningPoint . trace , 'bar-like' ) ||
1094
+ Registry . traceIs ( winningPoint . trace , 'box-violin' )
1095
+ ) ;
1093
1096
1094
1097
var lyBottom , lyTop ;
1095
1098
if ( axLetter === 'y' ) {
1096
- if ( scatterWon ) {
1097
- lyTop = Math . min ( winningPoint . y0 , winningPoint . y1 ) ;
1098
- lyBottom = Math . max ( winningPoint . y0 , winningPoint . y1 ) ;
1099
+ if ( pointWon ) {
1100
+ lyTop = ( winningPoint . y0 + winningPoint . y1 ) / 2 - HOVERTEXTPAD ;
1101
+ lyBottom = ( winningPoint . y0 + winningPoint . y1 ) / 2 + HOVERTEXTPAD ;
1099
1102
} else {
1100
1103
lyTop = Math . min . apply ( null , hoverData . map ( function ( c ) { return Math . min ( c . y0 , c . y1 ) ; } ) ) ;
1101
1104
lyBottom = Math . max . apply ( null , hoverData . map ( function ( c ) { return Math . max ( c . y0 , c . y1 ) ; } ) ) ;
@@ -1106,9 +1109,9 @@ function createHoverText(hoverData, opts, gd) {
1106
1109
1107
1110
var lxRight , lxLeft ;
1108
1111
if ( axLetter === 'x' ) {
1109
- if ( scatterWon ) {
1110
- lxRight = Math . max ( winningPoint . x0 , winningPoint . x1 ) ;
1111
- lxLeft = Math . min ( winningPoint . x0 , winningPoint . x1 ) ;
1112
+ if ( pointWon ) {
1113
+ lxRight = ( winningPoint . x0 + winningPoint . x1 ) / 2 + HOVERTEXTPAD ;
1114
+ lxLeft = ( winningPoint . x0 + winningPoint . x1 ) / 2 - HOVERTEXTPAD ;
1112
1115
} else {
1113
1116
lxRight = Math . max . apply ( null , hoverData . map ( function ( c ) { return Math . max ( c . x0 , c . x1 ) ; } ) ) ;
1114
1117
lxLeft = Math . min . apply ( null , hoverData . map ( function ( c ) { return Math . min ( c . x0 , c . x1 ) ; } ) ) ;
0 commit comments