Skip to content

Commit b44e11d

Browse files
committed
pick winning and median positions for unified hover depending on axis
1 parent 53a67bc commit b44e11d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/fx/hover.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,11 @@ function createHoverText(hoverData, opts, gd) {
10721072

10731073
// Position the hover
10741074
var winningPoint = hoverData[0];
1075-
var ly = (winningPoint.y0 + winningPoint.y1) / 2;
1076-
var lx = (winningPoint.x0 + winningPoint.x1) / 2;
1075+
var ly = axLetter === 'y' ?
1076+
(winningPoint.y0 + winningPoint.y1) / 2 : Lib.mean(hoverData.map(function(c) {return (c.y0 + c.y1) / 2;}));
1077+
var lx = axLetter === 'x' ?
1078+
(winningPoint.x0 + winningPoint.x1) / 2 : Lib.mean(hoverData.map(function(c) {return (c.x0 + c.x1) / 2;}));
1079+
10771080
var legendContainer = container.select('g.legend');
10781081
var tbb = legendContainer.node().getBoundingClientRect();
10791082
lx += xa._offset;

0 commit comments

Comments
 (0)