Gallery / Change and ranking /
Bump chart
How the places of items changed over the years: who overtook whom (bump chart).
75.3 KB of code · core 29.5 + 12 blocks 45.8
Market rank by sales, 2020-2025
Fabrikam rose from fifth place in 2020 to first in 2023 and stayed there; Contoso fell from first to fifth.
How it is made: transform.window with op "rank" and group = the year writes each brand's place in that year (1 for the largest; order "asc" for the smallest). A line and points per brand on a reversed y (domain [high, low]) is a bump chart: who overtook whom, not by how much. End labels name the lines, so no legend is needed.
What the report is made of
The composer reads the JSON below and puts into the page the core and only the blocks its chart uses: 12 of the 59, 75.3 KB of code, minified, which is 35% of the 215.9 KB that the core and every block weigh together. The report file is 83.1 KB: that code, the data, the styles and the page around them.
| Block | What it does | Share of the code | KB |
|---|---|---|---|
core.composed-plain A report with plain data: no checks, no decoder. Most reports. | A report with plain data: no checks, no decoder. Most reports. | 29.5 | |
lib.curve The path of a line: straight segments, a smooth curve that never overshoots, or steps. Shared by line and area. | The path of a line: straight segments, a smooth curve that never overshoots, or steps. Shared by line and area. | 1.2 | |
lib.pointer Where the pointer is on the chart, and following a mouse or a finger once a frame. Shared by tooltip, crosshair, zoom and brush. | Where the pointer is on the chart, and following a mouse or a finger once a frame. Shared by tooltip, crosshair, zoom and brush. | 1.7 | |
lib.ticks Round steps and ticks (1, 2 or 5 × 10ⁿ). Shared by the number scales and the histogram bins. | Round steps and ticks (1, 2 or 5 × 10ⁿ). Shared by the number scales and the histogram bins. | 0.7 | |
scale.band One band per category: the axis of bar charts. | One band per category: the axis of bar charts. | 1.2 | |
scale.color A color per category, from the theme palette. | A color per category, from the theme palette. | 0.8 | |
scale.linear Numbers to positions, with round ticks. | Numbers to positions, with round ticks. | 1.6 | |
transform.window Moving averages, running totals, change from the previous row; totals, shares and ranks in a group. | Moving averages, running totals, change from the previous row; totals, shares and ranks in a group. | 4.0 | |
mark.line A line per series, with optional end labels. | A line per series, with optional end labels. | 4.4 | |
mark.point Dots, bubbles and beeswarms. | Dots, bubbles and beeswarms. | 3.9 | |
guide.axis Axes: formatted labels, a title, long categories wrapped. | Axes: formatted labels, a title, long categories wrapped. | 11.7 | |
interaction.tooltip The values under the pointer. | The values under the pointer. | 10.7 | |
renderer.svg Draws into SVG: sharp, selectable, prints well. The default. | Draws into SVG: sharp, selectable, prints well. The default. | 3.9 | |
| Total | The core 29.5 and 12 blocks 45.8 | 75.3 |
The JSON
This is the whole input. data holds the datasets, each chart is a spec that names one.
In a checkout of the repository: node scripts/compose.js skills/blockcharts/recipes/bump-chart.json report.html.
Saved as page.json, it composes the same with the skill's own runtime/compose.js.
bump-chart.json
{
"title": "Bump chart",
"data": {
"brands": [
{
"year": "2020",
"brand": "Northwind",
"sales": 120
},
{
"year": "2021",
"brand": "Northwind",
"sales": 135
},
{
"year": "2022",
"brand": "Northwind",
"sales": 150
},
{
"year": "2023",
"brand": "Northwind",
"sales": 148
},
{
"year": "2024",
"brand": "Northwind",
"sales": 160
},
{
"year": "2025",
"brand": "Northwind",
"sales": 171
},
{
"year": "2020",
"brand": "Contoso",
"sales": 140
},
{
"year": "2021",
"brand": "Contoso",
"sales": 138
},
{
"year": "2022",
"brand": "Contoso",
"sales": 132
},
{
"year": "2023",
"brand": "Contoso",
"sales": 125
},
{
"year": "2024",
"brand": "Contoso",
"sales": 118
},
{
"year": "2025",
"brand": "Contoso",
"sales": 110
},
{
"year": "2020",
"brand": "Fabrikam",
"sales": 95
},
{
"year": "2021",
"brand": "Fabrikam",
"sales": 118
},
{
"year": "2022",
"brand": "Fabrikam",
"sales": 141
},
{
"year": "2023",
"brand": "Fabrikam",
"sales": 165
},
{
"year": "2024",
"brand": "Fabrikam",
"sales": 176
},
{
"year": "2025",
"brand": "Fabrikam",
"sales": 190
},
{
"year": "2020",
"brand": "Tailspin",
"sales": 110
},
{
"year": "2021",
"brand": "Tailspin",
"sales": 112
},
{
"year": "2022",
"brand": "Tailspin",
"sales": 109
},
{
"year": "2023",
"brand": "Tailspin",
"sales": 130
},
{
"year": "2024",
"brand": "Tailspin",
"sales": 128
},
{
"year": "2025",
"brand": "Tailspin",
"sales": 126
},
{
"year": "2020",
"brand": "Litware",
"sales": 80
},
{
"year": "2021",
"brand": "Litware",
"sales": 86
},
{
"year": "2022",
"brand": "Litware",
"sales": 97
},
{
"year": "2023",
"brand": "Litware",
"sales": 101
},
{
"year": "2024",
"brand": "Litware",
"sales": 133
},
{
"year": "2025",
"brand": "Litware",
"sales": 150
},
{
"year": "2020",
"brand": "Adatum",
"sales": 100
},
{
"year": "2021",
"brand": "Adatum",
"sales": 99
},
{
"year": "2022",
"brand": "Adatum",
"sales": 104
},
{
"year": "2023",
"brand": "Adatum",
"sales": 96
},
{
"year": "2024",
"brand": "Adatum",
"sales": 92
},
{
"year": "2025",
"brand": "Adatum",
"sales": 88
}
]
},
"charts": [
{
"title": "Market rank by sales, 2020-2025",
"note": "Fabrikam rose from fifth place in 2020 to first in 2023 and stayed there; Contoso fell from first to fifth.",
"how": "transform.window with op \"rank\" and group = the year writes each brand's place in that year (1 for the largest; order \"asc\" for the smallest). A line and points per brand on a reversed y (domain [high, low]) is a bump chart: who overtook whom, not by how much. End labels name the lines, so no legend is needed.",
"spec": {
"data": "brands",
"size": [
720,
340
],
"padding": {
"right": 100
},
"transforms": [
{
"type": "window",
"field": "sales",
"op": "rank",
"group": "year",
"as": "place"
}
],
"scales": {
"x": {
"type": "band",
"paddingOuter": 0.1
},
"y": {
"type": "linear",
"domain": [
6.4,
0.6
],
"nice": false
},
"color": {
"type": "color"
}
},
"guides": [
{
"type": "axis",
"scale": "x"
},
{
"type": "axis",
"scale": "y",
"format": {
"maximumFractionDigits": 0,
"prefix": "#"
}
}
],
"marks": [
{
"type": "line",
"x": "year",
"y": "place",
"color": "brand",
"strokeWidth": 3,
"label": "name"
},
{
"type": "point",
"x": "year",
"y": "place",
"color": "brand",
"r": 5
}
],
"interaction": [
{
"type": "tooltip",
"fields": [
"brand",
"place",
"sales"
]
}
]
}
}
]
}
The report the composer makes from it is one standalone file (83.1 KB): open it from disk, mail it, print it.
In a page of your own
The charts above use the dashboard kit (55.5 KB gzipped), the smallest one that has the blocks this example needs:
lib.curve, lib.pointer, lib.ticks, scale.band, scale.color, scale.linear, transform.window, mark.line, mark.point, guide.axis, interaction.tooltip, renderer.svg.
The HTML below loads it from the jsDelivr CDN, pinned to version 0.0.5; to serve it from your own site, put its file there
(the files of a release) and change the address.
HTML
<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.5/release/kits/dashboard.js"></script>
<script type="application/json" id="bc-data">
{"brands":[{"year":"2020","brand":"Northwind","sales":120},{"year":"2021","brand":"Northwind","sales":135},{"year":"2022","brand":"Northwind","sales":150},{"year":"2023","brand":"Northwind","sales":148},{"year":"2024","brand":"Northwind","sales":160},{"year":"2025","brand":"Northwind","sales":171},{"year":"2020","brand":"Contoso","sales":140},{"year":"2021","brand":"Contoso","sales":138},{"year":"2022","brand":"Contoso","sales":132},{"year":"2023","brand":"Contoso","sales":125},{"year":"2024","brand":"Contoso","sales":118},{"year":"2025","brand":"Contoso","sales":110},{"year":"2020","brand":"Fabrikam","sales":95},{"year":"2021","brand":"Fabrikam","sales":118},{"year":"2022","brand":"Fabrikam","sales":141},{"year":"2023","brand":"Fabrikam","sales":165},{"year":"2024","brand":"Fabrikam","sales":176},{"year":"2025","brand":"Fabrikam","sales":190},{"year":"2020","brand":"Tailspin","sales":110},{"year":"2021","brand":"Tailspin","sales":112},{"year":"2022","brand":"Tailspin","sales":109},{"year":"2023","brand":"Tailspin","sales":130},{"year":"2024","brand":"Tailspin","sales":128},{"year":"2025","brand":"Tailspin","sales":126},{"year":"2020","brand":"Litware","sales":80},{"year":"2021","brand":"Litware","sales":86},{"year":"2022","brand":"Litware","sales":97},{"year":"2023","brand":"Litware","sales":101},{"year":"2024","brand":"Litware","sales":133},{"year":"2025","brand":"Litware","sales":150},{"year":"2020","brand":"Adatum","sales":100},{"year":"2021","brand":"Adatum","sales":99},{"year":"2022","brand":"Adatum","sales":104},{"year":"2023","brand":"Adatum","sales":96},{"year":"2024","brand":"Adatum","sales":92},{"year":"2025","brand":"Adatum","sales":88}]}
</script>
<script type="application/json" data-bc-chart>
{
"data": "brands",
"size": [
720,
340
],
"padding": {
"right": 100
},
"transforms": [
{
"type": "window",
"field": "sales",
"op": "rank",
"group": "year",
"as": "place"
}
],
"scales": {
"x": {
"type": "band",
"paddingOuter": 0.1
},
"y": {
"type": "linear",
"domain": [
6.4,
0.6
],
"nice": false
},
"color": {
"type": "color"
}
},
"guides": [
{
"type": "axis",
"scale": "x"
},
{
"type": "axis",
"scale": "y",
"format": {
"maximumFractionDigits": 0,
"prefix": "#"
}
}
],
"marks": [
{
"type": "line",
"x": "year",
"y": "place",
"color": "brand",
"strokeWidth": 3,
"label": "name"
},
{
"type": "point",
"x": "year",
"y": "place",
"color": "brand",
"r": 5
}
],
"interaction": [
{
"type": "tooltip",
"fields": [
"brand",
"place",
"sales"
]
}
],
"alt": "Market rank by sales, 2020-2025"
}
</script>