Lattice Grid Buy a licence

demo D252

Calendar heatmap in ESM

A year of daily figures as one square per day, so busy runs and quiet spells stand out

type: 'calendar', x, y

This draws a year of daily figures as one square per day, shaded by value. It makes busy runs and quiet spells across a year stand out at a glance, the way a contribution calendar does.

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.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: 240px"></div>

<script type="module">
  import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
  import '@toclocoinc/lattice-grid/modules/chart-calendar';  // opt in to the calendar type

  const grid = createGrid(document.getElementById('grid'), {
    rowKey: 'id',
    columns: [
      { field: 'date', title: 'Date', type: 'dateString' },
      { field: 'orders', title: 'Orders', type: 'number', total: 'sum' },
    ],
    rows,  // one row a day for a year: date, orders
  });

  createChart({
    grid,
    container: document.getElementById('chart'),
    type: 'calendar',
    x: 'date',
    y: 'orders',
    title: 'Orders through the year',
  });
</script>