GroupedBar
Bars side by side, one per series, in each period: compare the series period by period. It is BarChart with two or more series.
import { BarChart } from '@sypnia/ui/react'
On this page
Sign-ups by plan
Sign-ups by plan
Per month
- Free
- Pro
View as table
| Free | Pro | |
|---|---|---|
| Jul | 120 | 30 |
| Aug | 150 | 42 |
| Sep | 140 | 38 |
| Oct | 190 | 55 |
| Nov | 210 | 61 |
Code
import { BarChart } from '@sypnia/ui/react';
// Bars side by side to compare series in each period.
export default function Compare() {
return <BarChart title="Sign-ups by plan" subtitle="Per month" x={['Jul', 'Aug', 'Sep', 'Oct', 'Nov']}
series={[{ id: 'free', label: 'Free', data: [120, 150, 140, 190, 210] }, { id: 'pro', label: 'Pro', data: [30, 42, 38, 55, 61] }]} />;
} When to use it
Use it when
- Comparing a few series in each period.
Do not use it when
- More than three series: the groups get thin.
- Parts of a total: use StackedBar.
For everyone
- Hover or focus a bar to read every series of that period; the table has all.
Props
| BarChart | Type | Default |
|---|---|---|
seriesrequired | Series[] | |
titlerequired | ReactNode | |
xrequiredThe positions along the horizontal axis: dates, hours, names. | string[] | |
empty | ReactNode | |
error | ReactNode | |
formatValueHow a value is written in ticks, tooltip and table. Defaults to a compact number in the person's language. | ((v: number) => string) | |
height | number | |
loading | boolean | |
stackedSeries on top of each other (parts of a total) instead of side by side. | boolean | false |
subtitle | ReactNode | |
xLabelThe header of the first column of the table view: what `x` is. | string |