demo D255
Dumbbell chart in ESM
Two dots joined by a bar per row, so the distance from before to after is the picture
type: 'dumbbell', x, start, end
This draws two dots joined by a bar per row, so the distance from a before value to an after value is the picture. It shows change per item at a glance, so the size of each move reads as the length of its bar.
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: 320px"></div>
<script type="module">
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-dumbbell'; // opt in to the dumbbell type
const grid = createGrid(document.getElementById('grid'), {
rowKey: 'id',
columns: [
{ field: 'route', title: 'Route' },
{ field: 'before', title: 'Before (ms)', type: 'number', total: 'avg' },
{ field: 'after', title: 'After (ms)', type: 'number', total: 'avg' },
],
rows, // one row a route: route, before, after
});
// start and end are the two dots; the bar between them is the change.
createChart({
grid,
container: document.getElementById('chart'),
type: 'dumbbell',
x: 'route',
start: 'before',
end: 'after',
title: 'Load time, before and after',
});
</script>