Feature request: a framework render slot for axis tick labels
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
- Ambito
- data-visualization
Direzione di ricerca
Start by reading the axis tick configuration under scales.y and the existing tooltip render path, RendererChart from @tanstack/charts/react/tooltip. The issue suggests either an axis render slot or exposing resolved tick positions and the plot rect, so the API and layout behavior still need design. Done means framework-rendered tick labels can be positioned and sized by the chart without duplicating plot layout math.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: @tanstack/charts 1.0.0, React adapter
Problem
Tick labels are SVG text. ticks.format returns a string. There is no way to render a framework component (an icon, an image, a styled badge) as a tick label.
Recharts lets you pass a component as tick. We used this for an Elo chart. Each y tick shows a skill level icon and the Elo value next to it. Each x tick on one variant shows a styled match result marker.
The tooltip already has a framework render path (RendererChart from @tanstack/charts/react/tooltip). Tick labels do not.
Our workaround
We hide the axis labels in the chart and render them as HTML over the plot. The component must know the plot layout:
- the y position of each tick, as a fraction of the y domain
- the x position of each tick, as a fraction of the x domain
- the plot insets and the x padding, so that the HTML labels line up with the SVG plot
Simplified from our code:
// Our own copy of the plot insets (example values). It must match the
// chart definition.
const layout = { top: 8, bottom: 24, start: 72, end: 8, xPadding: 12 };
<Frame>
<Chart definition={definition} ariaLabel={label} height={height} />
<YAxisLayer
style={{
insetBlock: `${layout.top}px ${layout.bottom}px`,
inlineSize: layout.start - TICK_GAP,
}}
>
{yTicks.map(tick => (
<SkillTick key={tick} value={tick} offset={getYFraction(yDomain, tick)} />
))}
</YAxisLayer>
<PlotLayer
style={{
insetBlock: `${layout.top}px ${layout.bottom}px`,
insetInline: `${layout.start + layout.xPadding}px ${layout.end + layout.xPadding}px`,
}}
>
{rows.map(row => (
<ResultTick key={row.x} row={row} position={getXFraction(xDomain, row.x)} />
))}
</PlotLayer>
</Frame>
This works, but:
- We copy the scale math and the plot insets into the component. If the library changes its layout, the labels move away from the plot.
- The library cannot measure the labels, so we reserve the label space by hand (a fixed gap and a fixed width).
- The labels are not part of the chart accessibility tree.
Suggested API
A render slot on the axis, for the adapters that support it. For example:
scales: {
y: {
scale: scaleLinear,
axis: {
ticks: {
render: tick => <SkillTick value={tick.value} />,
// the space the library reserves for each label
size: { width: 64, height: 24 },
},
},
},
},
The library positions each slot at the tick, like it does for the tooltip. An alternative is to expose the resolved tick positions and the plot rect to the framework layer (for example through a callback or a hook), so that an overlay does not have to copy the math.
Written by an agent (Claude Code, claude-opus-5-5).
- Lingua principale
- TypeScript
- Stelle
- 819
- Fork
- 49
- Merge medio
- 12h 9m
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/charts
-
Renderer treats a sub-pixel width difference as a resize, which cancels the `motion()` entranceAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
TanStack/charts#182 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
brushX with `values` can shorten the selection range when it’s dragged to the plot edgeForse già presa @andersk l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Grid and axis lines have no `shape-rendering` option, so hairlines anti-alias across two device rowsAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/charts
Issue simili
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
alunduil/projects-v2-sync#21 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
enhancement minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
testcontainers/testcontainers-node#1539 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
christopher-buss/eslint-plugin-flawless#72 ·
I maintainer di solito rispondono entro 1 giorno
-
cleanName keeps a state code that's joined to the word before it (SavannahGa → "Savannah Ga")Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
openwatersio/slackwater-database#281 ·
I maintainer di solito rispondono entro 1 giorno