Waffle chart
A ten by ten unit chart where every cell is one percent, and cells fly to their new group when the data changes.
npx shadcn@latest add @silicon-ui/waffle-chartInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/waffle-chartManually
Install the dependencies
npm install motionCopy these files into your project
- components/silicon-ui/waffle-chart/waffle-chart.tsx
- components/silicon-ui/waffle-chart/waffle-chart.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
data*Categories in fill order. The first fills from the bottom-left corner, column by column. | WaffleCategory[] | — |
label*What the whole is, such as "Electricity generation, 2023". Names the chart for assistive technology. | string | — |
unitUnit after each raw value in the tooltip and table, such as "TWh". | string | "" |
formatValue | (value: number, category: WaffleCategory) => string | — |
rowsGrid rows. rows × columns cells make the whole; 10 × 10 means one cell per percent. | number | 10 |
columns | number | 10 |
accentKeyThe category painted in the accent. Pass null to keep every category neutral. Defaults to the first category. | string | null | — |
activeKeyControlled focused category. Others dim while one is focused. | string | null | — |
defaultActiveKey | string | null | null |
onActiveChange | (key: string | null) => void | — |
legendCategory list with shares that roll to their new value. | boolean | true |
decimalsDecimal places for shares. | number | 0 |
emptyLabel | string | "No data" |
ref | Ref<HTMLElement> | — |
className | string | — |
Dependencies
- npm
- motion
- Registry
- silicon-motion-tokens