demo D216
Heatmap: JavaScript Data Grid Demo
A measure at the crossing of two categories
type: 'heatmap', x, series, y
This draws a heatmap of a measure at the crossing of two categories, with a colour-scale legend showing the low and high of the range. It shows where the highs and lows sit across a grid of combinations, so a pattern across two dimensions reads as colour rather than a table of figures. Switch the ramp scale above the chart between linear, log and quantile and watch the legend redraw to match.
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.103.2/lattice-grid.min.css">
<script src="https://cdn.latticegrid.dev/lattice-grid@1.103.2/lattice-grid.min.js"></script>
<div id="chart" style="height: 340px"></div>
<div id="grid" style="height: 320px; margin-top: 14px"></div>
<script type="module">
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
rowKey: 'id',
columns: [
{ field: 'circuit', title: 'Circuit', layout: { width: 180 } },
{ field: 'region', title: 'Region', filter: { type: 'set' } },
{ field: 'status', title: 'Status', filter: { type: 'set' } },
{ field: 'bandwidth', title: 'Bandwidth', type: 'number' },
{ field: 'charge', title: 'Monthly charge', type: 'number', format: { style: 'currency', currency: 'GBP' }, total: 'sum' },
],
rows, // circuit records
});
// region across, status down, charge at every crossing. diverging colours
// the cells from a midpoint out.
createChart({ grid, container: document.getElementById('chart'), type: 'heatmap', x: 'region', series: 'status',
y: 'charge', diverging: true, title: 'Charge by region and status' });
</script>