[Bug] Arc motion: rounded arcs snap and lose their round caps, and enter `delay` runs once per arc group
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- data-visualization
Línea de trabajo
Start with createArcTracks in packages/charts-core/src/motion.ts (around line 1638), which builds one enter track per g.ts-chart__arc group, and compare it with createBarTracks (around line 1238), which makes one call per datum. Run the reproduction test in part A to see that delay fires once. Done for part A means one enter track and one delay call per sector, with datumIndex, datumCount and datum set. Parts B and C also need public API decisions on SceneArea and the enter/exit seeds, so check with maintainers before writing those.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version: @tanstack/charts 1.1.0 (57774e1).
Built-in polar arcs (radialArc, ring progress arcs, pie wedges, sunburst sectors) animate worse than bars: a sunburst cannot stagger its sectors on enter (A), a rounded arc snaps when its sweep changes (F, moved here from #193), and the enter sweep cuts round caps flat (E). B asks for the arc geometry that would fix F and E to be public, so custom marks get the arc tween too.
A. Enter delay is called once per arc group, not per sector
createArcTracksmakes one enter track perg.ts-chart__arcgroup, withdatumIndex: 0,datumCount: 1,datum: undefined(motion.ts:1638-1641).- The sunburst emits one group holding all sectors (
hierarchy-sunburst.ts:322-329), sodelay(context)(types.ts:873) cannot tell sectors apart. Bars get one call per datum. - Polar marks use the same group class (
polar.ts:552,polar.ts:831).
Repro: save as packages/charts-core/src/repro.test.ts, run pnpm vitest run packages/charts-core/src/repro.test.ts (fails on main).
import { expect, it } from 'vitest'
import { motion } from './motion'
import { polar } from './polar'
import { sunburst } from './hierarchy-sunburst'
import { createChartScene, defineChart } from './scene'
import type { ChartMotionContext } from './types'
const rows = [
{ name: 'a', size: 0 }, { name: 'a.x', size: 3 }, { name: 'a.y', size: 2 },
{ name: 'b', size: 0 }, { name: 'b.x', size: 4 }, { name: 'b.y', size: 1 },
]
it('A: enter delay is called once per sector', () => {
const calls: ChartMotionContext[] = []
const scene = createChartScene(
defineChart({
marks: [polar({
marks: [sunburst(rows, {
path: 'name', delimiter: '.', value: 'size',
motion: { delay: (ctx) => (calls.push(ctx), ctx.datumIndex * 80) },
})],
scales: { angle: null, radius: null },
})],
scales: { x: null, y: null },
}),
{ width: 200, height: 200 },
)
const container = document.createElement('div')
motion({ transition: { type: 'tween', duration: 100, easing: 'linear' } })
.mount(container, () => {})
.render(scene, { ariaLabel: 'Sunburst' })
const enter = calls.filter((c) => c.phase === 'enter')
console.log(enter.map((c) => [c.role, c.datumIndex, c.datumCount]))
expect(container.querySelectorAll('g.ts-chart__arc path').length).toBe(6)
expect(enter.length).toBe(6) // one call per sector
})
Actual output:
[ [ 'arc', 0, 1 ] ]
AssertionError: expected 1 to be 6
Expected: delay is called per sector on enter, with datumIndex, datumCount and datum set, as for bars. Proposed: one enter track per sector, as createBarTracks does (motion.ts:1238).
F. Rounded polar arcs snap (moved here from #193 C)
radialArcbuilds a plain d3arc()with.cornerRadius(...)(polar.ts:445-453) and attaches no path geometry, soaddSemanticPathUpdateTrackreturns false (motion.ts:2386-2399).- The generic path needs identical command skeletons (
motion.ts:3650-3658); otherwisedis set directly. - Measured skeletons with
cornerRadius(6), radii 60/80: sweep 0 radMLZ, 0.012MALAZ, 1 to 5MAAALAAAZ, full circleMAAMAAZ. Crossing a threshold, including 0 to N, snaps.
Expected: a keyed arc whose angle changes animates. At minimum, document that a skeleton mismatch snaps.
Fix: radialArc, radialBarRadius and radialBarAngle attach arc geometry including corner radius so they use addSemanticPathUpdateTrack.
Repro: same file and command as A. With cornerRadius: 6 it fails; the cornerRadius: 0 control passes.
import { expect, it, vi } from 'vitest'
import { motion } from './motion'
import { polar, radialArc } from './polar'
import { createChartScene, defineChart } from './scene'
it.each([6, 0])('F: arc sweep tweens with cornerRadius %i', (cornerRadius) => {
const queue: FrameRequestCallback[] = []
const tick = (t: number) => queue.splice(0).forEach((f) => f(t))
vi.spyOn(window, 'requestAnimationFrame').mockImplementation((f) => queue.push(f))
vi.spyOn(window, 'cancelAnimationFrame').mockImplementation(() => {})
const el = document.createElement('div')
const s = motion({ transition: { type: 'tween', duration: 1000, easing: 'linear' } }).mount(el, () => {})
const render = (e: number) => s.render(createChartScene(defineChart({
scales: { x: null, y: null }, guides: false,
marks: [polar({ scales: { angle: null, radius: null }, marks: [radialArc([{ id: 'a', s: 0, e }],
{ key: 'id', startAngle: 's', endAngle: 'e', innerRadius: 60, outerRadius: 80, cornerRadius })] })],
}), { width: 300, height: 200 }), { ariaLabel: 'x' })
render(0.012); tick(0); tick(2000)
render(5); tick(0)
const seen = new Set<string>()
for (const t of [250, 500, 750]) { tick(t); seen.add(el.querySelector('path')!.getAttribute('d')!) }
expect(seen.size).toBeGreaterThan(1)
})
Output on 57774e14: F: distinct d values at 250/500/750 ms with cornerRadius 6 = 1 (expected > 1); with cornerRadius: 0, 3 distinct values.
E. The arc enter sweep is a straight wedge clip, so rounded caps are cut flat (from this comment)
For built-in polar arcs (radialArc with cornerRadius, ring progress arcs, pie wedges), the enter animation does not draw an arc of growing sweep. createArcTracks clips the whole g.ts-chart__arc group with a <clipPath> whose path is a centre-anchored wedge, rebuilt per frame by radialSweepClipPath (motion.ts:1618-1700, motion.ts:1803-1820). The final shape is therefore revealed by a straight radial edge, and the leading end of a rounded arc shows a flat cut instead of a round cap until the sweep completes.
Read from source, not run (jsdom has no paint): render a radialArc with cornerRadius: 6 and a large sweep under motion() and inspect the group's clip-path mid-enter.
Expected: the same arc geometry that F needs (and B proposes exposing) would let the enter animate the arc's own end angle, so the cap stays round, instead of clipping. At minimum, document that the enter is a wedge clip.
B. The arc tween metadata is private
- The arc tween needs angles and radii on the node under the
sceneMotionNodesymbol; without itaddSemanticPathUpdateTrackreturns false (motion.ts:2397-2398). - The symbol is not exported (
scene-motion-internal.ts:3); only built-ins set it (hierarchy-sunburst.ts:301,bar.ts:385). SceneAreahas no field for it (types.ts:1551-1556), so custom nodes only getpath: 'morph', a command-by-command path interpolation (motion.md:287).
Expected: a documented optional field on SceneArea (arc values and projector) so custom marks get the arc tween.
C. Sunburst enter/exit seeds cannot be supplied
Moved to #214, together with the scale enter from #193 D.
D. Arc state styles have no angle or radius keys
Moved to #213, together with the geometry keys from #186 E.
A and F were run; B and E are read from source.
Related: polar states are in released code as commit 265b20e (see this comment); #126 and PR #158 do not yet reflect that.
- Lenguaje dominante
- TypeScript
- Estrellas
- 870
- Forks
- 57
- Merge medio
- 11 h 58 min
- PR fusionados (30 d)
- 18
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/charts
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Posiblemente ocupada @getdownandcode la tomó hace 37 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TanStack/charts#211 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add reverse options to waffleY and waffleXPosiblemente ocupada @tannerlinsley la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/charts
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
fb55/htmlparser2#2579 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue needs-review
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
Add Module DB RulesAbiertodocumentation public
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
midnightntwrk/umbradb#65 ·
Los mantenedores suelen responder en 2 días
-
area/channels kind/bug priority/medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nanocoai/nanoclaw#4501 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Docker images: plain X.Y.Z tag (e.g. 7.2.3) is never updated after the initial release buildAbiertoneeds verification
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 13 días