[Feature] `motion()`: ticks that enter or leave on a change of scale do not travel with it
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
- 57/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả 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 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.
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.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.
- 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 78/100
fb55/htmlparser2#2579 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue needs-review
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add Module DB RulesĐang mởdocumentation public
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
midnightntwrk/umbradb#65 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area/channels kind/bug priority/medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nanocoai/nanoclaw#4501 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docker images: plain X.Y.Z tag (e.g. 7.2.3) is never updated after the initial release buildĐang mởneeds verification
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 13 ngày