Butterfly chart
Compare two measures for the same list of rows in a butterfly chart: two mirrored horizontal bar panes around one shared column of category names.
- React
import { ButterflyChart } from 'boardplot/react/butterfly';- Reference
- Data, options and sizing
- Use for
- Two measures per category · Before and after by segment · Imports and exports by country
- Not for
- More than two measures per category; butterfly has two panes.
Two products compared by customer
Mirrored bars compare Product A and Product B spend for eight customers; Customer 2 shows Product B at 60 against 81 for A, flagged as minus 21.
customer-spend
JSON spec
This spec includes the theme shown and the options you selected.
Changed from the fixture: options.size from the report frame to the width of the site frame.
{
"type": "butterfly",
"data": {
"categories": [
{
"id": "c1",
"label": "Customer 1"
},
{
"id": "c2",
"label": "Customer 2"
},
{
"id": "c3",
"label": "Customer 3"
},
{
"id": "c4",
"label": "Customer 4"
},
{
"id": "c5",
"label": "Customer 5"
},
{
"id": "c6",
"label": "Customer 6"
},
{
"id": "c7",
"label": "Customer 7"
},
{
"id": "c8",
"label": "Customer 8"
}
],
"series": [
{
"id": "prodA",
"label": "Product A",
"values": [
94,
81,
69,
55,
42,
33,
21,
10
]
},
{
"id": "prodB",
"label": "Product B",
"values": [
95,
60,
71,
48,
45,
28,
19,
12
]
}
]
},
"options": {
"a": "prodA",
"b": "prodB",
"sortBy": "a",
"title": "Product B matches A at the top accounts but trails 21 at Customer 2",
"subtitle": {
"company": "RetailCo",
"measure": "Customer spend",
"period": "FY25"
},
"unit": "$k",
"source": "RetailCo sales ledger, FY25 actuals",
"size": {
"width": 1000
}
},
"annotations": [
{
"kind": "delta",
"at": {
"categoryId": "c2",
"seriesId": "prodB"
},
"vs": {
"categoryId": "c2",
"seriesId": "prodA"
}
}
]
}License and services revenue by industry
Mirrored bars compare license and services revenue for six industries; services lead in four, with Public sector highlighted at 71 against 25.
license-vs-services
JSON spec
This spec includes the theme shown and the options you selected.
Changed from the fixture: options.unit; options.size from the report frame to the width of the site frame.
{
"type": "butterfly",
"data": {
"categories": [
{
"id": "pharma",
"label": "Pharma"
},
{
"id": "banking",
"label": "Banking"
},
{
"id": "auto",
"label": "Automotive"
},
{
"id": "retail",
"label": "Retail"
},
{
"id": "energy",
"label": "Energy"
},
{
"id": "public",
"label": "Public sector"
}
],
"series": [
{
"id": "license",
"label": "License",
"values": [
128,
96,
84,
61,
44,
25
]
},
{
"id": "services",
"label": "Services",
"values": [
74,
112,
90,
38,
52,
71
]
}
]
},
"options": {
"a": "license",
"b": "services",
"sortBy": "sum",
"highlight": [
"public"
],
"title": "Services carry four of six industries, Public sector most of all",
"subtitle": {
"company": "Software Company A",
"measure": "Revenue",
"period": "FY24",
"scenarios": [
"AC"
]
},
"unit": "$m",
"source": "Illustrative management accounts FY24",
"size": {
"width": 1000
}
}
}Channel growth with CAGR and gap
Mirrored bars compare Online and Store orders for FY21 to FY23, with a 20% a year growth arrow on Online (100 to 144) and a +30 gap bracket in FY21.
period-comparisons
JSON spec
This spec includes the theme shown and the options you selected.
Changed from the fixture: options.size from {"width":1000,"height":500} to the width of the site frame.
{
"type": "butterfly",
"data": {
"categories": [
{
"id": "fy21",
"label": "FY21",
"date": "2021-12-31"
},
{
"id": "fy22",
"label": "FY22",
"date": "2022-12-31"
},
{
"id": "fy23",
"label": "FY23",
"date": "2023-12-31"
}
],
"series": [
{
"id": "online",
"label": "Online",
"values": [
100,
120,
144
]
},
{
"id": "store",
"label": "Store",
"values": [
130,
150,
180
]
}
]
},
"options": {
"a": "online",
"b": "store",
"size": {
"width": 1000
},
"title": "Online grows 20% a year; Store is 30 ahead in FY21",
"subtitle": {
"measure": "Orders",
"period": "FY21 to FY23"
},
"source": "Illustrative channel orders",
"annotations": [
{
"id": "growth",
"kind": "cagr",
"from": {
"categoryId": "fy21",
"seriesId": "online"
},
"to": {
"categoryId": "fy23",
"seriesId": "online"
}
},
{
"id": "gap",
"kind": "diff",
"mode": "absolute",
"from": {
"categoryId": "fy21",
"seriesId": "online"
},
"to": {
"categoryId": "fy21",
"seriesId": "store"
}
}
]
}
}Minimal spec
Save this spec as butterfly.json and run the command.
{
"type": "butterfly",
"data": {
"categories": [{ "id": "north", "label": "North" }, { "id": "south", "label": "South" }],
"series": [
{ "id": "plan", "label": "Plan", "values": [100, 80], "scenario": "PL" },
{ "id": "actual", "label": "Actual", "values": [120, 70], "scenario": "AC" }
]
},
"options": {
"a": "plan",
"b": "actual",
"unit": "$k",
"title": "North beats plan while South falls short",
"source": "Illustrative data",
"footnotes": ["AC = actual; PL = plan."]
}
}npx boardplot render butterfly.json --out butterfly.svg