demo D252
Calendar heatmap in Angular
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.
This is the Angular version. A standalone component takes the whole configuration through one config input, surfaces grid events as outputs, and exposes the live grid on a getter for anything the inputs do not cover.
The configuration
import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-calendar'; // opt in to the calendar type
import { LatticeGridComponent, provideLattice } from '@toclocoinc/lattice-grid/angular';
@Component({
selector: 'app-root',
standalone: true,
imports: [LatticeGridComponent],
template:
'<div id="chart" style="height:240px"></div>' +
'<lattice-grid [config]="grid" style="display:block;height:320px;margin-top:14px"></lattice-grid>',
})
export class AppComponent implements AfterViewInit {
@ViewChild(LatticeGridComponent) gridRef!: LatticeGridComponent;
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 */],
};
ngAfterViewInit() {
createChart({ grid: this.gridRef.grid, container: '#chart', type: 'calendar', x: 'date', y: 'orders', title: 'Orders through the year' });
}
}
bootstrapApplication(AppComponent, {
providers: [provideLattice({ createGrid })],
});