Lattice Grid Buy a licence

demo D215

Gantt in Angular

A row label with a start and an end, coloured by phase

type: 'gantt', label, start, end

This draws a Gantt-style chart from a row label with a start and an end, coloured by phase. It lays activities out along a timeline so overlaps and sequence read at a glance, from ordinary rows with two dates.

Building…
Loading a live grid…

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 } 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 { LatticeGridComponent, provideLattice } from '@toclocoinc/lattice-grid/angular';

const columns = [
  { field: 'task',  title: 'Task', layout: { width: 160 } },
  { field: 'phase', title: 'Phase', filter: { type: 'set' } },
  { field: 'start', title: 'Start', type: 'date' },
  { field: 'end',   title: 'End',   type: 'date' },
];

// e.g. [{ id: 1, task: 'Discovery', phase: 'Plan', start: '2026-01-06', end: '2026-01-14' }, ...]
const rows = [/* one row a task */];



@Component({
  selector: 'app-root',
  standalone: true,
  imports: [LatticeGridComponent],
  template:
    '<div id="chart" style="height:320px"></div>' +
    '<lattice-grid [config]="grid" (grid-ready)="onGridReady()" style="display:block;height:320px;margin-top:14px"></lattice-grid>',
})
export class AppComponent {
  @ViewChild(LatticeGridComponent) gridRef!: LatticeGridComponent;

  grid = {
    rowKey: 'id',
    columns: columns,
    rows: rows,
  };

  // The grid is created once the view has rendered, so the live instance
  // arrives on grid-ready rather than in ngAfterViewInit.
  onGridReady() {
    const grid = this.gridRef.grid;
    // Gantt reads a row label and a start and end date; series colours the bars.
    createChart({ grid, container: '#chart', type: 'gantt',
      label: 'task', start: 'start', end: 'end', series: 'phase', legend: true,
      title: 'Schedule by phase' });
  }
}

bootstrapApplication(AppComponent, {
  providers: [provideLattice({ createGrid })],
});