|
|
@@ -284,13 +284,16 @@ const Elevation = (() => {
|
|
|
const th = tooltip.offsetHeight;
|
|
|
const gap = 8;
|
|
|
|
|
|
- // Prefer above cursor; fall back to below if not enough room
|
|
|
- const topAbove = cy - th - gap;
|
|
|
- const top = topAbove >= 0 ? topAbove : cy + gap;
|
|
|
-
|
|
|
- // Prefer right of indicator; clamp to canvas bounds
|
|
|
- const leftRight = cx + gap;
|
|
|
- const left = Math.min(leftRight, cRect.width - tw - 4);
|
|
|
+ // Decide above/below using viewport coordinates so the tooltip can
|
|
|
+ // float above the chart container when needed (container has no
|
|
|
+ // overflow:hidden, so negative top values are fine).
|
|
|
+ const cursorViewportY = cRect.top + cy;
|
|
|
+ const fitsAbove = cursorViewportY - th - gap >= 0;
|
|
|
+ // top is relative to the container (may be negative = above the panel)
|
|
|
+ const top = fitsAbove ? cy - th - gap : cy + gap;
|
|
|
+
|
|
|
+ // Prefer right of the indicator line; clamp within canvas width
|
|
|
+ const left = Math.min(cx + gap, cRect.width - tw - 4);
|
|
|
|
|
|
tooltip.style.left = Math.max(0, left) + 'px';
|
|
|
tooltip.style.top = top + 'px';
|