Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Feature] `text` mark: numeric tween with a `format` function

未关闭
#215 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
57/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
d3, typescript

调研方向

Read packages/charts-core/src/text.ts around lines 112–114 and packages/charts-core/src/motion.ts around lines 2113–2116, then run the provided Vitest repro. Trace how text marks are rendered and how the reconciler handles text leaves; define completion by intermediate formatted values appearing during the tween, the final text matching the target exactly, and reduced motion retaining the snap behavior.

由索引模型根据 Issue 内容生成。

描述

Version: @tanstack/charts 1.1.0 (57774e1). Split from #193 (section B) so it can be closed on its own.

A text mark showing a number (a total in a donut centre, a value label) jumps to the new string while the marks around it animate.

Why
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).

import { expect, it, vi } from 'vitest'
import { scaleLinear } from 'd3-scale'
import { defineChart, text } from './index'
import { motion } from './motion'
import { createChartScene } from './scene'

it('numeric text content tweens', () => {
  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 scales = { x: { scale: scaleLinear }, y: { scale: scaleLinear } }
  const render = (v: number) => s.render(createChartScene(defineChart({ scales, guides: false,
    marks: [text([v], { x: () => 0.5, y: () => 0.5, text: (d) => d.toFixed(0) })] }), { width: 300, height: 200 }), { ariaLabel: 'x' })
  render(10); tick(0); tick(2000)
  render(90); tick(0)
  const seen = new Set<string>()
  for (const t of [250, 500, 750]) { tick(t); seen.add(el.querySelector('text')!.textContent!) }
  expect([...seen].length).toBeGreaterThan(1)
})

Output on 57774e1: distinct textContent values at 250/500/750 ms = [ '90' ] (expected more than 1).

Ask

An opt-in numeric text tween that writes the formatted string each frame and ends on the exact target; reduced motion keeps the snap. For example a format?: (value: number) => string option on text plus a motion opt-in.

Related: #193.

主要语言
TypeScript
星标
850
派生
56
平均合并
3 小时 59 分钟
30 天内合并 PR
19

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/charts 的其他 Issue

查看 TanStack/charts 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。