Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#215 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
d3, typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
819
Fork
49
Merge medio
4h 40m
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/charts

Tutte le issue di TanStack/charts

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.