Waffle chart reference
Contents: Use cases, Chart IDs, Minimal spec, Data, Options, Annotations, Sizing, Fixtures, Not for.
Share of a whole as a grid of square cells, one panel per category: label, headline total and whole-cell segments (largest-remainder rounding), filled from the bottom left. Type waffle.
Use cases
- One share of 100%, such as 30% of customers
- Several shares side by side with one baseline
- Stacked segments of one whole
Chart IDs
waffle.cells: fixturesingle-sharewaffle.square: fixtureshare-squares
Minimal spec
{
"type": "waffle",
"data": {
"categories": [{ "id": "high-spend", "label": "Share of high-spending customers out of all customers" }],
"series": [{ "id": "share", "label": "High spenders", "values": [30] }]
},
"options": { "title": "Three in ten customers are high spenders", "source": "Illustrative data" }
}Data
A cell is a number, null or a value object; see Value cell.
| Path | Type | Required | Meaning |
|---|---|---|---|
| valueKind | string | Default valueKind for all series. One of 'fraction'. | |
| categories | array | yes | Panels, one waffle each, in left-to-right order. |
| categories[].id | string | yes | Panel identity used to match keyed values. |
| categories[].label | string | Text above the panel, wrapped to the panel width; defaults to the category id. | |
| series | array | yes | Segments of every panel, filled in this order. One series is a single share; several make a stacked waffle. The values of one panel add up to 100 or less; the rest of the panel stays empty. Those rest cells use color.othersMark (default color.others), deepened just enough to clear the mark floor on the page, with no outline; marks.othersOutline does not apply to them. |
| series[].valueKind | string | Multiply numbers by 100 into pct cells; explicit pct cells stay in percent units. One of 'fraction'. | |
| series[].id | string | yes | Segment identity used by keyed values and legend entries. |
| series[].label | string | Segment name in the legend; defaults to the series id. | |
| series[].values | (cell | { categoryId, value: cell })[] | yes | Percent of the whole (0 to 100) in panel order, or keyed entries pairing a categoryId with a value. Under valueKind fraction, 0.3 reads 30%. |
| series[].colorRole | string | Theme color role of this segment; the palette is used when absent. One of good, bad, warn, neutral, neutralLight, highlight, total, others; series-N for step N of the theme ramp, 1-based (series-2 is color.series[1]); or status-<key> for a theme status color. A hex color goes in fill. | |
| series[].fill | string | Authored fill of this segment. | |
| series[].format | string | Format-by-example for this segment value, for example 0.0%. Values are in percent units. The panel total takes the format of the first series; a cell format wins for its own value. |
Options
| Path | Type | Values | Default | Meaning |
|---|---|---|---|---|
| grid | object | {"rows":10,"columns":10} | Cell grid of every panel. Default 10 rows by 10 columns, so one cell is 1%. One cell is 100 / (rows × columns) percent, and each segment is rounded to whole cells. | |
| grid.rows | integer | 10 | Rows of cells in every panel, 1 to 50. | |
| grid.columns | integer | 10 | Columns of cells in every panel, 1 to 50. | |
| fillFrom | string | 'bottom', 'top' | 'bottom' | Where the fill starts. 'bottom' (default) starts at the bottom left, fills each row left to right and moves up. 'top' starts at the top left and moves down. A partly filled row fills from the left. |
| headline | string | 'value', 'none' | Automatic: a single-segment panel prints its value as a big number; several segments print their values in the key or below each grid. Authored 'value' prints a labeled total for several segments, in the format of the series or options.format. 'none' leaves the headline out. | |
| heightFill | string | 'rows', 'none' | 'rows' | Spare canvas height of one panel with one series. 'rows' (default): a pinned canvas gives the grid the full plot height, with the value and the label beside the filled cells. 'none': the label, the value and the grid stack in a column. |
| cellNote | string | 'auto', 'none' | 'auto' (default) prints the note "One cell = 5%" under the chart when one cell is not 1% of the whole, so a coarse grid reads right. 'none' leaves it out. The wording comes from strings.cellNote, with '{value}' for the percent. | |
| variant | string | 'cells', 'square' | 'cells' | 'cells' (default) draws the grid of cells. 'square' draws one solid square per panel whose AREA is the share (side = square root of the share × panel side), anchored at the fillFrom corner on the left, inside a pale tint of the same color that stands for 100%. The headline prints under the panel. Square mode takes exactly one series (a nested second square would read as an L-shape, not a share) and refuses grid; there are no cells, so no cell note prints. Area understates differences (59% is 15 times 4% but only about 4 times as wide), so keep the headline. |
| reference | object | Square mode only. One reference share for ALL panels, drawn as a dashed square outline of that area in every panel (not in the reference panel itself) and named once in a key line above the panels (a note when legend is 'none' or a pinned size has no room). One reference keeps the outline meaning the same in every panel. | ||
| reference.categoryId | string | Panel whose share is the reference. Give this or value. | ||
| reference.value | number | Reference share in percent, above 0 and up to 100 (a 0% reference has no square to outline). Give this or categoryId. | ||
| reference.label | string | Outline label; default the panel label and its share, such as "Population 4%". Required with value, since a bare share does not say what it stands for (waffle-reference-label-required). | ||
| arrows | boolean | false | Square mode only. true draws an arrow in each gap between adjacent panels, at the height of the reference outline (or mid-panel without one). Default false: the panels are separate measures, and an arrow reads as a flow or a cause. | |
| panelGroups | array | Runs of panels that tell one act of the story: a caption under each run and one color per run. Members must exist, belong to at most one group, and be contiguous in category order. | ||
| panelGroups[].id | string | Group id. | ||
| panelGroups[].panels | array | Member panels, contiguous in category order. | ||
| panelGroups[].label | string | Caption centered under the group, wrapped to its width. | ||
| panelGroups[].colorRole | string | Fill color role of the group's panels; the series color otherwise. Needs a single series. One of good, bad, warn, neutral, neutralLight, highlight, total, others; series-N for step N of the theme ramp, 1-based (series-2 is color.series[1]); or status-<key> for a theme status color. A hex color goes in fill. | ||
| subtotal | object | Cells mode with one panel only. Sums the first segments and prints the sum with its label: beside a bracket that spans their rows when the key stands beside the grid, under the key otherwise. The sum takes the first series' format. | ||
| subtotal.series | array | The summed segments: the first series and the ones right after it, in series order. | ||
| subtotal.label | string | What the sum stands for, such as 'within a day'; printed after the sum. |
Plus the shared options. This type does not accept detailFields, labels, labelPosition, valueAxis.tickStep, valueAxis.log, valueAxis.reverse, valueAxis.break, highlight, story, hatchStrength, rounding, annotations. This type ignores animate, debug, rowLabels, categoryAxis, categoryLabels, secondaryAxis, sort, topN, bandFraction, valueAxis with an option-ignored warning.
Annotations
This type takes no annotations.
Sizing
Floor 240 × 200 px; fit content. Below 240 px wide or 200 px high, down to the compact floor of 160 × 160 px, the chart draws in compact mode; belowMinimum: 'refuse' refuses there instead.
Below the floor a render is refused with size-below-floor and the pixels it needs. measure returns the natural and comfortable size for a given spec; see Sizing in the manual.
Fixtures
| ID | Kind | Use case |
|---|---|---|
| single-share | example | One panel: 30% of customers, a label, a headline and a 10 by 10 grid |
| two-panels | example | Two panels with labels of different lengths: grids and headlines keep one baseline |
| stacked-segments | example | One panel with three segments: whole-cell rounding, values beside the grid, 13 empty cells and a subtotal bracket |
| fraction-input | example | Fractions of 1 under valueKind fraction, on a wide 5 by 20 grid |
| top-fill-no-headline | example | Fill from the top on a coarse 4 by 5 grid, no headline |
| coarse-grid-cell-note | example | A 4 by 5 grid: one cell is 5%, and the note says so in the host wording |
| seven-panels-narrow | torture | Torture: seven panels near the minimum cell size, a missing value, a value under half a cell and a full panel |
| share-squares | example | Square mode: five shares as solid squares in pale 100% squares, one dashed reference, two captioned groups |
| share-squares-arrows | example | Square mode with arrows on: three panels, a number reference with its label, arrows in the gaps at the outline height |
Not for
Levels or values that are not shares of a whole; waffle fills part of 100%. Use bar or column for levels, pie for slices of a total.