Waffle chart
A hundred cells, each one percent of the whole, filled with each part's share so a reader can count it.
On this page
A waffle is a square of a hundred cells, each one percent of the whole, filled row by row from the foot with each series' share. A share is read by counting, which a reader does more truly than they judge the angle of a slice, so a waffle suits a whole whose parts are told to the percent: nine in a hundred.
Waffle chart
<div class="card max-w(480) mx-auto"> <div class="card-header"> <h3 class="card-title">Browsers</h3> <p class="card-description">Share of sessions this month</p> </div> <figure class="chart chart-split" id="cells" style="--chart-size: 10rem"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('cells'), { type: 'waffle', label: 'Share of sessions by browser, in percent', format: function (value) { return value + '%' }, series: [ { name: 'Chrome', value: 58 }, { name: 'Safari', value: 24 }, { name: 'Firefox', value: 9 }, { name: 'Edge', value: 6 }, { name: 'Other', value: 3 } ]})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(480) mx-auto"> <div className="card-header"> <h3 className="card-title">Browsers</h3> <p className="card-description">Share of sessions this month</p> </div> <Chart className="chart-split" id="cells" style={{ '--chart-size': '10rem' } as React.CSSProperties} type="waffle" label="Share of sessions by browser, in percent" format={function (value) { return value + '%' }} series={[ { name: 'Chrome', value: 58 }, { name: 'Safari', value: 24 }, { name: 'Firefox', value: 9 }, { name: 'Edge', value: 6 }, { name: 'Other', value: 3 } ]} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(480) mx-auto"> <div class="card-header"> <h3 class="card-title">Browsers</h3> <p class="card-description">Share of sessions this month</p> </div> <Chart class="chart-split" id="cells" style="--chart-size: 10rem" type="waffle" label="Share of sessions by browser, in percent" format={function (value) { return value + '%' }} series={[ { name: 'Chrome', value: 58 }, { name: 'Safari', value: 24 }, { name: 'Firefox', value: 9 }, { name: 'Edge', value: 6 }, { name: 'Other', value: 3 } ]} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(480) mx-auto"> <div class="card-header"> <h3 class="card-title">Browsers</h3> <p class="card-description">Share of sessions this month</p> </div> <Chart class="chart-split" id="cells" style="--chart-size: 10rem" type="waffle" label="Share of sessions by browser, in percent" :format="function (value) { return value + '%' }" :series="[ { name: 'Chrome', value: 58 }, { name: 'Safari', value: 24 }, { name: 'Firefox', value: 9 }, { name: 'Edge', value: 6 }, { name: 'Other', value: 3 } ]" /> </div></template>Shares are rounded so that they fill the hundred exactly: every share is rounded down, and the cells left over go to the largest fractions. A part under half a percent may get no cell; it stays in the legend with its share. --chart-size is the square's width, and chart-split stands the legend beside it.
#Options
| Option | Default | |
|---|---|---|
label | none | What the chart shows and in what unit: the plot's accessible name |
series | [] | Each with a name and what its form reads: values, a value, points, ranges or children; optionally a category, a type, low and high, and a ring's max |
format, tickFormat | the locale's | How a value and a tick are written; xFormat for a scatter's scale across |
current | none | The index of the point marked aria-current |
legend, toggle | with two series, true | Whether a legend is written, and whether its entries are checkboxes |
The readout, the keys, the legend, the colors and the scale are the same in every form: Chart holds them, with every option, class and custom property.