Waffle
Show shares of a whole as a grid of unit squares the reader can count, then highlight one category, resize the grid and bucket small categories into Other.
A waffle chart draws the whole as a grid of squares, one square per unit, and fills them by category. It reads directly: 16 of 100 squares is 16%. It suits a few shares when the audience should be able to count them.
Use a pie or donut when exact counts do not matter and you want direct slice labels. Use a bar chart when there are many categories or the values are not shares of a total.
A basic waffle
Set mark to "waffle", put the share on theta and the category on color. The grid is 10 by 10 by default. Values normalize to the grid by largest-remainder rounding, so the squares always sum exactly even when the shares are fractional.
{
"mark": "waffle",
"data": [
{
"source": "Coal",
"share": 35.2
},
{
"source": "Natural Gas",
"share": 22.5
},
{
"source": "Hydro",
"share": 14.8
},
{
"source": "Nuclear",
"share": 9.2
},
{
"source": "Renewables",
"share": 15.6
},
{
"source": "Oil & Other",
"share": 2.7
}
],
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal"
}
},
"chrome": {
"title": "Coal still generates about a third of the world's electricity",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent; shares round to whole cells."
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 6 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "waffle",
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal"
}
},
"chrome": {
"title": "Coal still generates about a third of the world's electricity",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent; shares round to whole cells."
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 6 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "waffle",
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal"
}
},
"chrome": {
"title": "Coal still generates about a third of the world's electricity",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent; shares round to whole cells."
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 6 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "waffle",
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal"
}
},
"chrome": {
"title": "Coal still generates about a third of the world's electricity",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent; shares round to whole cells."
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 6 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "waffle",
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal"
}
},
"chrome": {
"title": "Coal still generates about a third of the world's electricity",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent; shares round to whole cells."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Highlighting a category
highlight on the color channel takes a category name, keeps that category in color and mutes the rest. Use it when one share is the point and the others are context.
{
"mark": "waffle",
"data": [
{
"source": "Coal",
"share": 35.2
},
{
"source": "Natural Gas",
"share": 22.5
},
{
"source": "Hydro",
"share": 14.8
},
{
"source": "Nuclear",
"share": 9.2
},
{
"source": "Renewables",
"share": 15.6
},
{
"source": "Oil & Other",
"share": 2.7
}
],
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal",
"highlight": "Renewables"
}
},
"chrome": {
"title": "Renewables generated about 16 of every 100 kilowatt-hours",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent."
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 6 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "waffle",
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal",
"highlight": "Renewables"
}
},
"chrome": {
"title": "Renewables generated about 16 of every 100 kilowatt-hours",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent."
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 6 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "waffle",
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal",
"highlight": "Renewables"
}
},
"chrome": {
"title": "Renewables generated about 16 of every 100 kilowatt-hours",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent."
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 6 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "waffle",
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal",
"highlight": "Renewables"
}
},
"chrome": {
"title": "Renewables generated about 16 of every 100 kilowatt-hours",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent."
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 6 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": "waffle",
"encoding": {
"theta": {
"field": "share",
"type": "quantitative"
},
"color": {
"field": "source",
"type": "nominal",
"highlight": "Renewables"
}
},
"chrome": {
"title": "Renewables generated about 16 of every 100 kilowatt-hours",
"subtitle": "Share of global electricity generation, 2023. Each square is one percent."
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Grid size
units sets the total number of squares and columns sets how many sit in each row, with rows derived as units / columns. These are mark options, so the mark becomes an object. Here 50 units in 10 columns make a 5 by 10 grid where each square is two percent.
{
"mark": {
"type": "waffle",
"units": 50,
"columns": 10
},
"data": [
{
"category": "Healthcare",
"spending": 24
},
{
"category": "Social Security",
"spending": 21
},
{
"category": "Defense",
"spending": 13
},
{
"category": "Net Interest",
"spending": 13
},
{
"category": "All Other",
"spending": 29
}
],
"encoding": {
"theta": {
"field": "spending",
"type": "quantitative"
},
"color": {
"field": "category",
"type": "nominal"
}
},
"chrome": {
"title": "Fifty cells make each square two percent",
"subtitle": "Share of federal spending by category, fiscal year 2024"
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: ChartSpec = {
"mark": {
"type": "waffle",
"units": 50,
"columns": 10
},
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"encoding": {
"theta": {
"field": "spending",
"type": "quantitative"
},
"color": {
"field": "category",
"type": "nominal"
}
},
"chrome": {
"title": "Fifty cells make each square two percent",
"subtitle": "Share of federal spending by category, fiscal year 2024"
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: ChartSpec = {
"mark": {
"type": "waffle",
"units": 50,
"columns": 10
},
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"encoding": {
"theta": {
"field": "spending",
"type": "quantitative"
},
"color": {
"field": "category",
"type": "nominal"
}
},
"chrome": {
"title": "Fifty cells make each square two percent",
"subtitle": "Share of federal spending by category, fiscal year 2024"
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: ChartSpec = {
"mark": {
"type": "waffle",
"units": 50,
"columns": 10
},
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"encoding": {
"theta": {
"field": "spending",
"type": "quantitative"
},
"color": {
"field": "category",
"type": "nominal"
}
},
"chrome": {
"title": "Fifty cells make each square two percent",
"subtitle": "Share of federal spending by category, fiscal year 2024"
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: ChartSpec = {
"mark": {
"type": "waffle",
"units": 50,
"columns": 10
},
"data": [/* 5 rows, as in the Spec tab; Copy includes them */],
"encoding": {
"theta": {
"field": "spending",
"type": "quantitative"
},
"color": {
"field": "category",
"type": "nominal"
}
},
"chrome": {
"title": "Fifty cells make each square two percent",
"subtitle": "Share of federal spending by category, fiscal year 2024"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Bucketing small categories
other on the mark folds categories below a share threshold into one trailing category. other: 0.05 folds everything under 5%, and the object form { threshold, label } renames the bucket. It is off by default, because bucketing is an editorial decision.
{
"mark": {
"type": "waffle",
"other": {
"threshold": 0.05,
"label": "Other emitters"
}
},
"data": [
{
"country": "China",
"emissions": 12600
},
{
"country": "United States",
"emissions": 4500
},
{
"country": "India",
"emissions": 3000
},
{
"country": "Russia",
"emissions": 1900
},
{
"country": "Japan",
"emissions": 1000
},
{
"country": "Germany",
"emissions": 620
},
{
"country": "South Korea",
"emissions": 590
},
{
"country": "Iran",
"emissions": 580
},
{
"country": "Canada",
"emissions": 530
},
{
"country": "Indonesia",
"emissions": 490
},
{
"country": "Saudi Arabia",
"emissions": 480
},
{
"country": "Turkey",
"emissions": 420
}
],
"encoding": {
"theta": {
"field": "emissions",
"type": "quantitative"
},
"color": {
"field": "country",
"type": "nominal"
}
},
"chrome": {
"title": "Countries under 5% fold into one category",
"subtitle": "Annual CO₂ emissions among the top twelve emitters, 2024"
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "waffle",
"other": {
"threshold": 0.05,
"label": "Other emitters"
}
},
"encoding": {
"theta": {
"field": "emissions",
"type": "quantitative"
},
"color": {
"field": "country",
"type": "nominal"
}
},
"chrome": {
"title": "Countries under 5% fold into one category",
"subtitle": "Annual CO₂ emissions among the top twelve emitters, 2024"
}
};
export function Example() {
return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "waffle",
"other": {
"threshold": 0.05,
"label": "Other emitters"
}
},
"encoding": {
"theta": {
"field": "emissions",
"type": "quantitative"
},
"color": {
"field": "country",
"type": "nominal"
}
},
"chrome": {
"title": "Countries under 5% fold into one category",
"subtitle": "Annual CO₂ emissions among the top twelve emitters, 2024"
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "waffle",
"other": {
"threshold": 0.05,
"label": "Other emitters"
}
},
"encoding": {
"theta": {
"field": "emissions",
"type": "quantitative"
},
"color": {
"field": "country",
"type": "nominal"
}
},
"chrome": {
"title": "Countries under 5% fold into one category",
"subtitle": "Annual CO₂ emissions among the top twelve emitters, 2024"
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 12 rows, as in the Spec tab; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "waffle",
"other": {
"threshold": 0.05,
"label": "Other emitters"
}
},
"encoding": {
"theta": {
"field": "emissions",
"type": "quantitative"
},
"color": {
"field": "country",
"type": "nominal"
}
},
"chrome": {
"title": "Countries under 5% fold into one category",
"subtitle": "Annual CO₂ emissions among the top twelve emitters, 2024"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Fields that matter
| Field | What it does |
|---|---|
mark |
"waffle", or an object that sets units, columns and other. |
mark.units |
Total number of squares. Default 100. |
mark.columns |
Squares per row. Default 10. |
mark.other |
A threshold as a fraction, or { threshold, label }, that folds small categories into one. |
encoding.theta |
The quantitative share of each category. |
encoding.color |
The category. highlight singles one out. |
Related
- Pie and donut for shares with direct slice labels.
- Parliament for countable seats in a hemicycle.
- Stacked 100% for shares across several wholes.
- Bar for categories that are not shares of a total.
- Marks reference lists the channels and options each mark type takes.