[Bug] Printed charts keep their screen width: resize redraw waits for an animation frame
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- d3, react, typescript
- Ambito
- data-visualization, frontend
Direzione di ricerca
Start in packages/charts-core/src/renderer.ts around lines 406-432, where scheduleRender() defers redraws to requestAnimationFrame, and trace how the ResizeObserver callback reaches it. The root svg uses a viewBox built from the screen width, so the redraw must run when the container width changes, including under print media. Pull request #229 is already open against this issue, so check it before starting.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: @tanstack/charts 1.1.0, Chromium. Also seen with Playwright page.pdf().
A responsive chart (no width) is drawn at its screen width. When the page is printed or exported with page.pdf(), the print layout narrows the container but the chart is not redrawn. The browser scales the screen drawing down, so text and strokes shrink, and a fixed-height chart is letterboxed with empty space above and below.
Why
- The root SVG uses
width="100%" height="100%"withviewBox="0 0 <screenWidth> <height>", so a width change scales the existing drawing. ResizeObserversees the new size, but the redraw goes throughscheduleRender(), which waits forrequestAnimationFrame(renderer.ts).- Print and
page.pdf()lay out and paint without running an animation frame, so the redraw never happens before the page is printed.
Repro
- Render
<Chart definition={…} height={320} ariaLabel="…" />in a container with a percentage width. - Open print preview in a viewport wider than the page, or call
page.pdf({ format: 'A4' })on a 1200px-wide page. - The chart is a scaled-down screen drawing, not a chart laid out for the page width.
Expected
The chart redraws at the print container width before printing.
Workaround
On the print media change, measure the container and pass it as a fixed width inside flushSync, then remove width when print ends. It works, but every app that prints has to know about it.
- Lingua principale
- TypeScript
- Stelle
- 819
- Fork
- 49
- Merge medio
- 4h 40m
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/charts
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Forse già presa @getdownandcode l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TanStack/charts#211 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Feature] Readable outside labels for crowded pie and donut chartsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
TanStack/charts#227 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/charts
Issue simili
-
documentation good first issue
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
sujithputta02/Esapay#13 ·
-
Share dialog: the address book's contact count reads "1 contacts" (no singular form in any language)Forse già presa @chibenwa l’ha presa oggi. Apertaai-driven-qa bug claude Cosmetic
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
linagora/twake-contacts-frontend#271 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Koenkk/zigbee2mqtt#33402 ·
I maintainer di solito rispondono entro 1 giorno
-
dx P2 platform Stellar Wave Wave 10
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
winsznx/routedock#579 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:ui effort:S enhancement priority:P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno