Skip to content

Fix multiline tooltip clipping - #913

Open
jacobvjk wants to merge 3 commits into
mainfrom
fix-multiline-tooltip-clipping
Open

Fix multiline tooltip clipping#913
jacobvjk wants to merge 3 commits into
mainfrom
fix-multiline-tooltip-clipping

Conversation

@jacobvjk

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed tooltip clipping in MultiLineChart: the hover tooltip now repositions near the plot's edges instead of overflowing past them. It slides horizontally to stay within the left/right margins, and flips above the point when there is not enough space below. This mirrors the fix already shipped for NormalizedStackedAreaChart in Feat tooltip stacked area chart #909.
  • Tail always points at the exact hovered data point, even when the box has shifted or flipped to fit.
  • Extracted the positioning math into a pure, reusable function (chartTooltipLayout.ts) to make it testable without an SVG layout engine.
  • Added unit tests (chartTooltipLayout.test.ts) covering the following cases:
    • default/centered case
    • left/right edge sliding
    • bottom-edge flip
    • a corner case (both axes at once)
    • and two fallback edge cases.

Related issues

Closes: #910

Testing

  • added new unit tests making use of the repositioning math to ensure the tooltip stays within bounds in all relevant cases
  • manually validated the functionality

Checklist

  • PR is focused on a single concern
  • Tests pass locally and in CI
  • Docs updated for user-visible changes
  • AI-assisted portions declared (see CONTRIBUTING.md)

@jacobvjk
jacobvjk requested review from AlexAxthelm and a lite review from Copilot August 19, 2026 12:05
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

Expected version change and release notes:

1.16.0-dev.16 (v1.16.0-dev.15...fix-multiline-tooltip-clipping ) (2026-08-19T12:35 UTC)

Fixes

  • no more clipping of tooltip (3dc8b64)

@github-actions

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-913.westus2.2.azurestaticapps.net

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses tooltip clipping in MultiLineChart by introducing reusable, unit-testable tooltip positioning geometry and applying it to the chart’s per-point hover tooltip so it stays within plot bounds while keeping the tail anchored to the hovered point.

Changes:

  • Added a pure computeTooltipBoxLayout utility to compute clamped/flip tooltip box geometry within plot bounds.
  • Updated MultiLineChart to use the new layout function for tooltip path/text positioning (including edge sliding and vertical flipping).
  • Added Vitest unit tests covering centered, edge, flip, corner, and fallback behaviors for the layout utility.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/utils/chartTooltipLayout.ts New pure geometry helper for computing tooltip box/tail layout within plot bounds
src/utils/chartTooltipLayout.test.ts Unit tests for tooltip layout behavior across edge and fallback cases
src/components/MultiLineChart.tsx Integrates computed tooltip layout to prevent clipping and keep tail anchored to the hovered point

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils/chartTooltipLayout.ts Outdated
point/bounds are absolute plot-pixel coordinates; only the returned
layout is local to the anchor point. The previous header comment
claimed all coordinates were anchor-local, which contradicted
TooltipPlotBounds's own doc and could mislead callers.

Addresses Copilot review comment on PR #913.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 19, 2026 12:34
@github-actions

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-913.westus2.2.azurestaticapps.net

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plots: ensure hover tooltips do not clip near the plot boundaries

2 participants