Chart root

Cartesian SVG container — supplies scales, dimensions, and ResizeObserver-driven width to all child primitives via context.

Primitive: ChartRoot· Standalone (no ChartRoot needed)

Interactive demo

Usage

import { ChartRoot, ChartLine, ChartAxisX, ChartAxisY } from '@ramtt/charts'

<ChartRoot data={data} height={200}>
  <ChartLine />
  <ChartAxisX />
  <ChartAxisY />
</ChartRoot>

Props

PropTypeDefaultDescription
data*readonly number[]Primary series — drives scaleY domain
heightnumber280SVG height in px (width from container)
paddingPartial<ChartPadding>Override per-edge padding
yPaddingnumber0.05Extra Y-domain padding fraction
yDomainreadonly [number, number]Override Y domain
xDomainreadonly [number, number]Override X domain (use [-0.5, N-0.5] for band positioning)
decimationFactornumber0.3Downsampling target multiplier (lower = smoother)
childrenReactNodeChart primitives