Charts
LineChart
Trends over time or any ordered sequence: one or more series, dates or categories on the x axis, gaps for missing values. AreaChart fills the area under each line and can stack series to show parts of a total.
import '@reactloom/charts/styles.css';
import { LineChart, AreaChart } from '@reactloom/charts';Examples
Two series, currency values
Hover or focus the chart and use the arrow keys.
- Revenue
- Costs
import { LineChart } from '@reactloom/charts';
import { monthly } from './data';
export default function Example() {
return (
<LineChart
title="Revenue and costs, 2026"
data={monthly}
x="month"
series={[
{ key: 'revenue', label: 'Revenue' },
{ key: 'costs', label: 'Costs' },
]}
valueFormat={{ style: 'currency', currency: 'USD', maximumFractionDigits: 0 }}
/>
);
}Dates on the x axis
A written description states the takeaway; ticks are spaced by date.
import { LineChart } from '@reactloom/charts';
import { daily } from './data';
export default function Example() {
return (
<LineChart
title="Daily active users, November"
description="Usage grew about 30% over the month, with the usual dip at weekends."
data={daily}
x="day"
xFormat={{ month: 'short', day: 'numeric' }}
series={[{ key: 'users', label: 'Active users' }]}
curve="monotone"
height={220}
/>
);
}Stacked areas
Each band is one channel; the top edge is the total.
- Web
- Mobile
- Partner
import { AreaChart } from '@reactloom/charts';
import { quarterly } from './data';
export default function Example() {
return (
<AreaChart
title="Sign-ups by channel"
description="Mobile grew fastest: 53% more sign-ups in Q4 than in Q1."
data={quarterly}
x="quarter"
stacked
series={[
{ key: 'web', label: 'Web' },
{ key: 'mobile', label: 'Mobile' },
{ key: 'partner', label: 'Partner' },
]}
/>
);
}API reference
| Prop | Type | Default |
|---|---|---|
titlerequiredNames the figure; shown above it unless hideTitle. | string | — |
datarequired | Row[] | — |
xrequiredX value of each row. Dates and numbers get a continuous axis. | key | (row) => string | number | Date | — |
seriesrequiredvalue defaults to row[key]; null is a gap. | { key, label, value?, color? }[] | — |
descriptionThe takeaway. Generated from the data when omitted. | ReactNode | — |
valueFormatCurrency, percent, units. Axis ticks add compact notation. | Intl.NumberFormatOptions | — |
formatValue · formatXYour own formatting. | (value) => string | — |
xFormatFor date x values. Default: month and day. | Intl.DateTimeFormatOptions | — |
xLabel · yLabelAxis titles. | string | — |
yDomainFix the value axis. | [min, max] | — |
curve | 'linear' | 'monotone' | 'linear' |
pointsDefault: shown up to 24 points. | boolean | — |
stacked (AreaChart) | boolean | — |
table | 'toggle' | 'visible' | 'none' | 'toggle' |
height | number | 280 |
loading · emptyState | boolean · ReactNode | — |
messagesTranslate built-in text. | Partial<ChartMessages> | — |
Customization
Series colours are the theme tokens --pl-color-chart-1 to --pl-color-chart-6, used in order. Set them in a theme (createTheme({ colors: { 'chart-1': '#0E7C66' } }), contrast-checked by checkThemeContrast) or per series with color.
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
LineChart
Renders CartesianChart, so its hooks apply too.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-series] | present when on |
[data-zero] | present when on |
Theme tokens it reads
--pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-border-strong --pl-color-border-subtle --pl-color-fg-muted --pl-color-fg-subtle --pl-focus-ring-color --pl-focus-ring-offset --pl-focus-ring-width --pl-font-size-sm --pl-font-size-xs --pl-radius-md --pl-radius-sm --pl-radius-xs
AreaChart
Renders CartesianChart, so its hooks apply too.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-series] | present when on |
[data-zero] | present when on |
Theme tokens it reads
--pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-border-strong --pl-color-border-subtle --pl-color-fg-muted --pl-color-fg-subtle --pl-focus-ring-color --pl-focus-ring-offset --pl-focus-ring-width --pl-font-size-sm --pl-font-size-xs --pl-radius-md --pl-radius-sm --pl-radius-xs
Accessibility
- Each chart is a
<figure>named by its title and described by a summary. Write thedescriptionyourself to state the takeaway; otherwise a factual summary is generated from the data (range, lowest and highest values, change from first to last), formatted for the active locale. - The drawing is hidden from assistive technology. Screen-reader users get the summary and the data table (“Show data table”), which is a real, sortable table.
- The plot is one tab stop. Arrow keys move between data points, a visible tooltip follows, and a polite live region reads the values. It is not
role="application", so screen readers keep their normal reading keys; in browse mode, use the table. - Colours come from the theme’s chart palette, each at least 3:1 against the background in every built-in theme. In Windows high-contrast mode series switch to system colours with dash patterns.
- In right-to-left layouts the x axis runs from the right and the value axis moves to the right side; ← moves forward.
| Key | Action |
|---|---|
| Tab | Focus the plot |
| → / ↓ | Next point (← in right-to-left layouts) |
| ← / ↑ | Previous point |
| Home / End | First / last point |
| Escape | Hide the tooltip |
Usage guidelines
Do
- Write a description that says what the reader should notice.
- Keep to four series or fewer; split the rest into small multiples.
Don’t
- Don’t use a line for categories that have no order — use a BarChart.
- Don’t stack series that can be negative.