demo D251
Bump chart in ESM
Watch a ranking change from one period to the next, where a crossing is a change of place
type: 'bump', x, series, y
This draws a bump chart of a ranking changing from one period to the next, where a crossing line is a change of place. It makes shifts in position over time obvious, so who overtook whom reads directly.
This is the ES module version. The grid is imported straight from a CDN as a module, the same configuration as the vanilla tab without a global script tag, so it drops into any bundler or a bare module script.
The configuration
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.71.0/lattice-grid.min.css">
<div id="grid" style="height: 320px"></div>
<div id="chart" style="height: 340px"></div>
<script type="module">
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-bump'; // opt in to the bump type
const grid = createGrid(document.getElementById('grid'), {
rowKey: 'id',
columns: [
{ field: 'team', title: 'Team', filter: { type: 'set' } },
{ field: 'quarter', title: 'Quarter', filter: { type: 'set' } },
{ field: 'revenue', title: 'Revenue', type: 'number', total: 'sum' },
],
rows, // one team per quarter: team, quarter, revenue
});
// series draws one line per team; the line rides its rank, so a crossing is a
// change of place.
createChart({
grid,
container: document.getElementById('chart'),
type: 'bump',
x: 'quarter',
series: 'team',
y: 'revenue',
title: 'Rank by quarter',
});
</script>