Skip to content

Quick start

The container needs a height: the chart fills it and scrolls inside it.

<div id="chart" style="height: 420px"></div>
import '@ganttlane/dom/styles.css';
import { createGantt } from '@ganttlane/dom';
const container = document.querySelector<HTMLElement>('#chart');
if (!container) throw new Error('#chart not found');
const gantt = createGantt(container, {
tasks: [
{ id: 'design', name: 'Design', start: '2026-03-02', end: '2026-03-06', progress: 60 },
{ id: 'build', name: 'Build', start: '2026-03-09', end: '2026-03-20' },
],
links: [{ source: 'design', target: 'build' }],
viewMode: 'week',
scroll: { initial: 'first-task' },
onTasksChange: (changeSet) => console.log(changeSet),
});
// Later, without recreating the chart: options, view, scrolling, data, events.
gantt.setOptions({ theme: 'dark' });
gantt.setViewMode('month');
gantt.scrollToTask('build');
// When the page is done with the chart: removes every node, listener and timer it added.
gantt.destroy();
  • Tasks and links. A task has an id, a name, a start and an end (or a duration); a link joins a source to a target. '2026-03-02' is a day and its end is inclusive.
  • Dates are floating wall-clock time. There are no time zones: '2026-03-02T09:30' is 09:30 for every viewer. Strings with Z or an offset are rejected.
  • Nothing is mutated. Your options, tasks and links are never changed. A bad value never throws: it is reported as an issue and its default is used.
  • One event per change. A drag moves its task and the tasks that follow it along the links, and onTasksChange gets one ChangeSet with all of them.