Skip to content

Components

Chart

Areas, lines and bars on one axis, a donut and an allocation bar: plain SVG that draws itself in, with a crosshair tooltip, keyboard reading, a legend and a table for screen readers.

  • Balance
  • Projected
Balance grows from ₹4.2L in April to a projected ₹10.2L next March.
Balance over time
monthBalanceProjected
Apr₹4.2L
May₹5.1L
Jun₹3.8L
Jul₹4.6L
Aug₹6.2L
Sept₹7.1L₹7.1L
Oct₹6.4L
Nov₹7.9L
Dec₹8.8L
Jan₹7.6L
Feb₹9.4L
Mar₹10.2L

Import

import { Chart, ChartArea, ChartLine, ChartBar, ChartReference, ChartTooltipCard, DonutChart, AllocationBar } from '@rinzai/zen';

Examples

Cashflow

Bars grouped by month with a line on the same axis; months still to come are faded.

  • Income
  • Spending
  • Net
Income and spending by month
monthIncomeSpendingNet
Apr₹92K₹61K₹31K
May₹92K₹74K₹18K
Jun₹98K₹58K₹40K
Jul₹98K₹1L-₹5K
Aug₹98K₹66K₹32K
Sep₹1.1L₹71K₹41K
Oct₹1.1L₹69K₹43K
Nov₹1.1L₹80K₹32K

Lines

Several series in the chart palette, in the order they're written; the legend appears for two or more.

  • Web
  • iOS
  • Android
Sessions by platform
dayWebiOSAndroid
Mon420310220
Tue480330260
Wed510360250
Thu470390300
Fri560380330
Sat690450310
Sun640470360

Donut

Parts of a whole with the total in the middle, and a legend of your own beside it, in the chart's colours (paletteColor).

Spent
₹61,200
  • Home₹28,000
  • Food₹14,500
  • Travel₹9,200
  • Fun₹6,100
  • Other₹3,400

Allocation

Where September's income went.

API reference

<Chart>

A chart on one axis: areas, lines and bars over rows of data (e.g. months), with a recessive grid, a crosshair and a tooltip listing every series at the pointer (or keyboard: focus it and use the arrow keys), a legend for two or more series, and a table of the values for screen readers. Series draw in as they appear. Colours default to the chart palette (--chart-1…8) in the order the series are written; give each its own color for meaning (e.g. the theme's glow).

PropTypeDefault
childrenRequired

ChartArea, ChartLine, ChartBar and ChartReference parts.

ReactNode—
dataRequired

One row per point on the x axis (e.g. a month).

readonly T[]—
labelRequired

Names the chart for screen readers.

string—
xRequired

The row field placed along the x axis.

string—
className
string—
formatTooltipX

The tooltip's title for an x value (defaults to formatX).

((value: T[X]) => string)—
formatX

Axis labels for x values.

((value: T[X]) => string)—
formatY

Axis ticks and tooltip values (defaults to compact numbers: 1.2K).

((value: number) => string)(n: number) => compactFormat.format(n)
height

Height in px, including the axis labels.

number240
legend

Show the legend. Defaults to on for two or more series, or a bar's dimLabel.

boolean—
palette

Colours for series that don't give their own: the categorical palette (default), or shades of the theme's glow.

ChartPalettechart
renderTooltip

Your own tooltip for a row (build it from ChartTooltipCard).

((row: T, index: number) => ReactNode)—
summary

A sentence on what the chart shows, for screen readers (e.g. its highest and lowest points).

string—

<ChartArea>

A line with a soft fill down to the baseline.

PropTypeDefault
dataKeyRequired

The row field holding this series' values (numbers; null for none).

string—
labelRequired

Its name in the legend, the tooltip and the table.

string—
color

Any CSS colour. Defaults to the next of --chart-1…8.

string—
curve

Smooth (default) or straight between points.

"linear" | "monotone"—
dashed

Dashed (e.g. a projection).

boolean—

<ChartLine>

A 2px line. Gaps (null values) break it, so one series can be split into solid and dashed parts.

PropTypeDefault
dataKeyRequired

The row field holding this series' values (numbers; null for none).

string—
labelRequired

Its name in the legend, the tooltip and the table.

string—
color

Any CSS colour. Defaults to the next of --chart-1…8.

string—
curve

Smooth (default) or straight between points.

"linear" | "monotone"—
dashed

Dashed (e.g. a projection).

boolean—

<ChartBar>

Bars, grouped with the other bar series, growing from the baseline.

PropTypeDefault
dataKeyRequired

The row field holding this series' values (numbers; null for none).

string—
labelRequired

Its name in the legend, the tooltip and the table.

string—
color

Any CSS colour. Defaults to the next of --chart-1…8.

string—
dim

Rows whose bar is faded, e.g. months still to come.

((row: Row, index: number) => boolean)—
dimLabel

What the faded bars mean, e.g. "Planned": the legend gets a faded key for it (and shows, even for one series).

string—

<ChartReference>

A marker across the plot: a horizontal line at y (e.g. zero), or a vertical one at the row whose x is x (e.g. today).

PropTypeDefault
dashed

Vertical lines are dashed unless dashed={false}; horizontal ones solid unless dashed.

boolean—
label

Text beside a vertical line, e.g. "Today".

string—
tone

Destructive for a line that warns (e.g. below zero).

"muted" | "negative"—
x

A vertical line at the row whose x field equals this.

unknown—
y

A horizontal line at this value.

number—

<ChartTooltipCard>

The tooltip's card: a title and one row per series, the value first and the series keyed by a short stroke of its colour. Use it in renderTooltip to show your own rows.

PropTypeDefault
rowsRequired
{ label: string; value: string; color?: string | undefined; dashed?: boolean | undefined; }[]—
titleRequired
ReactNode—
className
string—

<DonutChart>

A ring of parts of a whole (e.g. spending by category), with your content in the middle (e.g. the total). Segments are parted by a small gap, with rounded corners; pointing at one (or focusing it) lifts it and shows its value. A part too small to show at its share is drawn as a pill, the narrowest segment, taking the room from the larger parts in proportion. Best for a handful of parts: past about six, use bars. Colours default to the chart palette in order.

PropTypeDefault
itemsRequired

The parts, in order round the ring from 12 o'clock.

{ key: string; label: string; value: number; color?: string | undefined; }[]—
labelRequired

Names the chart for screen readers.

string—
children

Content in the middle, e.g. the total.

ReactNode—
className
string—
formatValue

Values in the tooltip and for screen readers.

((value: number) => string)—
palette

Colours for items that don't give their own: the categorical palette (default), or shades of the theme's glow.

ChartPalettechart
size

Diameter in px.

number200
thickness

Ring thickness as a share of the radius.

number0.32

<AllocationBar>

Where a whole went, as one bar split into its parts (e.g. income across spending, savings and bills), with a legend of each part's value and share. Pointing at a part, in the bar or the legend, picks it out; screen readers hear every part's value and share from the bar's label. Sweeps in from the start the first time it's seen. Colours default to the chart palette in order, like DonutChart's.

PropTypeDefault
itemsRequired
AllocationItem[]—
labelRequired

What the whole is, e.g. "Income in September", for screen readers.

string—
className
string—
formatValue
((value: number) => string)—
legend

The list of parts under the bar (default on).

booleantrue
locale

For the shares' percent format.

string—
palette

Colours for items that don't give their own: the categorical palette (default), or shades of the theme's glow.

ChartPalettechart