Repository navigation
feat(tooltip): show a tooltip of the instance under the pointer - #168
Merged
Merged
Conversation
jonmmease
force-pushed
the
claude/hover-tooltips
branch
3 times, most recently
from
October 22, 2026 23:20
2f565f9 to
e7a9ae1
Compare
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
force-pushed
the
claude/hover-tooltips
branch
2 times, most recently
from
October 22, 2026 23:37
a44c209 to
e025f60
Compare
`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
force-pushed
the
claude/hover-tooltips
branch
from
October 23, 2026 18:07
e025f60 to
65b18cb
Compare
jonmmease
marked this pull request as ready for review
October 23, 2026 18:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
TickSpacingbecomesPrecisionSharing { Shared, PerValue }, named for what it decides: whether a set of formatted numbers shares one precision and unit, or each keeps its own.format_ticksbecomesformat_all, and scales'tick_spacingbecomestick_precision_sharing.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.avenger-tooltipcrate providesTooltips::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.InstanceTarget::exact()andInstanceTarget::nearest(max_radius)each find their instance with onequeryornearestcall, among the marks with rows.with_marks,with_metric,with_header, andwith_fieldsrefine a target, and targets are tried in order.TooltipField { column, title, value_format, value_label }reads a row as an axis reads its ticks, throughLabelEngine::format_array, which avenger-typst-label's newarrowfeature provides and the axes now use too.TooltipAnchor::Datasets the box beside the instance with a callout, andTooltipAnchor::Pointersets it beside the pointer. Each changes sides to stay inside the layer. The tooltip outlines its instance inside the instance's clip.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.