Repository navigation
spec(ChartTooltip): a dot-only chart's tooltip describes the dot nearest the pointer - #14193
marie-lucas wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
62fddae to
661dde2
Compare
661dde2 to
2261513
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the new point-mode record, and the record needs four fixes either way.
What must be settled: dot-only charts default to describing the one dot nearest the pointer within its radius + 8 px, ChartTooltip becomes the only card renderer, and dotGLInteractive drops renderTooltip (FR1-FR10, PR1-PR3, AR1, DEC-1 to DEC-6), and whether FR4's default-text WebGL rows stand under spec:AST-115 DEC-7 as written or DEC-7 is amended here. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner.
Blocking findings:
- FR9, FR10 and PR1 prescribe a package-private geometry registry and an index with its lifecycle, which
architecture:knowledge-contractsINV18 keeps out of module records, so keep the observable outcomes in the module and move the mechanism to an architecture record or drop it. - FR1 requires point mode on every dot-only chart while AR1 keeps today's touch behavior, so a touch drag on a scatter must both pick one dot without a crosshair and show the x-group card; state the input condition in FR1 and define a hover-capable pen.
dotGLanddotGLInteractivepaint a missing y as a dot at y = 0, visible whenever 0 is inside the y domain, which FR3 makes unpickable although DEC-6 says a visible dot can be picked, so either require those marks to skip such values asdotdoes, or narrow DEC-6 and FR3.- The FR8 gap line says
dotGLInteractivedraws its own card and halo, but from reading the code Chart's pointer layer covers the mark's hit target, so neither appears in a browser; reword it to the hit target andrenderTooltip.
One smaller point: review_triggers lists performance, which the routing tools do not support, and react-runtime is the trigger that routes the INV18 claim the record cites.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Today the tooltip shows the data row nearest the pointer in x on every chart: verified (
Chart.tsx:382-393,ChartTooltip.tsx:297). - On a scatter the card can describe a dot other than the one under the pointer: verified (the distance is x-only across all points).
- The WebGL interactive scatter has its own card, halo and hit target: verified in code (
dotGLInteractive.tsx:546-604). Traced in the code, the card and halo never show in a browser (Chart.tsx:557-578). - No current record decides which point the tooltip describes, who renders the card, or how the point is picked: verified. A search of current records for the tooltip, the interactive mark, its render option and scatter terms found three that mention them, and none decides.
- The parent tooltip and chart records are drafts holding the cited pick, indicator, placement and dispatch clauses: verified.
- The value-format, layering, swizzle and API records say what the description cites: verified.
- The six named source files and the render option exist: verified.
- The public chart context carries neither the series nor the pointer type: verified (
types.ts:192-219). - #13150 gives the interactive mark a working card, and #14151 and #14152 add a utility-marks record: verified from their files.
- #10040 and #10041 touch
Chart.tsxbut not tooltip selection: verified from their patches. - The utility-mark constant lists reference line, error bar and band: verified (
types.ts:226-230). - The WebGL scatter canvas sits above the SVG and is appended in mount order, while SVG dots and the interactive mark draw inside the SVG: verified (
webgl.ts:150-195,dot.tsx:104-127,dotGLInteractive.tsx:526-535). - Chart's nearest point is x-only and public, a resolved point has no radius or paint surface, and the row helper has no geometry: verified.
- Removing the render option is a disclosed break on the canary package: verified (the package is private and outside the compatibility promise).
- The pull request holds specification records only and no implementation: verified (two Markdown files).
- The record keeps equivalent internal implementations open and names its seam only as package-private: false (first blocking finding).
- Writing rubric results R1-R7: verified, except the FR8 gap line under R7, which is false (fourth blocking finding).
- Overlapping open work is named and the collision called out: verified (#13150 is named as replaced).
- Public text has no internal context: verified.
- Knowledge validation is aligned, Prettier is clean, and the whitespace check is clean: verified, each run here.
- Spec routing of both records: reported.
- The pre-review run's 280 authored lines and 0 findings: reported. This head has 275 authored lines.
- Real-Chrome probe agreement rates: reported.
docs/specs/components/ChartTooltip/modules/pointMode.spec.md: four blocking findings and the trigger note.docs/specs/components/ChartTooltip/ChartTooltip.spec.md: the backlink is clear. Its x-group lines are not scoped to x-group mode (non-blocking).
| | FR6 | In point mode, a miss, leaving the plot, a pick that a data or layout change leaves no longer eligible (FR3) or no longer present, and a custom `render` that returns `null` MUST keep the card closed or close an open card, and a later valid pick MUST be able to open it again, as `component:ChartTooltip` FR2 requires in x-group mode. `ChartTooltip` MUST draw at most one highlight, at the picked point, and no crosshair or band highlight; `showHoverDots` turns the highlight off, and `hoverIndicator` draws nothing. The highlight follows the pick when a custom `render` returns `null`, as in x-group mode. The highlight never intercepts the pointer. | DEC-1 | human decision | | ||
| | FR7 | In point mode, the card MUST take `ChartTooltip`'s side semantics (parent FR5) relative to the picked point instead of the plot top: `auto` starts to the right and flips left on inline overflow; `left`, `right` and `top` take that side. Beside the point, the card is vertically centered on it. When the card fits on its side, it keeps an 8px gap beyond the point's highlight, or beyond its painted radius when the highlight is off, and stays inside the viewport. When it does not fit, it is clamped toward the viewport and may cover the point. Custom-rendered content keeps its caller-owned size. | DEC-1 | human decision | | ||
| | FR8 | For the built-in chart marks, `ChartTooltip` MUST be the only renderer of a tooltip card or hover highlight. The built-in dot-family marks draw no card, halo or hit target of their own, and `dotGLInteractive` does not accept `renderTooltip`. A chart with neither `tooltip` nor a composed `ChartTooltip` shows no card. | DEC-1, DEC-4 | human decision | | ||
| | FR9 | Each built-in dot-family factory MUST register a capability for the exact series definition it returns, in a registry shared across copies of the package under a versioned key, that describes the series' dot geometry: painted centers from layout, painted radii and its paint surface. The capability MUST NOT appear as a public field, a `type` check, or a global picker. Where a mark holds live resources that serve the pick, it registers them at commit and releases them on unmount and rebuild; an absent or stale resource falls back to FR10's query, never to a different pick. | DEC-1 | human decision | |
There was a problem hiding this comment.
FR9 (with FR10 and PR1) prescribes a package-private registry, its registration timing and an index. architecture:knowledge-contracts INV18 says a requirement must not prescribe internal modules, algorithms or data structures unless the mechanism is an intentional public contract, and that internal seams belong in an architecture record. Keep the observable outcomes here: the pick equals FR2's, a copied factory and the package agree (spec:AST-110 FR3), and a type-only series is not dot-family. Move the registry, index and accelerator rule to an architecture record, or drop them.
|
|
||
| ## Accessibility contract | ||
|
|
||
| - **AR1 — Supplemental pointer detail.** Point mode is pointer-only detail for |
There was a problem hiding this comment.
AR1 keeps the existing touch behavior, but FR1 has no input condition and FR6 removes the crosshair. A touch drag on a dot-only chart would then have to be both point mode and today's x-group card. State the input condition in FR1, for example "for mouse and for pen input on a device that reports hover; touch keeps x-group selection", and define a hover-capable pen.
| | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------ | | ||
| | FR1 | `ChartTooltip` MUST use point mode when the chart has at least one primary series and every primary series is a dot-family series, and x-group mode otherwise: when any primary series is another mark, an unknown or custom series definition, `heatmapGL` or `streamGL`, or when there is no primary series. Utility annotations do not change the mode and are never pick candidates; they are `referenceLine`, `errorBar` and `band`, and a utility annotation added later states that it is one. The mode reads the chart's own series, not the `series` passed to a composed `ChartTooltip`. No prop selects the mode. | DEC-3 | human decision | | ||
| | FR2 | In point mode, the picked point MUST be the eligible dot (FR3) whose painted center is nearest the pointer by Euclidean distance in plot CSS pixels, among dots whose reach, painted radius + 8 CSS px, contains the pointer. At equal distance, the dot actually drawn on top wins: in one series, the later datum, and a dot on the chart's WebGL overlay (`dotGL`) over a dot drawn in the chart's SVG (`dot`, `dotGLInteractive`). Between series on one paint surface, the tie follows their actual stacking, which need not follow series order. When no eligible dot's reach contains the pointer, nothing is picked. A picked point is identified by its series identity and datum index, never by the datum index alone. | DEC-3 | human decision | | ||
| | FR3 | A dot MUST be eligible exactly when all of these hold: its x maps to a finite position on the x scale (a number on a continuous scale, a category on a band scale); its raw y is a finite number; its projected center is finite; its painted radius is greater than 0; and its painted disc intersects the plot clip, so a partly visible dot is eligible and a wholly clipped one is not. Eligibility does not change how a mark paints and never reads a missing value as 0. | DEC-6 | human decision | |
There was a problem hiding this comment.
dotGL and dotGLInteractive paint a missing or non-number y as a dot at y = 0 (marks/dotGL.tsx:259, marks/dotGLInteractive.tsx:649), which is visible whenever 0 is inside the y domain. This clause makes that dot unpickable while saying eligibility never changes paint, and DEC-6 says a dot the reader can see can be picked. Either require dot-family marks to skip such values, as dot does, or narrow DEC-6 and this clause to that case.
| | Behavior | On a chart whose primary series are all dot-family marks, `ChartTooltip` describes the one eligible dot nearest the pointer in x and y, within that dot's reach (painted radius + 8 CSS px); a tie goes to the dot drawn on top, and the card closes beyond reach. Every other chart keeps x-group selection. For built-in marks, only `ChartTooltip` draws a card. | | ||
| | End-user impact | People who hover a scatter see the dot under the pointer, not every row at that x, with the same card chrome and default-body treatment as other charts. A scatter with neither `tooltip` nor a composed `ChartTooltip` shows no card. | | ||
| | Builder impact | A `dotGLInteractive` `renderTooltip` moves to `tooltip={{render: (x, rows) => …}}`, which receives the raw x value and the picked point's row, not the whole datum or its index. | | ||
| | Compatibility/readiness | A disclosed break of `dotGLInteractive`'s `renderTooltip` on the canary package (DEC-4); a changed default for dot-only charts with a tooltip (DEC-3). FR1 and FR2 gap: on dot-only charts, `ChartTooltip` selects the row nearest the pointer in x. FR8 gap: `dotGLInteractive` draws its own card, halo and hit target. | |
There was a problem hiding this comment.
The FR8 gap line overstates today's behavior. Chart paints its pointer layer over the marks (Chart.tsx:557-578), so dotGLInteractive's hit rect never gets the pointer and its card and halo never appear in a browser. Suggested: "FR8 gap: dotGLInteractive renders its own hit target and accepts renderTooltip."
| approved_by: null | ||
| approved_at: null | ||
| owners: [marie-lucas, cixzhang] | ||
| review_triggers: [public-api, behavior, interaction, layout, performance] |
There was a problem hiding this comment.
Non-blocking: performance is not a supported review trigger. pnpm specs:for drops it silently, and the routing helper rejects it. react-runtime routes the architecture:react-component-runtime INV18 claim this record cites.
2261513 to
e12559b
Compare
…est the pointer Adds module:ChartTooltip/pointMode. For mouse moves and pen moves without contact on a chart whose primary series are all dot-family marks, ChartTooltip picks the one eligible dot nearest the pointer in x and y, within the dot's painted radius + 8 CSS px; a tie goes to the dot actually drawn on top, and the card closes beyond reach. Touch, pen in contact and every other chart keep x-group selection, and utility annotations do not change the mode. For built-in marks, ChartTooltip is the only card renderer: dot marks draw no card, halo or hit target, and dotGLInteractive takes no renderTooltip. The pick equals the exact nearest-dot result whatever accelerates it, behaves the same across package copies, and costs no work on charts without a point-mode tooltip. The move-to-paint p95 stays under 16 ms at 10,000 dots under a throttled phone emulation profile. Adds architecture:chart-point-pick for the internal seam that serves the pick: the geometry capability, Chart's private plumbing, the demand-driven index, commit-scoped resources and the accelerator rule. component:ChartTooltip lists the module and changes nothing else.
e12559b to
2047c5c
Compare
Exact decision needed
Which point a chart tooltip describes on a scatter, who renders it, and how the point is picked.
ChartTooltipselects the data row nearest the pointer in x on every chart, so on a scatter the card can describe a dot other than the one under the pointer.dotGLInteractivealso has a card, halo and hit target of its own.This PR adds
module:ChartTooltip/pointMode, which decides the observable behavior for the dot slice, andarchitecture:chart-point-pick, which owns the internal seam and mechanism that serve it (architecture:knowledge-contractsINV18 keeps mechanism out of module records).Existing authority searched
component:ChartTooltip(draft): FR2 (nearest x selects one data index; closure on leave, stale index and customnull), FR4 (indicator) and FR5 (placement sides). These describe the shipped x-group behavior and settle nothing. Point mode restates closure and side semantics for the picked point (FR6, FR7).component:Chart(draft): pointer dispatch and the publicnearestevent. Point mode leaves both unchanged.spec:AST-115(current): row value text. FR14 keeps series without a value key out of rows; DEC-7 keeps value formats off WebGL marks. Neither decides which point a tooltip describes, and this PR leaves AST-115 unchanged.spec:AST-027(current) FR7–FR8: the card is a Layer in the top layer. That is the card host, not the pick.spec:AST-110(current) FR3: state shared between components lives under a versioned key, so package and copied components interoperate. The seam follows it.architecture:public-component-api(current) INV3: a new behavior prop must default to the shipped behavior. This decision adds no prop.ChartTooltip.tsx,Chart.tsx,tooltip.ts,marks/dot.tsx,marks/dotGL.tsx,marks/dotGLInteractive.tsx;ChartTooltipanddotGLInteractive'srenderTooltip.Chart.tsxis in the record's path list because the publicChartContextexposes neither the chart's own series nor the pointer type, so the private plumbing that point mode needs lives there. The publiconPointerstays unchanged.dotGLInteractivea working card of its own. This decision replaces that mark-local card. fix(charts): the WebGL interactive scatter's hover card opens in browsers #13150 stays open, unmerged, until the implementation of this record lands.module:Chart/utilityMarks. This record has no dependency on them. FR1 says utility annotations do not change the mode, names today's three (referenceLine,errorBar,band; theUTILITY_MARK_TYPESconstant is the evidence for that list, not its authority), and requires a later annotation to state that it is one.Chart.tsxbut not tooltip selection.Decision
module:ChartTooltip/pointMode(behavior) andarchitecture:chart-point-pick(mechanism).component:ChartTooltiponly gains themodules:backlink.Mode (FR1): for mouse moves and pen moves without contact (hover), point mode applies when the chart has at least one primary series and every primary series is a built-in dot-family series (
dot,dotGL,dotGLInteractive).heatmapGL,streamGL, or no primary series.Pick (FR2): the eligible dot whose painted center is nearest the pointer in plot CSS pixels, among dots whose reach (painted radius + 8 CSS px) contains the pointer. Nothing is picked beyond every reach. A pick is identified by series and datum index.
dotGLdot (drawn on the WebGL overlay above the chart's SVG) over adotordotGLInteractivedot (drawn inside the SVG). Between series on one surface, the tie follows their actual stacking.dotGLcanvases are appended in mount order, so reordering the series need not reorder them.Eligibility (FR3): one rule. A dot is eligible exactly when:
In particular,
dotGLanddotGLInteractivepaint a missing or non-numeric y as a dot at y = 0, and that dot is not eligible. Eligibility never changes paint and never reads a missing value as 0.Content (FR4): the x text, then one row for the picked point, with x-group's value context (
formatXValue; series value text under AST-115, so WebGL rows read the default text).render(xValue, rows)receives the raw x value and that one row with its raw value.Composition (FR5): if a composed
ChartTooltip'sseriesomit the picked series, there is no card and no highlight, and no other dot is picked in its place.Closure and highlight (FR6):
nullkeeps the card closed, and a later valid pick reopens it, as in x-group mode.showHoverDotsturns it off, and the highlight still follows the pick under a customnull, as in x-group mode.Placement (FR7):
ChartTooltip's side semantics, relative to the picked point instead of the plot top.autostarts right and flips left on inline overflow;left,rightandtoptake that side. Beside the point, the card is vertically centered.Single renderer (FR8): for built-in marks,
ChartTooltipis the only card and highlight renderer. Dot marks draw no card, halo or hit target, anddotGLInteractivetakes norenderTooltip. A chart with neithertooltipnor a composedChartTooltipshows no card. Custom series and caller-added interactions are outside this rule.Copies and resources (FR9): the pick is the same when
ChartTooltip, Chart and the dot factories come from different copies of the package on one protocol version, in either combination. A definition that no built-in dot factory produced is never dot-family, whatever itstype. An optional resource that only serves the pick, such as a GPU pick buffer, never changes the pick when it is absent, stale or lost. No public field, prop or global exposes dot geometry.Exactness (FR10): for every pointer position, the pick equals FR2's nearest eligible dot computed from geometry, whatever accelerates it. A GPU readback alone never decides it.
Performance:
Accessibility (AR1): supplemental pointer-only detail for mouse and hover-capable pen. Existing touch behavior is kept, and existing accessible surfaces are not replaced. Keyboard and assistive-technology access to individual points stays uncontracted.
DEC-1 to DEC-6 record the engineering owner's six decisions: single renderer, exact CPU query, dot-only default with reach and ties,
renderTooltipretired, the performance gate, edges and composition.The mechanism:
architecture:chart-point-pick(DEC-22)The new draft architecture record owns the internal seam (INV18):
spec:AST-110FR3). It is never a public field, atypecheck or a global picker.ChartTooltipprivately. The publicChartContext,nearestandonPointerkeep their shape.ChartTooltipis mounted, rebuilt on layout or data change, released on unmount.Illustrative usage. The names are not part of either record.
Why existing pieces are not enough:
typeis a public string that any custom series can set. It cannot prove that a series paints dots or what radius it paints.nearestis the point nearest in x alone. It is public, and changing it would change everyonPointerconsumer.ResolvedPointcarries a center but no painted radius and no paint surface, so FR2's reach and tie rules cannot be computed from it.tooltip.tsderives rows and has no geometry.ChartContextis public, and adding the seam to it would make the seam public.Refinements within the six decisions, in the final text for approval
architecture:chart-point-pick: the module states the observable guarantees, and the architecture record owns the seam. The seam supplies dot geometry, andChartTooltipowns the pick.Compatibility
dotGLInteractive'srenderTooltipis a disclosed break on the canary package. Custom content moves totooltip={{render: (x, rows) => …}}, which receives the raw x value and the picked row, not the whole datum or its index.Authority
Both records stay
draftwith empty approval fields in this PR. After the engineering owner approves the exact text:module:ChartTooltip/pointModeandarchitecture:chart-point-pickbecomecurrent;component:ChartTooltipstays draft;Rejected alternatives
ChartTooltipsuppresses: two card renderers with two pick rules, and an arbitration rule between them.renderTooltip: two APIs for one job.Claim scope and non-goals
This record contracts the dot slice only. It leaves these uncontracted:
heatmapGL, hover onstreamGL, custom series and caller-added interactions;Chart's public
nearestandonPointerare unchanged, and so are AST-115's FR2, FR14 and DEC-7. FR4's default-text rows fordotGLanddotGLInteractivestand under AST-115 DEC-7 as written; this PR does not amend it.Known paint mismatch, outside this decision:
dotGLanddotGLInteractivepaint a missing y as a dot at y = 0, visible when 0 is in the y domain. FR3 makes that dot ineligible and requires no change to paint. How those marks paint a missing value is a separate decision.Evidence and implementation relationship
Real-Chrome probe on
mainof a 200-dot scatter withtooltipon: 20 sampled target dots, 7 pointer positions each inside the target's reach.These show agreement with the intended target only. They are neither proof of nearest or under-pointer identity nor rates in real data. Screenshots are not attached.
The option comparison and the per-hover probe data are kept outside the repository. The record stands without them.
No implementation is in this PR. The implementation follows as one change: the exact index and point mode in
ChartTooltip, the WebGL interactive story ontooltip, removal of the mark-local card andrenderTooltip, and tests, benchmarks and real-Chrome evidence per the verification map.dotGLInteractivedraws itself, and DEC-7's present-tense rationale, keeping DEC-7's Decider. Grouped WebGL rows keep their raw default text.Writing rubric results
For
module:ChartTooltip/pointMode:renderTooltip" became a present-tense statement.ChartTooltipselects the row nearest the pointer in x." "FR8 gap:dotGLInteractiveregisters its own hit target and acceptsrenderTooltip." Chart's pointer layer covers that hit target, so neither its card nor its halo appears in a browser.For
architecture:chart-point-pick:ChartTooltipno private series or input-type channel." "INV3 gap:ChartTooltipselects the row nearest the pointer in x on every chart." Optional acceleration is not listed as a gap.For
component:ChartTooltip: only themodules:backlink changes. It stays draft.Scope
Components: ChartTooltip (module pointMode); dotGLInteractive (API decision recorded); architecture: chart-point-pick
architecture:chart-point-pick, not in the module record (INV18). It is named because the built-in dot factories andChartTooltipshare it across package copies (spec:AST-110FR3), and becausetype,nearestandResolvedPointcannot carry what the pick needs (see the mechanism section above).Validation
pnpm check:knowledge: templates and records aligned.git diff --check: clean.pnpm specs:for --diff origin/main: routes the changed records.pnpm review:pre --head HEAD: 403 authored lines, merges cleanly, 0 findings.