Waffle chart Since 0.9.2
Display values as a percentage of a whole in an aesthetically pleasing way. A nicer alternative to pie charts.
Usage
To use this component in a Nunjucks template you would add the following (assumes you've loaded OI Lume Viz into componentNamespace: 'oi'
):
{% comp 'oi.chart.waffle', { "config": config } %}{% endcomp %}
where config
is replaced by an object that contains some or all of these variables:
data
- Either a reference to a CSV file in the Lume site or an array of rows with named attributescolumns
- As with many of the visualisation types you can optionally add virtual columns.colours
- Define some visualisation-specific named colours.width
- Set a specific width for the visualisation.height
- Set a specific height for the visualisation.series
- An ordered array of series. Each one is of the form:value
- The title of the column to use for the value.colour
- The hex code to use to colour this series.tooltip
- Either a string, template string, or the column heading to use to build a tooltip.points
- Properties of the points:size
- The size of the point.marker
- One ofcircle
,triangle
,square
,diamond
,pentagon
,hexagon
,octagon
,line
, orcross
. Alternatively you could set a sub-propertysvg
that is an SVG image as a string.rotate
- How much to rotate the marker around its centre by, in degrees.
total
- The name of the column that contains a total value. If not provided it will be guessed from the sum of the series values.padding
- Set the padding between cells of the waffle.size
- Set the grid size of the waffle. The default is10
which gives a 10x10 waffle. You can also specify an array with two values e.g.[20,5]
to set waffle grid horizontally and verticallyrounding
- By default the values are rounded usingMath.round()
but we can choose to useMath.floor()
by settingrounding
tofloor
(you could also useceil
).direction
- By default, thedirection
is set tol2r
which means that values fill in from the left. If we setdirection
tor2l
it will fill values from the right.gravity
- By default, thegravity
is set tobottom
which means that values start at the bottom and build upwards. We can also setgravity
totop
,left
orright
.attribution
- Add a line of attribution text under the visualisation.
Examples
- Basic waffle chart
- Set padding
- Set width/height
- Set waffle grid size
- Set waffle grid size in both dimensions
- Set the rounding type
- Set direction
- Set gravity direction
- Add tooltips
- Add legend
- Show multiple series
- Change the markers
- Custom marker icons
- Set the empty markers
1. Basic waffle chart§
This is a basic waffle chart showing the percentage of people aged 75 and over who have had the 2023 Spring Booster of the COVID-19 vaccination in England (data from UK Health Security Agency). In this example the series→value
is already given as a percentage.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91"
}]
}
2. Set padding§
We can set the padding
between cells of the waffle.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
padding: 16
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91"
}],
"padding": 16
}
3. Set width/height§
By default the waffle chart is 1080px across but we can set the width
and/or height
of the waffle to other values if we wish.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
width: 300
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91"
}],
"width": 300
}
4. Set waffle grid size§
We can set the size
, in grid cells, of the waffle grid.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
size: 5
width: 300
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91"
}],
"size": 5,
"width": 300
}
5. Set waffle grid size in both dimensions§
We can set the size
, in grid cells, of the waffle grid horizontally and vertically.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
size:
- 20
- 5
width: 300
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91"
}],
"size": [
20,
5
],
"width": 300
}
6. Set the rounding type§
By default the values are rounded using Math.round()
but we can choose to use Math.floor()
by setting rounding
to floor
(you could also use ceil
). In this example it will mean 67 waffle cells are coloured in rather than 68.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
width: 300
rounding: floor
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91"
}],
"width": 300,
"rounding": "floor"
}
7. Set direction§
By default, the direction
is set to l2r
which means that values fill in from the left. If we set direction
to r2l
it will fill values from the right.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
direction: rtl
width: 300
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91"
}],
"direction": "rtl",
"width": 300
}
8. Set gravity direction§
By default, the gravity
is set to bottom
which means that values start at the bottom and build upwards. We can also set gravity
to top
, left
or right
.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
gravity: top
width: 300
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91"
}],
"gravity": "top",
"width": 300
}
9. Add tooltips§
In this example we will build a custom tooltip
for the series
. This can either refer to a column/virtual column in the data or be a string template.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
series:
- value: Percentage of people aged 75+
colour: '#019c91'
tooltip: >-
Aged 75+
People: {{ Total vaccinated aged 75+ | toLocaleString() }} ({{ Percentage
of people aged 75+ }}%)
width: 300
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"series": [{
"value": "Percentage of people aged 75+",
"colour": "#019c91",
"tooltip": "Aged 75+\nPeople: {{ Total vaccinated aged 75+ | toLocaleString() }} ({{ Percentage of people aged 75+ }}%)"
}],
"width": 300
}
10. Add legend§
In this example, along with defining a width
and creating a tooltip
, we will add a legend
to position→top
.
This example was made with config
:
data:
- Total vaccinated aged 75+: 3725152
Percentage of people aged 75+: 67.9
columns:
- name: Tooltip
template: >-
Aged 75+
People: {{ Total vaccinated aged 75+ | toLocaleString() }} ({{ Percentage
of people aged 75+ }}%)
series:
- title: Aged 75+ vaccinated
value: Percentage of people aged 75+
colour: '#019c91'
tooltip: Tooltip
width: 300
legend:
show: true
position: top
{
"data": [{
"Total vaccinated aged 75+": 3725152,
"Percentage of people aged 75+": 67.9
}],
"columns": [{
"name": "Tooltip",
"template": "Aged 75+\nPeople: {{ Total vaccinated aged 75+ | toLocaleString() }} ({{ Percentage of people aged 75+ }}%)"
}],
"series": [{
"title": "Aged 75+ vaccinated",
"value": "Percentage of people aged 75+",
"colour": "#019c91",
"tooltip": "Tooltip"
}],
"width": 300,
"legend": {
"show": true,
"position": "top"
}
}
11. Show multiple series§
In this example we show the gender breakdown of appearances on Channel 4's Taskmaster as of the end of series 15. We will create a tooltip
for each series
as virtual columns. In this example the data consists of appearances rather than percentages so we define a total
key (to the column Total
) in order to scale the values into percentages.
This example was made with config
:
data:
- Female: 283
Male: 675
Other/diverse: 10
Total: 968
total: Total
columns:
- name: F tooltip
template: >-
Appearances: female
{{ Female | toLocaleString() }} ({{ Female | multiply(100 / Total) |
toFixed(1) }}%)
- name: M tooltip
template: >-
Appearances: male
{{ Male | toLocaleString() }} ({{ Male | multiply(100 / Total) |
toFixed(1) }}%)
- name: O tooltip
template: >-
Appearances: diverse/non-binary genders
{{ Other/diverse | toLocaleString() }} ({{ Other/diverse | multiply(100 /
Total) | toFixed(1) }}%)
series:
- value: Female
colour: '#722EA5'
tooltip: F tooltip
- value: Male
colour: '#0dbc37'
tooltip: M tooltip
- value: Other/diverse
colour: '#fac900'
tooltip: O tooltip
size:
- 20
- 5
legend:
show: true
position: top
{
"data": [{
"Female": 283,
"Male": 675,
"Other/diverse": 10,
"Total": 968
}],
"total": "Total",
"columns": [{
"name": "F tooltip",
"template": "Appearances: female\n{{ Female | toLocaleString() }} ({{ Female | multiply(100 / Total) | toFixed(1) }}%)"
},{
"name": "M tooltip",
"template": "Appearances: male\n{{ Male | toLocaleString() }} ({{ Male | multiply(100 / Total) | toFixed(1) }}%)"
},{
"name": "O tooltip",
"template": "Appearances: diverse/non-binary genders\n{{ Other/diverse | toLocaleString() }} ({{ Other/diverse | multiply(100 / Total) | toFixed(1) }}%)"
}],
"series": [{
"value": "Female",
"colour": "#722EA5",
"tooltip": "F tooltip"
},{
"value": "Male",
"colour": "#0dbc37",
"tooltip": "M tooltip"
},{
"value": "Other/diverse",
"colour": "#fac900",
"tooltip": "O tooltip"
}],
"size": [
20,
5
],
"legend": {
"show": true,
"position": "top"
}
}
12. Change the markers§
In this example we will set the points→marker
values for each series
. These can be one of circle
, triangle
, square
, diamond
, pentagon
, hexagon
, octagon
, line
, or cross
. Each can have an optional rotate
value set (in degrees) to rotate the shape.
This example was made with config
:
data:
- Triangles: 25
Hexagons: 60
Crosses: 15
total: 100
width: 300
columns:
- name: triangle tooltip
template: 'Triangles: {{ Triangles | toLocaleString() }}'
- name: hexagon tooltip
template: 'Hexagons: {{ Hexagons | toLocaleString() }}'
- name: cross tooltip
template: 'Crosses: {{ Crosses | toLocaleString() }}'
series:
- value: Triangles
colour: '#722EA5'
tooltip: triangle tooltip
points:
marker: triangle
rotate: 30
- value: Hexagons
colour: '#0dbc37'
tooltip: hexagon tooltip
points:
marker: hexagon
- value: Crosses
colour: '#fac900'
tooltip: cross tooltip
points:
marker: cross
legend:
show: true
position: top
{
"data": [{
"Triangles": 25,
"Hexagons": 60,
"Crosses": 15
}],
"total": 100,
"width": 300,
"columns": [{
"name": "triangle tooltip",
"template": "Triangles: {{ Triangles | toLocaleString() }}"
},{
"name": "hexagon tooltip",
"template": "Hexagons: {{ Hexagons | toLocaleString() }}"
},{
"name": "cross tooltip",
"template": "Crosses: {{ Crosses | toLocaleString() }}"
}],
"series": [{
"value": "Triangles",
"colour": "#722EA5",
"tooltip": "triangle tooltip",
"points": {
"marker": "triangle",
"rotate": 30
}
},{
"value": "Hexagons",
"colour": "#0dbc37",
"tooltip": "hexagon tooltip",
"points": {
"marker": "hexagon"
}
},{
"value": "Crosses",
"colour": "#fac900",
"tooltip": "cross tooltip",
"points": {
"marker": "cross"
}
}],
"legend": {
"show": true,
"position": "top"
}
}
13. Custom marker icons§
In this example we show the breakdown of operating system share Mar 2023. We will create a tooltip
for each series
as virtual columns. In this example the data consists of appearances rather than percentages so we define a total
in order to scale the values into percentages. We can set custom points→marker
values for each series
using SVG icons copied from Bootstrap icons. Note that because each series is rounded to the nearest whole bin, the totals don't add up to 100%.
This example was made with config
:
data:
- microsoft: 28.32
apple: 24.33
android: 41.48
linux: 1.17
other: 1.65
unknown: 3.07
total: 100
columns:
- name: microsoft tooltip
template: 'Windows: {{ microsoft | toLocaleString() }}%'
- name: apple tooltip
template: 'iOS/macOS: {{ apple | toLocaleString() }}%'
- name: android tooltip
template: 'Android: {{ android | toLocaleString() }}%'
- name: linux tooltip
template: 'Linux: {{ linux | toLocaleString() }}%'
- name: unknown tooltip
template: 'Unknown: {{ unknown | toLocaleString() }}%'
- name: other tooltip
template: 'Other: {{ other | toLocaleString() }}%'
series:
- value: android
title: Android
colour: '#a3c639'
tooltip: android tooltip
points:
marker:
svg: >-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-android2" viewBox="0 0 16 16"><path
d="m10.213
1.471.691-1.26c.046-.083.03-.147-.048-.192-.085-.038-.15-.019-.195.058l-.7
1.27A4.832 4.832 0 0 0 8.005.941c-.688
0-1.34.135-1.956.404l-.7-1.27C5.303 0 5.239-.018
5.154.02c-.078.046-.094.11-.049.193l.691 1.259a4.25 4.25 0 0 0-1.673
1.476A3.697 3.697 0 0 0 3.5 5.02h9c0-.75-.208-1.44-.623-2.072a4.266
4.266 0 0 0-1.664-1.476ZM6.22 3.303a.367.367 0 0 1-.267.11.35.35 0 0
1-.263-.11.366.366 0 0 1-.107-.264.37.37 0 0 1 .107-.265.351.351 0 0 1
.263-.11c.103 0 .193.037.267.11a.36.36 0 0 1 .112.265.36.36 0 0
1-.112.264Zm4.101 0a.351.351 0 0 1-.262.11.366.366 0 0
1-.268-.11.358.358 0 0 1-.112-.264c0-.103.037-.191.112-.265a.367.367 0
0 1 .268-.11c.104 0 .19.037.262.11a.367.367 0 0 1 .107.265c0
.102-.035.19-.107.264ZM3.5 11.77c0
.294.104.544.311.75.208.204.46.307.76.307h.758l.01 2.182c0
.276.097.51.292.703a.961.961 0 0 0 .7.288.973.973 0 0 0 .71-.288.95.95
0 0 0 .292-.703v-2.182h1.343v2.182c0 .276.097.51.292.703a.972.972 0 0
0 .71.288.973.973 0 0 0 .71-.288.95.95 0 0 0 .292-.703v-2.182h.76c.291
0
.54-.103.749-.308.207-.205.311-.455.311-.75V5.365h-9v6.404Zm10.495-6.587a.983.983
0 0 0-.702.278.91.91 0 0 0-.293.685v4.063c0 .271.098.501.293.69a.97.97
0 0 0 .702.284c.28 0 .517-.095.712-.284a.924.924 0 0 0
.293-.69V6.146a.91.91 0 0 0-.293-.685.995.995 0 0
0-.712-.278Zm-12.702.283a.985.985 0 0 1 .712-.283c.273 0
.507.094.702.283a.913.913 0 0 1 .293.68v4.063a.932.932 0 0
1-.288.69.97.97 0 0 1-.707.284.986.986 0 0 1-.712-.284.924.924 0 0
1-.293-.69V6.146c0-.264.098-.491.293-.68Z"/></svg>
- value: microsoft
title: Windows
colour: '#0067b8'
tooltip: microsoft tooltip
points:
marker:
svg: >-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-windows" viewBox="0 0 16 16"> <path
d="M6.555 1.375 0 2.237v5.45h6.555V1.375zM0
13.795l6.555.933V8.313H0v5.482zm7.278-5.4.026 6.378L16
16V8.395H7.278zM16 0 7.33 1.244v6.414H16V0z"/></svg>
- value: apple
title: iOS/macOS
colour: '#424243'
tooltip: apple tooltip
points:
marker:
svg: >-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-apple" viewBox="0 0 16 16"><path
d="M11.182.008C11.148-.03 9.923.023 8.857 1.18c-1.066 1.156-.902
2.482-.878 2.516.024.034 1.52.087
2.475-1.258.955-1.345.762-2.391.728-2.43Zm3.314
11.733c-.048-.096-2.325-1.234-2.113-3.422.212-2.189 1.675-2.789
1.698-2.854.023-.065-.597-.79-1.254-1.157a3.692 3.692 0 0
0-1.563-.434c-.108-.003-.483-.095-1.254.116-.508.139-1.653.589-1.968.607-.316.018-1.256-.522-2.267-.665-.647-.125-1.333.131-1.824.328-.49.196-1.422.754-2.074
2.237-.652 1.482-.311 3.83-.067 4.56.244.729.625 1.924 1.273
2.796.576.984 1.34 1.667 1.659 1.899.319.232 1.219.386
1.843.067.502-.308 1.408-.485 1.766-.472.357.013 1.061.154
1.782.539.571.197 1.111.115 1.652-.105.541-.221 1.324-1.059
2.238-2.758.347-.79.505-1.217.473-1.282Z"/><path
d="M11.182.008C11.148-.03 9.923.023 8.857 1.18c-1.066 1.156-.902
2.482-.878 2.516.024.034 1.52.087
2.475-1.258.955-1.345.762-2.391.728-2.43Zm3.314
11.733c-.048-.096-2.325-1.234-2.113-3.422.212-2.189 1.675-2.789
1.698-2.854.023-.065-.597-.79-1.254-1.157a3.692 3.692 0 0
0-1.563-.434c-.108-.003-.483-.095-1.254.116-.508.139-1.653.589-1.968.607-.316.018-1.256-.522-2.267-.665-.647-.125-1.333.131-1.824.328-.49.196-1.422.754-2.074
2.237-.652 1.482-.311 3.83-.067 4.56.244.729.625 1.924 1.273
2.796.576.984 1.34 1.667 1.659 1.899.319.232 1.219.386
1.843.067.502-.308 1.408-.485 1.766-.472.357.013 1.061.154
1.782.539.571.197 1.111.115 1.652-.105.541-.221 1.324-1.059
2.238-2.758.347-.79.505-1.217.473-1.282Z"/></svg>
- value: linux
title: Linux
colour: '#f9be00'
tooltip: linux tooltip
points:
marker:
svg: >-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-ubuntu" viewBox="0 0 16 16"><path
d="M2.273 9.53a2.273 2.273 0 1 0 0-4.546 2.273 2.273 0 0 0 0
4.547Zm9.467-4.984a2.273 2.273 0 1 0 0-4.546 2.273 2.273 0 0 0 0
4.546ZM7.4 13.108a5.535 5.535 0 0 1-3.775-2.88 3.273 3.273 0 0
1-1.944.24 7.4 7.4 0 0 0 5.328 4.465c.53.113 1.072.169 1.614.166a3.253
3.253 0 0 1-.666-1.9 5.639 5.639 0 0 1-.557-.091Zm3.828 2.285a2.273
2.273 0 1 0 0-4.546 2.273 2.273 0 0 0 0 4.546Zm3.163-3.108a7.436 7.436
0 0 0 .373-8.726 3.276 3.276 0 0 1-1.278 1.498 5.573 5.573 0 0 1-.183
5.535 3.26 3.26 0 0 1 1.088 1.693ZM2.098 3.998a3.28 3.28 0 0 1
1.897.486 5.544 5.544 0 0 1
4.464-2.388c.037-.67.277-1.313.69-1.843a7.472 7.472 0 0 0-7.051
3.745Z"/></svg>
- value: unknown
title: Unknown
colour: '#dfdfdf'
tooltip: unknown tooltip
points:
marker:
svg: >-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-question-circle-fill" viewBox="0 0 16
16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.496 6.033h.825c.138
0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314
1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168
1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0
.25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977
1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75
2.286a.237.237 0 0 0 .241.247zm2.325 6.443c.61 0 1.029-.394 1.029-.927
0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927
1.01.927z"/></svg>
size:
- 10
- 10
width: 300
legend:
show: true
position: top
{
"data": [{
"microsoft": 28.32,
"apple": 24.33,
"android": 41.48,
"linux": 1.17,
"other": 1.65,
"unknown": 3.07
}],
"total": 100,
"columns": [{
"name": "microsoft tooltip",
"template": "Windows: {{ microsoft | toLocaleString() }}%"
},{
"name": "apple tooltip",
"template": "iOS/macOS: {{ apple | toLocaleString() }}%"
},{
"name": "android tooltip",
"template": "Android: {{ android | toLocaleString() }}%"
},{
"name": "linux tooltip",
"template": "Linux: {{ linux | toLocaleString() }}%"
},{
"name": "unknown tooltip",
"template": "Unknown: {{ unknown | toLocaleString() }}%"
},{
"name": "other tooltip",
"template": "Other: {{ other | toLocaleString() }}%"
}],
"series": [{
"value": "android",
"title": "Android",
"colour": "#a3c639",
"tooltip": "android tooltip",
"points": {
"marker": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-android2\" viewBox=\"0 0 16 16\"><path d=\"m10.213 1.471.691-1.26c.046-.083.03-.147-.048-.192-.085-.038-.15-.019-.195.058l-.7 1.27A4.832 4.832 0 0 0 8.005.941c-.688 0-1.34.135-1.956.404l-.7-1.27C5.303 0 5.239-.018 5.154.02c-.078.046-.094.11-.049.193l.691 1.259a4.25 4.25 0 0 0-1.673 1.476A3.697 3.697 0 0 0 3.5 5.02h9c0-.75-.208-1.44-.623-2.072a4.266 4.266 0 0 0-1.664-1.476ZM6.22 3.303a.367.367 0 0 1-.267.11.35.35 0 0 1-.263-.11.366.366 0 0 1-.107-.264.37.37 0 0 1 .107-.265.351.351 0 0 1 .263-.11c.103 0 .193.037.267.11a.36.36 0 0 1 .112.265.36.36 0 0 1-.112.264Zm4.101 0a.351.351 0 0 1-.262.11.366.366 0 0 1-.268-.11.358.358 0 0 1-.112-.264c0-.103.037-.191.112-.265a.367.367 0 0 1 .268-.11c.104 0 .19.037.262.11a.367.367 0 0 1 .107.265c0 .102-.035.19-.107.264ZM3.5 11.77c0 .294.104.544.311.75.208.204.46.307.76.307h.758l.01 2.182c0 .276.097.51.292.703a.961.961 0 0 0 .7.288.973.973 0 0 0 .71-.288.95.95 0 0 0 .292-.703v-2.182h1.343v2.182c0 .276.097.51.292.703a.972.972 0 0 0 .71.288.973.973 0 0 0 .71-.288.95.95 0 0 0 .292-.703v-2.182h.76c.291 0 .54-.103.749-.308.207-.205.311-.455.311-.75V5.365h-9v6.404Zm10.495-6.587a.983.983 0 0 0-.702.278.91.91 0 0 0-.293.685v4.063c0 .271.098.501.293.69a.97.97 0 0 0 .702.284c.28 0 .517-.095.712-.284a.924.924 0 0 0 .293-.69V6.146a.91.91 0 0 0-.293-.685.995.995 0 0 0-.712-.278Zm-12.702.283a.985.985 0 0 1 .712-.283c.273 0 .507.094.702.283a.913.913 0 0 1 .293.68v4.063a.932.932 0 0 1-.288.69.97.97 0 0 1-.707.284.986.986 0 0 1-.712-.284.924.924 0 0 1-.293-.69V6.146c0-.264.098-.491.293-.68Z\"/></svg>"
}
}
},{
"value": "microsoft",
"title": "Windows",
"colour": "#0067b8",
"tooltip": "microsoft tooltip",
"points": {
"marker": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-windows\" viewBox=\"0 0 16 16\"> <path d=\"M6.555 1.375 0 2.237v5.45h6.555V1.375zM0 13.795l6.555.933V8.313H0v5.482zm7.278-5.4.026 6.378L16 16V8.395H7.278zM16 0 7.33 1.244v6.414H16V0z\"/></svg>"
}
}
},{
"value": "apple",
"title": "iOS/macOS",
"colour": "#424243",
"tooltip": "apple tooltip",
"points": {
"marker": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-apple\" viewBox=\"0 0 16 16\"><path d=\"M11.182.008C11.148-.03 9.923.023 8.857 1.18c-1.066 1.156-.902 2.482-.878 2.516.024.034 1.52.087 2.475-1.258.955-1.345.762-2.391.728-2.43Zm3.314 11.733c-.048-.096-2.325-1.234-2.113-3.422.212-2.189 1.675-2.789 1.698-2.854.023-.065-.597-.79-1.254-1.157a3.692 3.692 0 0 0-1.563-.434c-.108-.003-.483-.095-1.254.116-.508.139-1.653.589-1.968.607-.316.018-1.256-.522-2.267-.665-.647-.125-1.333.131-1.824.328-.49.196-1.422.754-2.074 2.237-.652 1.482-.311 3.83-.067 4.56.244.729.625 1.924 1.273 2.796.576.984 1.34 1.667 1.659 1.899.319.232 1.219.386 1.843.067.502-.308 1.408-.485 1.766-.472.357.013 1.061.154 1.782.539.571.197 1.111.115 1.652-.105.541-.221 1.324-1.059 2.238-2.758.347-.79.505-1.217.473-1.282Z\"/><path d=\"M11.182.008C11.148-.03 9.923.023 8.857 1.18c-1.066 1.156-.902 2.482-.878 2.516.024.034 1.52.087 2.475-1.258.955-1.345.762-2.391.728-2.43Zm3.314 11.733c-.048-.096-2.325-1.234-2.113-3.422.212-2.189 1.675-2.789 1.698-2.854.023-.065-.597-.79-1.254-1.157a3.692 3.692 0 0 0-1.563-.434c-.108-.003-.483-.095-1.254.116-.508.139-1.653.589-1.968.607-.316.018-1.256-.522-2.267-.665-.647-.125-1.333.131-1.824.328-.49.196-1.422.754-2.074 2.237-.652 1.482-.311 3.83-.067 4.56.244.729.625 1.924 1.273 2.796.576.984 1.34 1.667 1.659 1.899.319.232 1.219.386 1.843.067.502-.308 1.408-.485 1.766-.472.357.013 1.061.154 1.782.539.571.197 1.111.115 1.652-.105.541-.221 1.324-1.059 2.238-2.758.347-.79.505-1.217.473-1.282Z\"/></svg>"
}
}
},{
"value": "linux",
"title": "Linux",
"colour": "#f9be00",
"tooltip": "linux tooltip",
"points": {
"marker": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-ubuntu\" viewBox=\"0 0 16 16\"><path d=\"M2.273 9.53a2.273 2.273 0 1 0 0-4.546 2.273 2.273 0 0 0 0 4.547Zm9.467-4.984a2.273 2.273 0 1 0 0-4.546 2.273 2.273 0 0 0 0 4.546ZM7.4 13.108a5.535 5.535 0 0 1-3.775-2.88 3.273 3.273 0 0 1-1.944.24 7.4 7.4 0 0 0 5.328 4.465c.53.113 1.072.169 1.614.166a3.253 3.253 0 0 1-.666-1.9 5.639 5.639 0 0 1-.557-.091Zm3.828 2.285a2.273 2.273 0 1 0 0-4.546 2.273 2.273 0 0 0 0 4.546Zm3.163-3.108a7.436 7.436 0 0 0 .373-8.726 3.276 3.276 0 0 1-1.278 1.498 5.573 5.573 0 0 1-.183 5.535 3.26 3.26 0 0 1 1.088 1.693ZM2.098 3.998a3.28 3.28 0 0 1 1.897.486 5.544 5.544 0 0 1 4.464-2.388c.037-.67.277-1.313.69-1.843a7.472 7.472 0 0 0-7.051 3.745Z\"/></svg>"
}
}
},{
"value": "unknown",
"title": "Unknown",
"colour": "#dfdfdf",
"tooltip": "unknown tooltip",
"points": {
"marker": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-question-circle-fill\" viewBox=\"0 0 16 16\"><path d=\"M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247zm2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z\"/></svg>"
}
}
}],
"size": [
10,
10
],
"width": 300,
"legend": {
"show": true,
"position": "top"
}
}
14. Set the empty markers§
To set properties of the empty markers (the remainder of the grid), define a last series
entry without a value
. Note that creating an empty series will also cause a legend item to be created for it.
This example was made with config
:
data:
- universal credit: 4
total: 100
columns:
- name: uc tooltip
template: >-
Claiming Universal Credit or Jobseeker's Allowance: {{ universal credit |
toLocaleString() }}%
series:
- value: universal credit
title: Claiming
colour: '#ce0058'
tooltip: uc tooltip
points:
marker:
svg: >-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-person-fill" viewBox="0 0 16
16"><path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3Zm5-6a3 3 0 1 0
0-6 3 3 0 0 0 0 6Z"/></svg>
- title: Not claiming
colour: '#cccccc'
points:
marker:
svg: >-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-person" viewBox="0 0 16 16"><path
d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4
0Zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6
4Zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8
10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832
1.664h10Z"/></svg>
size:
- 10
- 10
width: 300
legend:
show: true
position: top
{
"data": [{
"universal credit": 4
}],
"total": 100,
"columns": [{
"name": "uc tooltip",
"template": "Claiming Universal Credit or Jobseeker's Allowance: {{ universal credit | toLocaleString() }}%"
}],
"series": [{
"value": "universal credit",
"title": "Claiming",
"colour": "#ce0058",
"tooltip": "uc tooltip",
"points": {
"marker": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-person-fill\" viewBox=\"0 0 16 16\"><path d=\"M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3Zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z\"/></svg>"
}
}
},{
"title": "Not claiming",
"colour": "#cccccc",
"points": {
"marker": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" class=\"bi bi-person\" viewBox=\"0 0 16 16\"><path d=\"M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0Zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4Zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10Z\"/></svg>"
}
}
}],
"size": [
10,
10
],
"width": 300,
"legend": {
"show": true,
"position": "top"
}
}