Lattice Grid Buy a licence

demo D215

Gantt in React

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 React version. The grid mounts through the createLatticeGrid adapter, which takes its configuration as ordinary props and hands back the live grid through a ref. The grid below is the same one every other tab runs.

The configuration

<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.min.css">

<div id="app"></div>

<script type="module">
  import React from 'https://esm.sh/react@18';
  import { createRoot } from 'https://esm.sh/react-dom@18/client';
  import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.esm.min.js';
  import { createLatticeReact } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/react.esm.min.js';
  import { createChart } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/charts.esm.min.js';

  const { LatticeGrid, LatticeChart } = createLatticeReact({ React, createGrid, createChart });

  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 */];

  function App() {
    const [grid, setGrid] = React.useState(null);

    return (
      <>
        {/* Gantt reads a row label and a start and end date; series colours
            the bars. This is the chart TYPE, not the Gantt module. */}
        {grid && (
          <LatticeChart grid={grid} type="gantt" label="task" start="start" end="end" series="phase" legend title="Schedule by phase" style={{ height: '320px' }} />
        )}
        <LatticeGrid
          rowKey="id"
          columns={columns}
          rows={rows}
          onGridReady={setGrid}
          style={{ height: '320px', marginTop: '14px' }}
        />
      </>
    );
  }

  createRoot(document.getElementById('app')).render(<App />);
</script>