The DPR-aware <canvas> primitive every chart draw layer sits on. It sizes
the backing buffer to width*dpr × height*dpr, keeps the CSS box at
width × height, applies setTransform(dpr, …) so the CanvasDraw
callback works in CSS-pixel coordinates, clears, and calls draw.
Drawing runs in useLayoutEffect (synchronous, before paint) so there is no
flash of an unsized or empty canvas. The backing buffer is resized only when
its device-pixel size changes (trap #7 in docs/rfcs/charts.md). A redraw at
the same size therefore resets nothing by itself, so the transform is
re-applied and the draw bracketed in save/restore on every run.
Props
drawCanvasDrawCanvasDrawtype@pond-ts/charts(ctx: CanvasRenderingContext2D, width: number, height: number) => voidA draw callback. The 2D context it receives is already transformed to device
pixels, so draw in CSS-pixel coordinates (0..width, 0..height) and it
renders crisply at any device-pixel ratio. The context is freshly transformed
and cleared before each invocation, and any state the callback sets (alpha,
dash, clip, …) is discarded when it returns.
requiredSynchronous draw callback, invoked after every (re)size or prop change.
CSS height in pixels.
CSS width in pixels.
classNamestringdprnumberDevice-pixel-ratio override (defaults to window.devicePixelRatio || 1).
Exposed so tests can pin a deterministic backing-buffer size; production
callers leave it unset.
styleCSSProperties