Skip to content

Commit 1c7a69d

Browse files
committed
adjustment also for winning types e.g. heatmap use scatter logic
1 parent 9217db4 commit 1c7a69d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/components/fx/hover.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -1088,14 +1088,17 @@ function createHoverText(hoverData, opts, gd) {
10881088
var tWidth = tbb.width + 2 * HOVERTEXTPAD;
10891089
var tHeight = tbb.height + 2 * HOVERTEXTPAD;
10901090
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+
);
10931096

10941097
var lyBottom, lyTop;
10951098
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;
10991102
} else {
11001103
lyTop = Math.min.apply(null, hoverData.map(function(c) { return Math.min(c.y0, c.y1); }));
11011104
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) {
11061109

11071110
var lxRight, lxLeft;
11081111
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;
11121115
} else {
11131116
lxRight = Math.max.apply(null, hoverData.map(function(c) { return Math.max(c.x0, c.x1); }));
11141117
lxLeft = Math.min.apply(null, hoverData.map(function(c) { return Math.min(c.x0, c.x1); }));

0 commit comments

Comments
 (0)