Chart

The config, axes, tooltip and legend every chart shares.

Installation

  1. Add the registryOnce per project
  2. Add chart

The charts are built on Recharts. Each chart, such as Area Chart, installs this file too.

Usage

The Area, Bar, Line and Pie charts already wrap Chart, so most of the time you only need this file's axes, tooltip and legend. Use Chart directly for anything they don't cover, like the mix of bars and a line above.

Config

The config labels and colors each series, keyed by data key (or by sector name, for a pie). Tooltips and legends follow its order.

Series without a color cycle through the theme's chart-1 to chart-5. Each key's color is also set as --chart-<key>, so a Recharts series can use var(--chart-desktop).

Examples

Icons

An icon takes the place of the series' swatch in the tooltip and legend.

Colors

Any CSS color works, but theme tokens adapt to dark mode.

Tooltip

labelFormatter and valueFormatter format the tooltip. indicator swaps the swatches for lines.

Legend

align and verticalAlign position the legend.

Props

Chart

ChartTooltip

ChartLegend

Each part also takes the props of the Recharts component it extends.