Waffle chart
Shares of a whole as a grid of squares that always add up, easier to count than slices. The hovered share stays bright while the rest dims, and new data turns each square to its new share in a wave.
Examples
New data
A hundred squares, dealt out so they always add up. Another range turns each square to its new share where it is, in a wave from the first, and the share under the pointer stays bright while the rest step back.
Total
total sets the whole the values are shares of. The squares past them are the remaining room, named by remainingLabel, which the tooltip and the table read like a share.
Columns
rows, columns and fill='columns' make a strip that fills up each column from the start, as a bar across does.
Patterns
patterns draws a pattern over each share after the first, so they tell apart in grey and in print.
Installation
npx shadcn@latest add https://kinoui.com/r/waffle-chart.json- Files
lib/dates.tslib/chart-math.tslib/chart-scale.tslib/chart-frame.tslib/refs.tslib/reduce-motion.tslib/resize.tslib/live.tsxlib/chart-live.tslib/chart-live-clock.tsxlib/scroll.tslib/swap.tsxlib/popup.tslib/glide.tsxlib/keys.tsxcomponents/kino/kbd.tsxcomponents/kino/tooltip.tsxlib/cut.tsxlib/number-format.tslib/roll.tsxlib/run-progress.tscomponents/kino/animated-number.tsxlib/announce.tscomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/controllable.tslib/chart-root.tsxlib/chart-state.tslib/chart-agent.tslib/chart-base.tsxlib/chart-cartesian-reader.tslib/chart-cartesian.tsxlib/chart-list.tsxlib/chart-list-reader.tslib/chart-tree-reader.tslib/chart-flow-reader.tslib/chart-grid-reader.tslib/highlight.tscomponents/kino/chart.tsxlib/chart-grid.tslib/placeholder.tslib/chart-cells.tsxcomponents/kino/waffle-chart.tsx- Packages
@ui-sdk/core@ui-sdk/reactclass-variance-authorityd3-array- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
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:
:root { --chart-1: oklch(0.42 0.1 248); --chart-2: oklch(0.53 0.12 222); --chart-3: oklch(0.6 0.11 185); --chart-4: oklch(0.65 0.17 132); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}.dark { --chart-1: oklch(0.6 0.15 255); --chart-2: oklch(0.7 0.13 222); --chart-3: oklch(0.79 0.13 185); --chart-4: oklch(0.82 0.15 128); --chart-5: oklch(0.72 0.154 106.7); --chart-accent: oklch(0.795 0.171 71.2);}API reference
WaffleChart
The chart: a <figure> named by label, which draws the squares and holds the chart’s parts. Other props go to the figure. The config’s keys are the shares, as a Donut chart’s are, so one swaps for the other. The props from data to messages are the ones every chart takes, less those for a value axis.
WAFFLE_REMAINING
The remaining room’s key, remaining, for selected, defaultSelected and onSelectedChange. No share takes it.
ChartTooltip
What is under the pointer or the focus, in the chart’s own words: on a chart with series, the values of the category or the time. It shows at once and slides from one to the next. Other props go to its popup.
ChartLegend
A toggle for each series that shows and hides it. Pointing at one, or focusing it, brings its series forward. Takes position, top or bottom.
ChartGroup
Charts inside it share the category under the pointer or the focus, by its key, so pointing at a day on one lights it on all of them.
Data attributes
CSS variables
Accessibility
- The squares are one stop in the tab order: a slider over the shares. The arrow keys step through them, Home and End go to the first and last, and each share’s name, value and share of the whole are read as the slider’s value.
- A hidden table holds every share’s value and share, with the remaining room and the total, for screen readers and for copying.
- Loading, an error and new data are announced in a status region.
- Each share is named in the legend and the tooltip, so none relies on colour alone;
patternsadds a pattern too. Forced colours draw each share in a system colour, and the remaining room as dashed outlines. - Any share above nothing takes at least one square, so it shows and the pointer can find it; the tooltip and the table give its exact share.
- When the system asks for less motion, the squares turn at once, with no wave, and only their colours fade.
- The chart is a
<figure>named bylabel. - Escape closes the tooltip and nothing above the chart.
- The legend’s toggles say whether each series shows. When every series is hidden, a button shows them all again and takes the focus.
For agents
What an agent reads on this example with snapshot(), and the actions it can call with act().
The Agent bridge page sets up snapshot() and act() in your app.