[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ 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
Bắt đầu tại packages/charts-core/src/svg-renderer.ts, ở focusGuideRenderHooks và lời gọi paint(), sau đó theo dõi cách resolvePaint được truyền qua svg.ts và svg-surface.ts. Thêm một bài kiểm thử hồi quy dựa trên cách tái hiện trong issue và chạy bằng pnpm vitest run; coi như hoàn tất khi các paint của focus-guide sử dụng url(#id) được phân giải thành ID tài nguyên trong phạm vi của idPrefix.
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). Split from #191 (section C) so it can be closed on its own.
With idPrefix set, mark paints such as fill: 'url(#fade)' resolve to the scoped resource id, but the same paint on a focus guide or crosshair is written verbatim and points at a resource that does not exist. This affects gradients today and <pattern> resources once PR #166 lands.
Why
renderChartSvgmapsurl(#id)tourl(#<idPrefix>-id)throughresolvePaint(svg.ts:18-26).focusGuideRenderHookshas onlyrenderGroup(svg-renderer.ts:84-86), sopaint()writes the value verbatim (svg-renderer.ts:207-209).
Repro
Save as packages/charts-core/src/repro.test.ts, run pnpm vitest run packages/charts-core/src/repro.test.ts.
import { expect, it } from 'vitest'
import { scaleLinear } from 'd3-scale'
import { areaY } from './area'
import { crosshair } from './crosshair'
import { motion } from './motion'
import { createChartScene, defineChart } from './scene'
const make = (end: number, top: number) =>
createChartScene(defineChart({
marks: [
areaY([{ x: 0, y: 1 }, { x: 1, y: top }, { x: 2, y: 2 }], { x: 'x', y: 'y', fill: 'url(#fade)' }),
crosshair({ y: false, stroke: 'url(#fade)' }),
],
scales: { x: { scale: scaleLinear().domain([0, 2]) }, y: { scale: scaleLinear().domain([0, 4]) } },
gradients: [{ id: 'fade', stops: [
{ offset: 0, color: '#2563eb', opacity: 0.6 }, { offset: end, color: '#2563eb', opacity: 0 }] }],
}), { width: 320, height: 200 })
const opts = { ariaLabel: 't', idPrefix: 'a' }
it('url(#id) in a focus-guide node is scoped by idPrefix', () => {
const el = document.createElement('div')
const surface = motion({ initial: false }).mount(el, () => {})
const scene = make(1, 3)
surface.render(scene, opts)
const p = scene.points[0]!
surface.paintFocus({ primary: p, group: [p], source: 'pointer', pinned: false })
const rule = el.querySelector('[data-ts-focus-guide-layer] [data-ts-key$=":x-rule"]')!
console.log('gradient id:', el.querySelector('linearGradient')?.id, '| guide stroke:', rule.getAttribute('stroke'))
expect(rule.getAttribute('stroke')).toBe('url(#a-fade)')
})
Actual output:
gradient id: a-fade | guide stroke: url(#fade)
AssertionError: expected 'url(#fade)' to be 'url(#a-fade)'
Expected
Guide node paints resolve to the scoped id like mark paints. Proposal: pass resolvePaint into focusGuideRenderHooks and the renderer-based path (svg-surface.ts:326-327).
Related: #191 (gradient stops and units), #128 / PR #166 (<pattern> resources).
- Ngôn ngữ chính
- TypeScript
- Star
- 819
- Fork
- 49
- Merge trung bình
- 4 giờ 58 phút
- Pull request đã merge (30 ngày)
- 15
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
-
[Bug] Printed charts keep their screen width: resize redraw waits for an animation frameCó thể đã có người làm @piecyk đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày 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
-
[Feature] Readable outside labels for crowded pie and donut chartsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
TanStack/charts#227 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/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 57/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/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 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
homarr-labs/homarr#7191 ·
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 62/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 74/100
AvaProtocol/ava-sdk-js#276 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
useFragment does not require `variables` when the fragment's variables type has required fieldsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
apollographql/apollo-client#13493 ·
Maintainer thường phản hồi trong vòng 1 ngày