Skip to content

feat(tooltip): show a tooltip of the instance under the pointer - #168

Merged
jonmmease merged 5 commits into
mainfrom
claude/hover-tooltips
Oct 24, 2026
Merged

jonmmease merged 5 commits into
mainfrom
claude/hover-tooltips

Conversation

@jonmmease

@jonmmease jonmmease commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Why

A tooltip describes the data under the pointer. With layers, tree queries, and rows on main, a tooltip is a layer over the chart that finds its instance with one tree query and reads the instance's row, and a hover never rebuilds the chart.

What

  • Precision sharing: TickSpacing becomes PrecisionSharing { Shared, PerValue }, named for what it decides: whether a set of formatted numbers shares one precision and unit, or each keeps its own. format_ticks becomes format_all, and scales' tick_spacing becomes tick_precision_sharing.
  • Current trees: BuildContext::tree_is_current(layer) says whether a lower layer's tree shows its newest scene. A scene that rebuilds without its tree, as during a pan, leaves the tree stale until it builds again. A crosshair or a tooltip shows nothing from a stale tree, so it needs no press tracking of its own.
  • Tooltips: the new avenger-tooltip crate provides Tooltips::over(targets), a layer for any app state. It follows the pointer, builds again only when the pointer moves, and draws marks that take no hits.
  • Targets: InstanceTarget::exact() and InstanceTarget::nearest(max_radius) each find their instance with one query or nearest call, among the marks with rows. with_marks, with_metric, with_header, and with_fields refine a target, and targets are tried in order.
  • Fields: TooltipField { column, title, value_format, value_label } reads a row as an axis reads its ticks, through LabelEngine::format_array, which avenger-typst-label's new arrow feature provides and the axes now use too.
  • Placement: TooltipAnchor::Data sets the box beside the instance with a callout, and TooltipAnchor::Pointer sets it beside the pointer. Each changes sides to stay inside the layer. The tooltip outlines its instance inside the instance's clip.
  • geo-pan-zoom: earthquakes take tooltips beside them, and countries take tooltips beside the cursor. Each map's readout moves into a layer of its own, so a hover builds only the readouts and the tooltips. After a zoom, the tree rebuilds once the wheel stops for 100 ms.

Examples

In geo-pan-zoom, an earthquake's tooltip stands beside the earthquake, and a country's tooltip stands beside the cursor. Each tooltip outlines its instance.

Earthquake on the globe Country on the world map
tooltip-earthquake-globe tooltip-country-world

@jonmmease
jonmmease force-pushed the claude/hover-tooltips branch 3 times, most recently from 2f565f9 to e7a9ae1 Compare October 22, 2026 23:20
The option decides whether a set of formatted values shares one
precision and unit or each value keeps its own, and band axes already
use it for categories, which aren't ticks.
`TickSpacing::{Uniform, Varying}` becomes
`PrecisionSharing::{Shared, PerValue}`, the number formatters'
`format_ticks` becomes `format_all`, and scales' `tick_spacing` becomes
`tick_precision_sharing`. The D3 tick fixture and its generator name
their cases the same way.
A layer whose scene rebuilds without its hit-testing tree, as during a
pan, has a stale tree until the tree builds again, and
`BuildContext::tree_is_current` tells the layers above. A layer that
shows what a tree places, such as a crosshair or a tooltip, shows
nothing from a stale tree, and since a drag rebuilds its chart without
the tree, such a layer needs no press tracking of its own.

The iris crosshair snaps only over a current tree and drops its press
tracking, and its chart's tree settles 100 ms after the wheel stops.
@jonmmease
jonmmease force-pushed the claude/hover-tooltips branch 2 times, most recently from a44c209 to e025f60 Compare October 22, 2026 23:37
`avenger-tooltip` provides `Tooltips`, a layer for any app state that
follows the pointer and shows a tooltip of the instance that the first
of its targets finds there, in the current trees below it.
`InstanceTarget::exact` and `nearest` find the instance with one tree
query among the marks with rows, and `TooltipField`s read the
instance's row as an axis reads its ticks, through
`LabelEngine::format_array`. avenger-typst-label's new `arrow` feature
provides it, and the axes use it too. A data-anchored box stands beside
the instance with a callout, and a pointer-anchored box beside the
pointer, and each changes sides to stay inside the layer. The tooltip
outlines its instance, clipped as the instance's mark is.
Each map names its earthquake and country marks apart and shares their
rows, and the countries take hits. The nearest earthquake within 10
pixels takes a tooltip beside it, and otherwise the country under the
cursor takes one beside the cursor. Each map's readout of the place
under the cursor moves into a layer of its own, so a hover builds only
the readouts and the tooltips. After a zoom, the tree rebuilds once the
wheel stops for 100 ms, whatever the cursor does, so no move rebuilds
the maps and drops the next wheel turn.
@jonmmease
jonmmease force-pushed the claude/hover-tooltips branch from e025f60 to 65b18cb Compare October 23, 2026 18:07
@jonmmease
jonmmease marked this pull request as ready for review October 23, 2026 18:11
@jonmmease
jonmmease merged commit 12ff7f9 into main Oct 24, 2026
1 check passed
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