Charts
IBarChart
Bars, in plain SVG with no charting dependency. It inherits the theme like everything else, so it follows light and dark for free.
| Category | Value |
|---|---|
| Jan | €18,200 |
| Feb | €22,400 |
| Mar | €19,800 |
| Apr | €27,600 |
| May | €31,200 |
| Jun | €29,900 |
The width fills the container and height (240px by default) is the only dimension you set. The value axis always includes zero and lands on round numbers, so ticks is a target count rather than an exact one.
Hovering a category raises a tooltip with the value formatted exactly as the ticks are: locale and format feed one Intl.NumberFormat used everywhere in the chart.
Horizontal
Turn the chart when the category names are long or numerous — a horizontal chart gives every name a full row.
| Category | Value |
|---|---|
| Direct | €41,200 |
| Partner referrals | €28,800 |
| Marketplace | €19,400 |
| Outbound | €12,100 |
Several series
Pass series to read more than one measure out of each datum. Each series names the key it reads and, optionally, how it should be labelled.
- North
- South
- East
| Category | North | South | East |
|---|---|---|---|
| Q1 | €18,200 | €12,400 | €9,100 |
| Q2 | €22,600 | €15,100 | €11,800 |
| Q3 | €20,100 | €17,400 | €14,200 |
| Q4 | €26,800 | €19,200 | €16,900 |
A legend appears automatically from two series up; legend is honoured only for a single series. When you filter series in and out, give each one a slot so its colour stays with the entity rather than with its position in the list.
Stacked
- North
- South
- East
| Category | North | South | East |
|---|---|---|---|
| Q1 | €18,200 | €12,400 | €9,100 |
| Q2 | €22,600 | €15,100 | €11,800 |
| Q3 | €20,100 | €17,400 | €14,200 |
| Q4 | €26,800 | €19,200 | €16,900 |
Stacking answers "what makes up the total"; grouping answers "how do these compare". The stacked tooltip adds a sum row, labelled by totalLabel.
Negative values
| Category | Value |
|---|---|
| Jan | €4,200 |
| Feb | -€1,800 |
| Mar | €3,100 |
| Apr | -€900 |
| May | €5,600 |
Bars below zero hang from the zero line rather than from the axis floor.
Bare bars
Drop the axis and gridlines for a chart that sits inside a tile, where the shape is the whole message.
| Category | Value |
|---|---|
| Jan | 18,200 |
| Feb | 22,400 |
| Mar | 19,800 |
| Apr | 27,600 |
| May | 31,200 |
| Jun | 29,900 |
Gaps
null is a missing reading, not a zero — no bar is drawn at all, which is not the same as a bar of no height.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | BarChartDatum[] | [] | One entry per category |
series | ChartSeries[] | — | Two or more measures per category |
orientation | 'vertical' | 'horizontal' | 'vertical' | Bars up, or categories down the side |
stacked | boolean | — | One bar per category instead of a group |
height | number | 240 | Rendered height in px; width fills the container |
ticks | number | 5 | Target tick count; the axis lands on round numbers |
axis | boolean | true | Draw the value axis and its gridlines |
legend | boolean | true | Only honoured for a single series |
totalLabel | string | 'Total' | Word for the stacked tooltip's sum |
locale | string | — | Locale for every number in the chart |
format | Intl.NumberFormatOptions | — | Options for every number in the chart |
label | string | — | Accessible name for the figure |
unstyled | boolean | — | Drop built-in classes |
class | string | — | Merged with the built-in classes |
ui | { root?, svg?, grid?, tick?, category?, bar?, tooltip?, tooltipLabel?, tooltipValue?, table? } | — | Per-slot class overrides |
Slots
| Slot | Props | When to use it |
|---|---|---|
underlay | layout geometry | Draw behind the bars — a target band, a shaded period |
overlay | layout geometry | Draw in front — an annotation, a threshold line |
Data shapes
interface BarChartDatum {
label: string
value?: number | null
[key: string]: unknown
}
interface ChartSeries {
key: string
name?: string
slot?: number
}The bars are hidden from assistive technology and the same data is exposed as a table, named by label.