The example below loads live from Storybook; open it in Storybook for the controls.
Line and area
Section titled “Line and area”line shows change along an ordered axis such as time. With several series every line has its own symbol and line style (solid, dashed, dotted), so series do not differ by colour alone. area softly fills under a single series.
Values of two series from January to June.
| Kategori | First series | Second series |
|---|---|---|
| January | 12 | 8 |
| February | 18 | 11 |
| March | 15 | 17 |
| April | 24 | 14 |
| May | 30 | 19 |
| June | 28 | 26 |
import { Chart } from '@bigbang/ui';
const months = ['January', 'February', 'March', 'April', 'May', 'June'];const first = [12, 18, 15, 24, 30, 28];const second = [8, 11, 17, 14, 19, 26];
const toPoints = (values: number[]) => values.map((y, index) => ({ x: months[index] ?? '', y }));
export default function Line() { return ( <div className="w-full max-w-2xl"> <Chart kind="line" title="Monthly values" description="Values of two series from January to June." series={[ { id: 'first', label: 'First series', data: toPoints(first) }, { id: 'second', label: 'Second series', data: toPoints(second) }, ]} /> </div> );}Bar and stacked bar
Section titled “Bar and stacked bar”bar compares categories; the value axis always starts at zero. stacked-bar shows the parts of a whole. Bars carry a pattern (decal) in addition to colour.
| Kategori | First series | Second series |
|---|---|---|
| January | 12 | 8 |
| February | 18 | 11 |
| March | 15 | 17 |
| April | 24 | 14 |
| May | 30 | 19 |
| June | 28 | 26 |
| Kategori | First series | Second series | Third series |
|---|---|---|---|
| January | 12 | 8 | 5 |
| February | 18 | 11 | 9 |
| March | 15 | 17 | 7 |
| April | 24 | 14 | 12 |
| May | 30 | 19 | 10 |
| June | 28 | 26 | 15 |
import { Chart } from '@bigbang/ui';
const months = ['January', 'February', 'March', 'April', 'May', 'June'];const first = [12, 18, 15, 24, 30, 28];const second = [8, 11, 17, 14, 19, 26];const third = [5, 9, 7, 12, 10, 15];
const toPoints = (values: number[]) => values.map((y, index) => ({ x: months[index] ?? '', y }));
export default function Bar() { return ( <div className="grid w-full gap-3xl md:grid-cols-2"> <Chart kind="bar" title="Monthly values" height="sm" series={[ { id: 'first', label: 'First series', data: toPoints(first) }, { id: 'second', label: 'Second series', data: toPoints(second) }, ]} /> <Chart kind="stacked-bar" title="Monthly values" height="sm" series={[ { id: 'first', label: 'First series', data: toPoints(first) }, { id: 'second', label: 'Second series', data: toPoints(second) }, { id: 'third', label: 'Third series', data: toPoints(third) }, ]} /> </div> );}donut shows the shares of one series; use at most 5 parts. The first series is drawn. Slices differ by colour and pattern.
| Kategori | Share of categories |
|---|---|
| Category A | 40 |
| Category B | 25 |
| Category C | 20 |
| Category D | 15 |
import { Chart } from '@bigbang/ui';
export default function Donut() { return ( <div className="w-full max-w-sm"> <Chart kind="donut" title="Share of categories" series={[ { id: 'share', label: 'Share of categories', data: [ { x: 'Category A', y: 40 }, { x: 'Category B', y: 25 }, { x: 'Category C', y: 20 }, { x: 'Category D', y: 15 }, ], }, ]} /> </div> );}Sparkline
Section titled “Sparkline”Chart.Sparkline is a small line without axes or tooltip. Put it in the trend slot of a StatCard. With label a screen reader reads its name; without it the sparkline is decoration and hidden.
import { Chart, StatCard } from '@bigbang/ui';
export default function Sparkline() { return ( <div className="w-full max-w-sm"> <StatCard label="Active items" value="3.420" delta={{ value: '12 %', direction: 'up' }} period="vs previous month" trend={<Chart.Sparkline tone="positive" data={[4, 6, 5, 9, 8, 12, 11]} label="Trend of the last six months" />} /> </div> );}Data table
Section titled “Data table”Every chart has a semantic table. The default table="toggle" adds a button that swaps the chart for the table. table="visible" shows both.
| Kategori | First series |
|---|---|
| January | 12 |
| February | 18 |
| March | 15 |
| April | 24 |
| May | 30 |
| June | 28 |
import { Chart } from '@bigbang/ui';
const months = ['January', 'February', 'March', 'April', 'May', 'June'];const first = [12, 18, 15, 24, 30, 28];
const toPoints = (values: number[]) => values.map((y, index) => ({ x: months[index] ?? '', y }));
export default function Table() { return ( <div className="w-full max-w-2xl"> <Chart kind="area" title="Monthly values" height="sm" table="visible" series={[{ id: 'first', label: 'First series', data: toPoints(first) }]} /> </div> );}Light and dark mode
Section titled “Light and dark mode”The chart reads its colours at run time from the tokens of the selected brand and mode, and redraws when either changes.
Values of two series from January to June.
| Kategori | First series | Second series |
|---|---|---|
| January | 12 | 8 |
| February | 18 | 11 |
| March | 15 | 17 |
| April | 24 | 14 |
| May | 30 | 19 |
| June | 28 | 26 |
Values of two series from January to June.
| Kategori | First series | Second series |
|---|---|---|
| January | 12 | 8 |
| February | 18 | 11 |
| March | 15 | 17 |
| April | 24 | 14 |
| May | 30 | 19 |
| June | 28 | 26 |
import { Chart } from '@bigbang/ui';
const months = ['January', 'February', 'March', 'April', 'May', 'June'];const first = [12, 18, 15, 24, 30, 28];const second = [8, 11, 17, 14, 19, 26];
const toPoints = (values: number[]) => values.map((y, index) => ({ x: months[index] ?? '', y }));
export default function Line() { return ( <div className="w-full max-w-2xl"> <Chart kind="line" title="Monthly values" description="Values of two series from January to June." series={[ { id: 'first', label: 'First series', data: toPoints(first) }, { id: 'second', label: 'Second series', data: toPoints(second) }, ]} /> </div> );}