Lattice Grid Buy a licence

demo D216

Heatmap in ESM

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.

Building…
Loading a live grid…

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.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.min.css">

<div id="chart" style="height: 340px"></div>
<div id="grid" style="height: 320px; margin-top: 14px"></div>

<script type="module">
  import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.esm.min.js';

  import { createChart } from '@toclocoinc/lattice-grid/modules/charts';

  const grid = 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>