Skip to content

Commit 3658c48

Browse files
Othmane BentalebOBe95
Othmane Bentaleb
authored andcommitted
fix: tooltip pointer position in hovermode x
1 parent a04e81d commit 3658c48

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

src/components/fx/hover.js

+13-25
Original file line numberDiff line numberDiff line change
@@ -999,35 +999,23 @@ function createHoverText(hoverData, opts) {
999999

10001000
var halfWidth = tbb.width / 2 + HOVERTEXTPAD;
10011001

1002+
var tooltipMidX = lx;
10021003
if(lx < halfWidth) {
1003-
lx = halfWidth;
1004-
1005-
lpath.attr('d', 'M-' + (halfWidth - HOVERARROWSIZE) + ',0' +
1006-
'L-' + (halfWidth - HOVERARROWSIZE * 2) + ',' + topsign + HOVERARROWSIZE +
1007-
'H' + (halfWidth) +
1008-
'v' + topsign + (HOVERTEXTPAD * 2 + tbb.height) +
1009-
'H-' + halfWidth +
1010-
'V' + topsign + HOVERARROWSIZE +
1011-
'Z');
1004+
tooltipMidX = halfWidth;
10121005
} else if(lx > (fullLayout.width - halfWidth)) {
1013-
lx = fullLayout.width - halfWidth;
1014-
1015-
lpath.attr('d', 'M' + (halfWidth - HOVERARROWSIZE) + ',0' +
1016-
'L' + halfWidth + ',' + topsign + HOVERARROWSIZE +
1017-
'v' + topsign + (HOVERTEXTPAD * 2 + tbb.height) +
1018-
'H-' + halfWidth +
1019-
'V' + topsign + HOVERARROWSIZE +
1020-
'H' + (halfWidth - HOVERARROWSIZE * 2) + 'Z');
1021-
} else {
1022-
lpath.attr('d', 'M0,0' +
1023-
'L' + HOVERARROWSIZE + ',' + topsign + HOVERARROWSIZE +
1024-
'H' + (halfWidth) +
1025-
'v' + topsign + (HOVERTEXTPAD * 2 + tbb.height) +
1026-
'H-' + (halfWidth) +
1027-
'V' + topsign + HOVERARROWSIZE +
1028-
'H-' + HOVERARROWSIZE + 'Z');
1006+
tooltipMidX = fullLayout.width - halfWidth;
10291007
}
10301008

1009+
lpath.attr('d', 'M' + (lx - tooltipMidX) + ',0' +
1010+
'L' + (lx - tooltipMidX + HOVERARROWSIZE) + ',' + topsign + HOVERARROWSIZE +
1011+
'H' + (halfWidth) +
1012+
'v' + topsign + (HOVERTEXTPAD * 2 + tbb.height) +
1013+
'H-' + halfWidth +
1014+
'V' + topsign + HOVERARROWSIZE +
1015+
'H' + (lx - tooltipMidX - HOVERARROWSIZE) +
1016+
'Z');
1017+
1018+
lx = tooltipMidX;
10311019
commonLabelRect.minX = lx - halfWidth;
10321020
commonLabelRect.maxX = lx + halfWidth;
10331021
if(xa.side === 'top') {

0 commit comments

Comments
 (0)