@@ -1199,36 +1199,44 @@ function createHoverText(hoverData, opts, gd) {
1199
1199
var lx , ly ; // top and left positions of the hover box
1200
1200
1201
1201
// horizontal alignment to end up on screen
1202
- if ( lxRight + tWidth < outerWidth && lxRight >= 0 ) {
1203
- lx = lxRight ;
1204
- } else if ( lxLeft + tWidth < outerWidth && lxLeft >= 0 ) {
1205
- lx = lxLeft ;
1206
- } else if ( xOffset + tWidth < outerWidth ) {
1207
- lx = xOffset ; // subplot left corner
1208
- } else {
1209
- // closest left or right side of the paper
1210
- if ( lxRight - avgX < avgX - lxLeft + tWidth ) {
1211
- lx = outerWidth - tWidth ;
1202
+ if ( outerWidth > 0 ) {
1203
+ if ( lxRight + tWidth < outerWidth && lxRight >= 0 ) {
1204
+ lx = lxRight ;
1205
+ } else if ( lxLeft + tWidth < outerWidth && lxLeft >= 0 ) {
1206
+ lx = lxLeft ;
1207
+ } else if ( outerWidth > 0 && xOffset + tWidth < outerWidth ) {
1208
+ lx = xOffset ; // subplot left corner
1212
1209
} else {
1213
- lx = 0 ;
1210
+ // closest left or right side of the paper
1211
+ if ( lxRight - avgX < avgX - lxLeft + tWidth ) {
1212
+ lx = outerWidth - tWidth ;
1213
+ } else {
1214
+ lx = 0 ;
1215
+ }
1214
1216
}
1217
+ } else {
1218
+ lx = lxLeft ;
1215
1219
}
1216
1220
lx += HOVERTEXTPAD ;
1217
1221
1218
1222
// vertical alignement to end up on screen
1219
- if ( lyBottom + tHeight < outerHeight && lyBottom >= 0 ) {
1220
- ly = lyBottom ;
1221
- } else if ( lyTop + tHeight < outerHeight && lyTop >= 0 ) {
1222
- ly = lyTop ;
1223
- } else if ( yOffset + tHeight < outerHeight ) {
1224
- ly = yOffset ; // subplot top corner
1225
- } else {
1226
- // closest top or bottom side of the paper
1227
- if ( lyBottom - avgY < avgY - lyTop + tHeight ) {
1228
- ly = outerHeight - tHeight ;
1223
+ if ( outerHeight > 0 ) {
1224
+ if ( lyBottom + tHeight < outerHeight && lyBottom >= 0 ) {
1225
+ ly = lyBottom ;
1226
+ } else if ( lyTop + tHeight < outerHeight && lyTop >= 0 ) {
1227
+ ly = lyTop ;
1228
+ } else if ( yOffset + tHeight < outerHeight ) {
1229
+ ly = yOffset ; // subplot top corner
1229
1230
} else {
1230
- ly = 0 ;
1231
+ // closest top or bottom side of the paper
1232
+ if ( lyBottom - avgY < avgY - lyTop + tHeight ) {
1233
+ ly = outerHeight - tHeight ;
1234
+ } else {
1235
+ ly = 0 ;
1236
+ }
1231
1237
}
1238
+ } else { // N.B. this case happens on documentation website (outerHeight: 0)
1239
+ ly = lyTop ;
1232
1240
}
1233
1241
ly += HOVERTEXTPAD ;
1234
1242
0 commit comments