madhushreeag commented on code in PR #41174:
URL: https://github.com/apache/superset/pull/41174#discussion_r3483397571


##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/tooltip.ts:
##########
@@ -107,18 +111,39 @@ export function getDefaultTooltip(refs: Refs) {
         }
       }
 
-      // Position tooltip above cursor, or below if no space
-      yPos = mouseY - TOOLTIP_POINTER_MARGIN - effectiveTooltipHeight;
+      // Mirror horizontal logic: position tooltip below cursor when in top 
half of chart,
+      // above cursor when in bottom half. This prevents the tooltip from 
covering annotation
+      // labels that appear at the top of the chart (markArea/markLine labels).
+      const chartHeight = divRect?.height || viewportHeight;
+      const cursorYInChart = canvasMousePos[1];
+      const isInTopHalfOfChart = cursorYInChart < chartHeight / 2;
 
-      // The tooltip is overflowing past the top edge of the window
-      if (yPos <= 0) {
-        // Attempt to place the tooltip to the bottom of the mouse position
+      if (isInTopHalfOfChart) {
         yPos = mouseY + TOOLTIP_POINTER_MARGIN;
 
-        // The tooltip is overflowing past the bottom edge of the window
-        if (yPos + effectiveTooltipHeight >= viewportHeight)
-          // Place the tooltip a fixed distance from the top edge of the window
-          yPos = TOOLTIP_OVERFLOW_MARGIN;
+        if (yPos + effectiveTooltipHeight >= viewportHeight) {
+          yPos = mouseY - TOOLTIP_POINTER_MARGIN - effectiveTooltipHeight;
+
+          if (yPos <= 0) {
+            yPos = TOOLTIP_OVERFLOW_MARGIN;
+          }
+        }
+      } else {
+        yPos = mouseY - TOOLTIP_POINTER_MARGIN - effectiveTooltipHeight;
+
+        if (yPos <= 0) {
+          yPos = mouseY + TOOLTIP_POINTER_MARGIN;
+
+          if (yPos + effectiveTooltipHeight >= viewportHeight) {
+            yPos = TOOLTIP_OVERFLOW_MARGIN;
+          }
+        }
+      }
+
+      // Clamp tooltip away from the top of the chart to avoid covering 
annotation labels
+      // (markLine/markArea labels rendered at insideEndTop are within the 
first ~40px)
+      if (divRect) {
+        yPos = Math.max(yPos, divRect.y + TOOLTIP_TOP_CLEARANCE);

Review Comment:
   Fixed this -  Re-applied viewport bottom clamp after tooltip top-clearance 
so the tooltip stays on screen when the chart is near the bottom of the page.



##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts:
##########
@@ -472,6 +472,7 @@ export function transformFormulaAnnotation(
   return {
     name,
     id: name,
+    z: 10,

Review Comment:
   Marked interval/event annotation overlays as silent so they don't intercept 
data-point hover and cross-filter events at high z-index.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to