Component

Charts

Composable SVG chart primitives. A Chart provides scales and dimensions through context; primitives like Bars, Line, and PieChart consume it.

Bar chart

Bars renders a band-scaled bar for each datum.

Line chart

Compose Line with Circles to add point markers.

Pie chart

PieChart is self-contained — it draws its own arcs and accepts a custom colors palette.

Installation

$pnpm add @refraction-ui/react-charts

Usage

tsx
import { Chart, Bars } from '@refraction-ui/react-charts'

const data = [
  { month: 'Jan', value: 32 },
  { month: 'Feb', value: 48 },
  { month: 'Mar', value: 41 },
]

export function Revenue() {
  return (
    <Chart width={520} height={280} margin={{ top: 16, right: 16, bottom: 32, left: 32 }}>
      <Bars data={data} x={(d) => d.month} y={(d) => d.value} fill="currentColor" />
    </Chart>
  )
}

Chart props

PropTypeDefaultDescription
widthnumber600Overall width of the SVG canvas in pixels.
heightnumber400Overall height of the SVG canvas in pixels.
marginPartial<Margin>--Inner padding `{ top, right, bottom, left }` reserved for axes and labels.
childrenReactNode--Chart primitives (`Bars`, `Line`, `Circles`, axes) rendered inside the chart context.

Series props (Bars / Line / Circles)

PropTypeDefaultDescription
dataT[]--Array of datum objects to plot.
x(d: T) => string | number--Accessor returning the x value for a datum (`string` for `Bars`, `number` for `Line`/`Circles`).
y(d: T) => number--Accessor returning the y value for a datum.
fill / strokestring'currentColor'Color of the rendered marks. Inherits text color via `currentColor`.