Skip to contentKino
Skip to Content

Chart

The parts every chart is built from, such as the grid, the axes, a tooltip that slides between categories, a legend that shows and hides series, reference lines and bands, and Kino’s chart colours.

npx shadcn add https://kinoui.com/r/chart.json
Share on

Examples

Notes each day

The last two weeks, against the goal of 90 to 130 a day.
Goal
Launch
CategoryNotes
16 Oct110
17 Oct103
18 Oct102
19 Oct51
20 Oct49
21 Oct95
22 Oct114
23 Oct98
24 Oct73
25 Oct77
26 Oct72
27 Oct72
28 Oct112
29 Oct108

Reference lines and bands

ChartReferenceLine marks a value, one worked out from the data such as the average, or a category; ChartReferenceArea shades a range. The value axis reaches far enough to show them.

Notes by platform

Each platform has its own pattern as well as its colour.
CategoryWebiOSAndroid
Sun 8 November705529
Mon 9 November1547360
Tue 10 November1887666
Wed 11 November1658865
Thu 12 November1768870
Fri 13 November17012666
Sat 14 November775327

Patterns

patterns gives each series after the first a pattern over its colour, so the series differ by more than colour. The legend shows and hides them.

Notes by project

Every note in the Kino workspace, by project.
CategoryNotes
Lisbon cafés128
Kestrel Bakery64
Harbour market92
Night buses37

Axis titles

An axis takes a label, and side puts it at either edge: here the values sit at the end.

Notes by project

The notes couldn’t load, so the chart says why and offers to try again.

The notes couldn’t load. Check your connection.

Error

error says the data couldn’t load, and onRetry adds a button that tries again. loading shows a placeholder the bars grow out of.

Installation

npx shadcn@latest add https://kinoui.com/r/chart.json
Files
lib/reduce-motion.tslib/scroll.tslib/refs.tslib/resize.tslib/swap.tsxlib/popup.tslib/glide.tsxcomponents/kino/tooltip.tsxlib/cut.tsxlib/announce.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/chart-math.tslib/controllable.tslib/number-format.tslib/chart-core.tsxlib/run-progress.tslib/highlight.tscomponents/kino/chart.tsx
Packages
@base-ui/reactclass-variance-authorityd3-array

New to Kino? Installation covers what your project needs first and the @kino namespace.

The CLI keeps any of these colours your project already has, such as the chart colours shadcn init writes. To use Kino’s, set them in your global CSS:

globals.css
:root {  --chart-1: oklch(0.62 0.16 250);  --chart-2: oklch(0.54 0.18 257);  --chart-3: oklch(0.47 0.21 263);  --chart-4: oklch(0.4 0.19 268);  --chart-5: oklch(0.33 0.15 272);}.dark {  --chart-1: oklch(0.82 0.09 245);  --chart-2: oklch(0.74 0.13 250);  --chart-3: oklch(0.67 0.17 257);  --chart-4: oklch(0.61 0.19 263);  --chart-5: oklch(0.55 0.2 268);}

API reference

ChartYAxis

PropTypeDefaultDescription
side'start''end''start'Which edge it sits on.
labelReactNodeNoneThe axis’s title, such as its unit.
formatIntl.NumberFormatOptions(value: number) => stringNoneHow its values are written.
categoryFormat(value: unknown) => stringNoneHow its categories are written.

ChartTooltip

PropTypeDefaultDescription
totalbooleanNoneAdds a row with the total; on when the series stack.
children(item: { index, category }) => ReactNodeNoneWhat it shows; ChartTooltipContent by default, which yours can wrap.

ChartReferenceLine

PropTypeDefaultDescription
valuenumber'average''median''min''max'NoneThe value to mark, or one worked out from the shown data.
categorystringNoneThe key of a category to mark, in place of a value.
labelReactNode(value: number) => ReactNodeNoneWhat it says. It crossfades when it changes.
labelPosition'start''end''end'Which end of the line the label sits at.

Data attributes

AttributeOnDescription
data-mountedThe chartSet a frame after first paint; nothing moves before it.
data-resizingThe chartWhile its size changes, so nothing in it eases.

CSS variables

VariableSet it onDefaultDescription
--chart-1 … --chart-5Your themeKino’s blues, unless your project has its ownThe series’ colours, in order. Installing the Chart adds Kino’s, each at least 3:1 on the background in light and dark, but the CLI keeps any your project already has, such as the ones shadcn init writes. Installation, above, has Kino’s to copy.

Accessibility

  • The chart is a <figure> named by label, with a hidden table of every value.
  • The plot is one stop in the tab order, a slider over the categories, as the WAI-ARIA slider pattern has it. Escape closes the tooltip and nothing above the chart.
  • Loading, an error and new data are announced in a status region that is there before the words arrive.
  • The legend’s toggles say whether each series shows. When every series is hidden, a button shows them all again and takes the focus.
  • With patterns, series differ by more than colour, and forced colours draw each series in a system colour.