Circle packing chart
A whole as circles packed inside each other, each as large as its value, or a list as one cloud of bubbles. Press a group to zoom in until it fills the chart; the hovered circle stays bright while the rest step back, and new data moves every circle from where it is.
Examples
Spend
Teams with their tools inside, coloured by team, with each team’s name on it. Press a team, or a tool in it, to zoom in until it fills the chart; CirclePackingPath above it, or Escape, zooms back out. Another month moves every circle from where it is.
Bubbles
Rows with no children pack into one cloud, each in the next of the chart’s colours. CirclePackingLegend adds a key of sizes.
Colour by value
colorKey colours each circle by a value of its own, a step of one colour above zero and another below, named by CirclePackingLegend.
Zoom
zoom and onZoomChange hold the part in view as the path of names to it, so controls of your own and the chart’s presses agree, and new data keeps it.
Installation
npx shadcn@latest add https://kinoui.com/r/circle-packing-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.tsxlib/chart-tiles.tscomponents/kino/separator.tsxlib/list-rows.tsxlib/grip.tslib/panel.tsxcomponents/kino/menu.tsxcomponents/kino/breadcrumb.tsxlib/chart-tree-path.tsxcomponents/kino/circle-packing-chart.tsx- Packages
@ui-sdk/core@ui-sdk/reactclass-variance-authorityd3-arrayd3-hierarchy- 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
CirclePackingChart
The chart: a <figure> named by label, which packs and draws the circles and holds the chart’s parts. The part in view fills its round window, with the name of each circle in it where it fits; a row with no children is a circle of its own. Other props go to the figure. The props from data to messages are the ones every chart takes, less those for a value axis, an order, patterns and a pick: a press zooms instead.
CirclePackingPath
The way back out, above the plot and under a legend at the top: Kino’s Breadcrumb, with a button for each part above the one in view, the whole first, and the part in view last. It is there before the first zoom too, so zooming never moves the plot, and a long path folds into a menu.
CirclePackingLegend
Under or over the plot: a key of three nested circles with the values their sizes stand for in the part in view, and with colorKey, the colour’s steps with the value at each edge. Pointing at a step brings its circles forward. The groups’ colours are ChartLegend’s.
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.
Data attributes
CSS variables
Accessibility
- The circles are one stop in the tab order: a slider over the circles in view, biggest first and each group before the circles inside it. The arrow keys step through them, Home and End go to the first and last, and each circle’s name, where it sits, its value and share, and its
colorKeyvalue are read as the slider’s value. - Enter or Space on a group zooms into it, and on a circle into the group around it, and the keys start again from the first circle there; once the tooltip is closed, Escape zooms back out.
CirclePackingPathis a row of buttons for the same, and each zoom is announced in a status region. - A hidden table holds every circle in view with the groups it sits in, its value, share and
colorKeyvalue, and the total, for screen readers and for copying. - Labels show only where they fit whole: near white or near black for a circle’s colour, and a group’s name on a chip of the page’s colours. A circle too small for one keeps its name and value in the tooltip, the table and the slider.
- Groups are named in the legend, on their circles and in the tooltip, and
colorKeyvalues in the tooltip and the legend’s steps, so none relies on colour alone. Forced colours draw each group’s circles in a system colour, and groups as a faint wash. - When the system asks for less motion, zooms and new data land at once, with no move, and only the circles’ and labels’ colours and opacity 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.