Skip to content
ChartslibraryUI Get Pro

Common API

All charts follow the same conventions, so learning one teaches you the rest.

Data

Charts take an array of plain row objects and the keys to read. You don't reshape your data into a chart-specific format.

<LineChart data={rows} x="month" series={["revenue", "cost"]} />
<BarChart data={rows} x="region" y="revenue" />
<Heatmap data={cells} row="channel" column="week" value="delta" />
  • series accepts strings or { key, label?, color?, dashed? }.
  • Single-measure charts use y (plus an optional label).
  • null or undefined means missing. It's drawn as a gap or left out, and a note says how many.
  • Strings where numbers are expected are invalid. The chart shows an error naming the rows instead of guessing.

Frame props (every chart)

Prop Type Meaning
title ReactNode The takeaway: "Revenue passed plan in March"
subtitle ReactNode What's measured: metric, unit, period
source ReactNode Shown in the footer as "Source: …"
footnote ReactNode Extra footer text
height number Plot height in px (horizontal bar charts grow with rows by default)
width number Fixed width; by default the chart fills its container
mode "light" | "dark" | "auto" Override the inherited theme
toolbar boolean Show the Table/CSV buttons (default true)
showNotes boolean Show data notes under the chart (default true)
titleAs "h2" | "h3" | "h4" | "div" Heading level of the title (default h3)
className, style Applied to the outer <figure>

Shared value props

Prop Charts Meaning
format all See formatting
highlight line, bar, donut, scatter, slope… Keys or labels to emphasise; others turn grey
favorable diverging, variance, waterfall, KPI… "up" (default) or "down": which direction is good
forecastFrom line family, bars First x value that is a forecast
partialFrom line family, bars First x value that is incomplete
references line family, bars [{ value, label }] reference lines
zero line, scatter, dot plot Include zero in the axis (bars and areas always do)
sort bar, dot, dumbbell "none" | "asc" | "desc"

Interaction built in

  • Tooltip: a crosshair on time series, and per mark everywhere else. It lists every series with the same formatting as the axis.
  • Keyboard: tab to a chart, then use arrow keys to move through points or categories, Home/End to jump, and Escape to clear.
  • Legend: click to hide or show a series; hover to highlight it.
  • Table view and CSV: the toolbar switches the chart to an accessible table and downloads the underlying data.

Charts that report problems

Each chart validates its data:

Situation Result
Empty data "No data to display" placeholder
Non-numeric values Error listing the key and sample values
Impossible input (negative pie slice, high < low in OHLC, cyclic sankey) Error naming the rows
Missing values Gaps, plus a note with the count
Duplicates, too many series, inconsistent subtotals A "Check:" warning under the chart
A render crash Caught by the chart's error boundary and shown as a message, so the page keeps working

Set showNotes={false} to hide notes and warnings (errors always show).

Core exports

Building something custom? The core is importable:

import { ChartFrame, ChartTooltip, useActiveIndex } from "@/components/charts/core/frame";
import { linearScale, bandScale, valueDomain, niceTicks, timeTicks } from "@/components/charts/core/scale";
import { linePath, areaPath, barPath, arcPath } from "@/components/charts/core/path";
import { formatValue, tickFormatter } from "@/components/charts/core/format";
import { checkRows, column, parseDate } from "@/components/charts/core/data";
import { YGrid, XLabels, RefLine, PeriodShade } from "@/components/charts/core/axis";

See Composition for a worked example.