Skip to content

plot: Fix and polish chart hover tooltips#2507

Merged
madcodelife merged 4 commits into
mainfrom
fix-plot-tooltip-top-inset
Jun 24, 2026
Merged

plot: Fix and polish chart hover tooltips#2507
madcodelife merged 4 commits into
mainfrom
fix-plot-tooltip-top-inset

Conversation

@madcodelife

@madcodelife madcodelife commented Jun 24, 2026

Copy link
Copy Markdown
Member

Description

Follow-up fixes and polish for the interactive chart hover tooltips added in #2500.

  • Tooltip vertical stretch — a stray top_0() on the tooltip base stretched the box vertically; removed it.
  • Tooltip clipped under later siblings — the overlay was painted inline during the plot's paint, so siblings drawn afterwards (e.g. a chart card footer) covered the part of the box overflowing the plot bounds. It's now wrapped in gpui::deferred(...) so it paints on top; prepaint_as_root keeps the plot-origin offset, so positioning is unchanged.
  • Downstream clippy lint — the IntoPlot derive emitted let...else, which tripped clippy::question_mark in crates that derive it. It now emits ? so generated code is lint-clean.
  • CrossLine::both() crosshair — both axes shared a single span, so confining the crosshair with height()/span() clipped the horizontal line to the vertical extent. Each axis now confines independently.

Breaking Changes

  • CrossLine::height() / span() now confine only the vertical line. Use the new width() / h_span() to confine the horizontal line.
- CrossLine::new(point).horizontal().height(120.)
+ CrossLine::new(point).horizontal().width(120.)

madcodelife and others added 4 commits June 24, 2026 11:53
The `IntoPlot` derive painted the tooltip overlay inline during the plot's own
`paint`, so any sibling drawn after the plot (e.g. a chart card's footer text)
covered the part of the tooltip box that overflows the plot bounds. Wrap the
overlay in `gpui::deferred(...)` before `prepaint_as_root` so it paints in the
deferred pass, on top of the rest of the tree. `prepaint_as_root` keeps the
plot-origin offset, so positioning is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The derive generated `let Some(_) = ... else { return None }`, which trips
`clippy::question_mark` in downstream crates that derive `IntoPlot` (the
generated code is attributed to the call site via `quote!`). Emit `?` instead
so the generated code is lint-clean regardless of clippy version.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`CrossLine` shared a single `start`/`length` across both axes, so a `both()`
crosshair confined with `height()`/`span()` wrongly clipped the horizontal line
to the vertical extent. Give each axis its own span and add `width()`/`h_span()`
so the vertical and horizontal lines confine independently.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@madcodelife madcodelife force-pushed the fix-plot-tooltip-top-inset branch from de2fb5c to 2147d5d Compare June 24, 2026 09:35
@madcodelife madcodelife changed the title plot: Fix tooltip stretched vertically by stray top_0() on base plot: Fix and polish chart hover tooltips Jun 24, 2026
@madcodelife madcodelife merged commit a0ae3a3 into main Jun 24, 2026
3 checks passed
@madcodelife madcodelife deleted the fix-plot-tooltip-top-inset branch June 24, 2026 10:05
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.

1 participant