Waffle chart — pure SVG, zero JS.
Renders a 10x10 grid of cells filled proportionally per category. Each cell represents 1% of the total when using default 10x10 grid.
Examples
<.waffle_chart data={[
%{label: "Chrome", value: 65},
%{label: "Firefox", value: 20},
%{label: "Safari", value: 15}
]} />
<.waffle_chart
data={[%{label: "Yes", value: 72}, %{label: "No", value: 28}]}
colors={["oklch(0.60 0.20 240)", "oklch(0.60 0.25 0)"]}
cell_size={24}
cell_gap={3}
/>
Summary
Functions
Attributes
data(:list) - Category data:[%{label, value}]. Defaults to[].colors(:list) - Override default palette. CSS color strings. Defaults to[].cell_size(:integer) - Size of each cell in pixels. Defaults to20.cell_gap(:integer) - Gap between cells in pixels. Defaults to2.rows(:integer) - Number of rows in the grid. Defaults to10.cols(:integer) - Number of columns in the grid. Defaults to10.animate(:boolean) - Enable entrance animations. Defaults totrue.animation_duration(:integer) - Animation duration in ms. Defaults to600.theme(:map) - Chart theme overrides (see ChartTheme). Defaults to%{}.id(:string) - Unique ID for the chart (auto-generated if not provided). Defaults tonil.title(:string) - Chart title rendered above the visualization. Defaults tonil.description(:string) - Chart description for context (rendered below title). Defaults tonil.class(:string) - Defaults tonil.- Global attributes are accepted.