demo D215
Gantt: JavaScript Data Grid Demo
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.
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.103.2/lattice-grid.min.css">
<script src="https://cdn.latticegrid.dev/lattice-grid@1.103.2/lattice-grid.min.js"></script>
<div id="grid" style="height: 320px"></div>
<div id="chart" style="height: 320px; margin-top: 14px"></div>
<script type="module">
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
rowKey: 'id',
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' }, ...]
rows, // one row a task
});
// Gantt reads a row label and a start and end date; series colours the
// bars. This is the chart TYPE, not the Gantt module.
createChart({ grid, container: document.getElementById('chart'), type: 'gantt',
label: 'task', start: 'start', end: 'end', series: 'phase', legend: true,
title: 'Schedule by phase' });
</script>