demo D252
Calendar heatmap: JavaScript Data Grid Demo
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.
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.108.1/lattice-grid.min.css">
<script src="https://cdn.latticegrid.dev/lattice-grid@1.108.1/lattice-grid.min.js"></script>
<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 = LatticeGrid.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>