[Feature] `motion()`: ticks that enter or leave on a change of scale do not travel with it
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 57/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- d3, typescript
- Ambito
- data-visualization, frontend
Direzione di ricerca
Start in packages/charts-core/src/motion.ts at the enter and exit opacity tweens, then read packages/charts-core/src/scene.ts where ticks are keyed by value. Compare the renderer’s previous and next scenes and scale positions; the issue’s Vitest repro gives a concrete check. Done means entering ticks start at their previous-scale positions and leaving ticks end at their new-scale positions while still fading.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: @tanstack/charts 1.5.0 (b236dae).
When a continuous scale's domain changes, a kept tick moves with the marks, but an entering tick fades in at its final place and a leaving one fades out where it stood. With a y domain going from 0–100 to 0–200, the 100 label slides down from the top while the new 200 label already sits there. Grid lines do the same.
Ticks are keyed by value (scene.ts:1883), and enter and exit are opacity tweens only (motion.ts:2642-2659, motion.ts:2749-2762). d3-axis starts an entering tick at its value's place on the previous scale and ends a leaving one at its place on the new scale (axis.js, __axis).
Repro
npm i @tanstack/[email protected] vitest jsdom, then npx vitest run ticks.test.ts.
// @vitest-environment jsdom
import { defineChart, lineY } from '@tanstack/charts'
import { motion } from '@tanstack/charts/motion'
import { mountChartRenderer } from '@tanstack/charts/renderer'
import { scaleLinear } from '@tanstack/charts/scales/linear'
import { expect, it, vi } from 'vitest'
it('entering and leaving ticks travel with a change of scale', () => {
let now = 0
const frames: FrameRequestCallback[] = []
vi.spyOn(performance, 'now').mockImplementation(() => now)
vi.spyOn(window, 'requestAnimationFrame').mockImplementation((f) => frames.push(f))
const renderer = motion({ initial: false, transition: { type: 'tween', duration: 400, easing: 'linear' } })
// Ticks at 0, top / 2 and top. In the plot, y=170 is 0 and y=10 is `top`.
const options = (top: number) => ({
definition: defineChart({
marks: [lineY([{ x: 0, y: 10 }, { x: 1, y: 90 }], { x: 'x', y: 'y' })],
scales: {
x: { scale: scaleLinear().domain([0, 1]) },
y: { scale: scaleLinear().domain([0, top]), axis: { ticks: { values: [0, top / 2, top] } } },
},
margin: { top: 10, right: 10, bottom: 30, left: 40 },
}),
renderer,
width: 300,
height: 200,
ariaLabel: 'ticks',
})
const el = document.createElement('div')
const host = mountChartRenderer(el, options(100))
const y = (tick: number) =>
Number(el.querySelector(`[data-ts-key="y-tick-label:number:${tick}"]`)?.getAttribute('y'))
host.update(options(200)) // 100 moves from y=10 to y=90, 200 enters, 50 leaves
now = 200 // half way
frames.splice(0).forEach((frame) => frame(now))
// On the scale the kept tick is moving with, 200 is at y=-70 and 50 at y=110.
expect({ kept100: y(100), entering200: y(200), leaving50: y(50) }).toEqual({ kept100: 50, entering200: -70, leaving50: 110 })
})
- "entering200": -70,
+ "entering200": 10,
"kept100": 50,
- "leaving50": 110,
+ "leaving50": 90,
Ask
Under motion(), when a continuous scale's domain changes, an entering tick rule, label and grid line start where their value sits on the previous scale, and a leaving one ends where its value sits on the new scale, each still fading. The renderer holds both scenes, so this needs no option.
The workaround is two renders in one frame (the new tick values on the old domain with enter motion off, then the real update), which needs fixed margins and thin: false, and still leaves exiting ticks in place.
Related: #195, #214.
- Lingua principale
- TypeScript
- Stelle
- 870
- Fork
- 57
- Merge medio
- 11h 58m
- PR unite (30g)
- 18
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
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Forse già presa @getdownandcode l’ha presa 37 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TanStack/charts#211 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Add reverse options to waffleY and waffleXForse già presa @tannerlinsley l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/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
Tutte le issue di TanStack/charts
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
fb55/htmlparser2#2579 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue needs-review
Difficoltà 1/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Add Module DB RulesApertadocumentation public
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
midnightntwrk/umbradb#65 ·
I maintainer di solito rispondono entro 2 giorni
-
area/channels kind/bug priority/medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nanocoai/nanoclaw#4501 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
needs verification
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 13 giorni