[Bug] `motion()`: no enter animation for keyed rect/dot/text on first paint, or for marks in a newly joined group
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- d3, typescript
- Lĩnh vực
- data-visualization, frontend
Hướng nghiên cứu
Start with packages/charts-core/test-repro/08-motion-coverage.test.ts, run it with pnpm vitest run, and read the first-paint track setup in packages/charts-core/src/motion.ts near lines 281-286. The issue covers three separate gaps (first-paint enter for keyed rect/dot/text, numeric text tween in text.ts, and arc path morphing in polar.ts), so pick one and scope it. Done means the matching repro assertion passes without breaking the controls.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version: @tanstack/charts 1.1.0 (57774e1).
Description
Two enter paths skip marks that the update path animates:
- A. Keyed
rect,dotandtextmarks get no enter track on first paint. - E. A mark group that joins during an update only fades; its per-datum enter (bar grow) never plays.
A. First paint: no enter track for keyed rect, dot, text
- First paint builds only bar, cartesian path, radial path and arc tracks (
motion.ts:281-286). - The generic enter track is added only for elements that join in an update (
motion.ts:2159). - Docs list only bars, paths and arcs for initial choreography (
motion.md:54-56).
Expected: keyed rect, dot and text get the same enter track on first paint as when they join a group, or the docs say initial covers only bars, paths and arcs.
Fix: call addEnterMotionTrack (motion.ts:2475) in the first-paint path for keyed elements no other track covers.
Repro: save as packages/charts-core/src/repro.test.ts, run pnpm vitest run packages/charts-core/src/repro.test.ts (vitest + jsdom, rAF driven by hand). "Animated" means the element has data-ts-motion-role. The test asserts the expected behaviour; the control passes.
import { expect, it, vi } from 'vitest'
import { scaleLinear } from 'd3-scale'
import { barY, defineChart, dot, rect, text } from './index'
import { motion } from './motion'
import { createChartScene } from './scene'
const queue: FrameRequestCallback[] = []
const tick = (t: number) => queue.splice(0).forEach((f) => f(t))
function mount() {
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, () => {})
return { el, render: (d: ReturnType<typeof defineChart>) =>
s.render(createChartScene(d, { width: 300, height: 200 }), { ariaLabel: 'x' }) }
}
const scales = { x: { scale: scaleLinear }, y: { scale: scaleLinear } }
const rows = [0, 1, 2].map((i) => ({ id: `r${i}`, x: i, x2: i + 0.5, y: 10 + i }))
const A = (data: typeof rows) => defineChart({ scales, guides: false, marks: [
barY(data, { key: 'id', x: 'x', y: 'y' }),
rect(data, { key: 'id', x1: 'x', x2: 'x2', y1: () => 0, y2: 'y' }),
dot(data, { key: 'id', x: 'x', y: 'y' }),
text(data, { key: 'id', x: 'x', y: 'y', text: 'y' }),
] })
const animated = (el: HTMLElement, sel: string) =>
[...el.querySelectorAll(`${sel} [data-ts-key]`)].filter((n) => n.hasAttribute('data-ts-motion-role')).length
const kinds = (el: HTMLElement) => ['bar', 'rect', 'dot', 'text'].map((k) => `${k}=${animated(el, `.ts-chart__${k}`)}`)
it('A: first paint animates keyed rect, dot and text like bars', () => {
const { el, render } = mount()
render(A(rows)); tick(0); tick(100)
expect(kinds(el)).toEqual(['bar=3', 'rect=3', 'dot=3', 'text=3'])
})
it('A control: the same marks join an empty chart with an enter track', () => {
const { el, render } = mount()
render(A([])); tick(0); tick(2000)
render(A(rows)); tick(0); tick(100)
expect(kinds(el)).toEqual(['bar=3', 'rect=3', 'dot=3', 'text=3'])
})
Output on 57774e14:
A: expected ['bar=3','rect=3','dot=3','text=3'], received ['bar=3','rect=0','dot=0','text=0']
A control: passes
Downstream measurement (bklit migration, Chrome, 800 ms window, keyed barY/lineY/rect/dot/text): first paint had 0 animating rects/dots/text; after an empty-then-data flip, 8/17 each.
E. A mark group that joins during an update only fades (from this comment)
In the update reconciler, an unmatched child is cloned and addEnterMotionTrack runs on that one element only (motion.ts:2140-2159). The function has no recursion into descendants. The bar grow branch requires the element itself to be a rect or path (motion.ts:1414-1420, motion.ts:2505-2510). So a bar joining an existing g.ts-chart__bar-y group grows, but a whole new group (a series that is added, or data that goes from [] to N rows so the mark group is new) falls to the opacity branch (motion.ts:2596-2635) and its bars never grow. createBarTracks runs only on first paint (motion.ts:273-286, motion.ts:1238).
Repro (source-level; not run): render a barY chart with [], then re-render with data. Expected a grow, observed a fade. Changing 0 to N on a chart whose group already exists does grow.
Proposal: when a group joins, run the first-paint enter tracks for its descendants (createBarTracks and friends scoped to the new group), so a joining group animates like a first paint.
B. Text content cannot be tweened
Moved to #215 (a new
textoption, with its repro).
C. Rounded polar arcs snap
Moved to #194, which covers arc motion, with its repro.
D. The only generic enter is an opacity fade (comment)
Moved to #214, together with the sunburst enter/exit seeds from #194 C.
- Ngôn ngữ chính
- TypeScript
- Star
- 870
- Fork
- 57
- Merge trung bình
- 11 giờ 58 phút
- Pull request đã merge (30 ngày)
- 18
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/charts
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Có thể đã có người làm @getdownandcode đã nhận 37 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TanStack/charts#211 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add reverse options to waffleY and waffleXCó thể đã có người làm @tannerlinsley đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/charts
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vega/vega-webgpu#40 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openwatersio/slackwater#550 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug size:small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fb55/htmlparser2#2579 ·
Maintainer thường phản hồi trong vòng 1 ngày