Appearance
Charts > Waffle chart
A waffle chart is a visual representation of data using a grid of small equal-sized squares or rectangles, where each unit typically represents a
The Chart
Other compatible charts
Download example CSV
Copy HTML
Playground
Animation
Duration of animation in ms
Style
Colors for areas
Show percentages next to chart
Rounding of corners of squares
Space between squares
Component API
This chart is built using SVG and d3, and GSAP for animation.
It consists of 100 squares and each square represents 1% of data. Each color is a category. Since only whole squares can be colored, the values are rounded and there might be rounding errors (sum is 99 or 101). In these cases, a percentage point is added or subtracted from the biggest category. In the future we should make this more precise and support drawing partial squares.
Data
Values are percentages.
js
[
{
id: "data-1",
name: "Data 1",
values: {
val1: {
id: "val-1",
name: "Val 1",
value: 75,
count: 3,
color: "#eee",
},
val2: {
id: "val-2",
name: "Val 2",
value: 25,
count: 1,
color: "#ccc",
},
},
},
];Props
| Name | Default | Type | Description |
|---|---|---|---|
data | [] | Array | The dataset |
padding | 0.1 | Number | The space between squares |
borderRadius | 3 | Number | The rounding of squares |
showValues | true | Boolean | Whether or not to show value labels |
showLabels | false | Boolean | Whether or not to show category labels |
showCount | false | Boolean | Whether or not to show count labels |
marginRight | 10 | Number | The space between chart and labels |
hasFlyAnimation | true | Boolean | Whether or not to show animation on enter |
duration | 1.5 | Number | The total time of the animation in seconds |
Dependencies
- d3
- GSAP