Skip to content
InsightCharts

Search

Search guides and components

Waffle chart

Shows shares of a whole as counted cells in a grid, such as 37 in every 100.

Use when
One share ("37 in every 100") or a handful of categories that add up to a whole, where the reader should be able to count the units.
Avoid when
Comparing shares across several groups (use bar chart with stack "percent"); more than about 6 categories or shares under 1% (use bar chart); a compact inline part-to-whole (use segmented bar).

Preview

33% of the world's population had never used the internet in 2023

Share of the global population, 2023. Each square is 1% of people

Source: ITU Facts and Figures 2023 · Figures are approximate, for illustration

Composition

Used in

3 molecules and 3 templates use waffle chart.

Molecules

3

The sheet an infographic is composed on. It paints a full-bleed ground from a poster theme, forces one theme and colour mode on everything inside, and lays out a masthead, a grid of panels and a footer. It can save the whole sheet as one PNG.

A share stated as a countable sentence ("37 in every 100…"): a waffle grid or a row of icons beside the statement in large type, with the number emphasised.

Repeats any chart spec once per value of a facet field, each panel with its own filtered rows and a title, in a grid that follows the container width.

Templates

3

A graphic that states one fact, at a fixed aspect ratio (1:1, 4:5, 16:9 or 9:16). It has a kicker, a headline, one exhibit, a source and a credit, painted on the theme surface. A button downloads the whole card as a PNG.

A vertical infographic in one narrow column. It opens with a big number or a proportion statement (hook), then the hero exhibit, then numbered sections with one exhibit each, a conclusion with an optional link, and sources.

A long article read by scrolling. It has a headline, then an ordered list of blocks in a reading column, then a source note. The blocks are prose, figures, charts with a callout, scrolly sequences, pull quotes, stat rows, small multiples and chapter breaks. Exhibits can be wider than the column.

Installation

$ pnpm dlx shadcn@latest add @insightcharts/waffle-chart

The CLI copies the source into your project and needs the @insightcharts registry in components.json; see installation. With the package, import it by name:

import { WaffleChart } from "insightcharts";

Examples

Several categories

Coal and gas generated 57.9% of the world's electricity in 2023

Share of global electricity generation by source, 2023

Source: Ember, Global Electricity Review 2024 · Figures are approximate, for illustration

Highlight, circles

Wind and solar generated 13.3% of the world's electricity in 2023

Share of global electricity generation by source, 2023

Source: Ember, Global Electricity Review 2024 · Figures are approximate, for illustration

Stress: long names, wide grid, rounding

Survey responses on extending the policy, 1,004 adults

Each cell is 1% of responses. Largest-remainder rounding keeps the grid total at 100

Source: Illustrative data

Props

PropTypeDefaultDescription
valuerequiredstringValue field. Each category's cells are its share of the whole.
namestringCategory field. Omit for a single share.
totalnumberThe whole. Default: the sum of the values. Set to 100 with one value to show a single share against an empty remainder.
rowsnumber10Grid rows.
columnsnumber10Grid columns.
shape"square" | "circle""square"Cell shape.
restLabelstringLabel for the unfilled remainder when total exceeds the sum.
namesRecord<string, string>Display names for category keys.
Common chart props 29

Every chart built with defineChart accepts these on top of its own props.

PropTypeDescription
dataDataInputRows, CSV text, a URL, { url, path }, an async function, or an Arrow-style table. Omit inside <InsightData>.
transformTransform | Transform[]A pipeline of transforms applied before drawing.
titlestringThe title. One plain statement of what the data shows, with the number and the period ("Monthly churn fell from 4.2% to 2.1% in 2024"), or a plain label ("Monthly churn, 2024"). One clause, no figures of speech.
subtitlestringMeasure, unit, population, period.
sourcestringData source, shown as "Source: ...".
notestringMethod notes or caveats.
heightnumber | stringCSS height of the plot. Default 360.
aspectnumberWidth / height. Overrides height.
highlightstring | string[]The entity (or entities) the title is about. Every other series is drawn in grey.
annotationsAnnotation[]Reference lines, shaded bands and callouts, in data coordinates.
formatFormatSpecHow to print values: "compact", "percent", "currency:USD", "{value} kg", Intl options, or a function.
legendbooleanShow the legend. Default: shown when there are two or more series.
selectboolean | stringMake marks clickable to filter. Inside <InsightData> the selection filters every other chart. Pass a field name, or true to use the chart's category field.
onSelect(values: string[], field: string) => voidCalled with the selected values whenever the selection changes.
optionEChartsOption | ((option: EChartsOption, ctx: BuildContext) => EChartsOption)Deep-merged over the generated ECharts option, or a function that receives and returns it. Use it for ECharts settings no prop covers.
themeThemeInputA theme, or a partial set of tokens merged over the surrounding theme, for this chart only.
modeModeInput"auto" (default) follows the page, "system" follows the OS, or force "light" / "dark".
rendererRendererInput"auto" (default) uses SVG for light charts and canvas for heavy ones.
animatebooleanSet false to disable animation. Reduced-motion preferences are always respected.
lazybooleanMount the chart only when it scrolls near the viewport. Default true.
groupstringLink tooltips with other charts sharing this group id.
exportableboolean | ExportFormat[]Show an export menu: true or a list of formats from png, jpeg, svg, pdf, csv, json.
tablebooleanShow a collapsible "View data" table under the chart.
altstringAccessible description: the chart type and measures, then the main pattern and the notable values.
idstringStable id for this chart's selection in the shared store.
onEventsRecord<string, ChartEventHandler>ECharts event handlers, e.g. { click: (params, chart) => {} }. Prefix a name with zr: to bind to the canvas itself.
onReady(chart: EChartsInstance) => voidCalled with the ECharts instance once it is created.
classNamestringClass name for the outer <figure>.
styleCSSPropertiesInline style for the outer <figure>.