Built with ApexGantt
You already have the tasks. They are rows in a database, or an issue-tracker
export, with names like task_id and start_date and a pointer to a parent.
The shortest path to a timeline is not to rewrite that array into a new shape:
it is to declare where each field lives and hand over the rows you already have.
npm install apexgantt
What does ApexGantt actually need per task?
Two fields are always required, and every task without children also needs a start date. Everything else is optional and most of it you already have.
| Field | Required | What it does |
|---|---|---|
id | yes | Stable string id. Dependencies and parents reference it. |
name | yes | Shown in the task-list column and on the bar. |
startTime | yes, except parent rows | Date string, parsed per inputDateFormat. See below, it is the one that bites. From 3.20.0 a parent row may leave it out and take its span from its children. |
endTime | for a bar | End date string. A task without one is a milestone, which needs type set before 3.20.0. See below. |
type | no | 'task' (the default) or 'milestone', a diamond on startTime. |
progress | no | 0 to 100. Draws the filled portion of the bar. |
parentId | no | Id of the parent task. Produces a nested, collapsible task list. |
dependency | no | A task id string, or an object. See below. |
assignees | no | Consumed by the built-in avatar column renderer. |
Map your fields instead of rebuilding your rows
parsing tells ApexGantt where to find each field in whatever shape your data
already has, and series then takes your raw rows untouched. Dot-notation paths
work, and any field can carry a transform for coercion:
import ApexGantt from 'apexgantt'
// Straight from a task API: snake_case keys, ISO dates, a progress value that
// arrives as a string, a parent pointer, and a kind column for milestones.
const rows = [
{ task_id: 'T-1', title: 'Discovery', start_date: '2026-01-05', end_date: '2026-01-16', pct_complete: '100' },
{ task_id: 'T-2', title: 'Build', start_date: '2026-01-19', end_date: '2026-02-27', pct_complete: '40', blocked_by: 'T-1' },
{ task_id: 'T-3', title: 'API', start_date: '2026-01-19', end_date: '2026-02-06', pct_complete: '80', parent: 'T-2' },
{ task_id: 'T-4', title: 'Launch', start_date: '2026-03-02', kind: 'milestone', pct_complete: '0', blocked_by: 'T-2' },
]
const gantt = new ApexGantt(document.getElementById('gantt'), {
height: 420,
// The rows carry ISO dates, so say so. Edits are written back in this format too.
inputDateFormat: 'YYYY-MM-DD',
parsing: {
id: 'task_id',
name: 'title',
startTime: 'start_date',
endTime: 'end_date',
type: 'kind',
parentId: 'parent',
dependency: 'blocked_by',
// A path plus a transform, for the percentage that arrives as a string.
progress: { key: 'pct_complete', transform: Number },
},
series: rows,
})
gantt.render()
Three things in that snippet are worth calling out.
series is typed TaskInput[] | Record<string, unknown>[], so passing raw rows
alongside parsing type-checks cleanly. You are not fighting the types to avoid
a transform step.
The constructor takes an element, not a selector. document.getElementById
or a ref, never '#gantt'. One example in the shipped type definitions shows a
selector string; it is wrong.
T-4 is a milestone: it has no end_date, and its kind column, mapped to
type, says so. Rows without a kind stay ordinary tasks. From apexgantt
3.20.0 a task with no end date and no type is drawn as a milestone anyway, a
diamond on startTime. Before 3.20.0 the same row throws
Task must have an id, start, and end date and nothing renders, so keep the
type whenever your users may be on an older release. An explicit
type: 'task' with no end date throws on every release.
A failing transform does not take the chart down: the library logs
DataParser: Transform function failed for key "..." and falls back to the raw
value, so a bad coercion shows up as a wrong-looking task rather than a blank
screen. Worth knowing when only some rows look off.
Which date format? This is the one that will bite you
Dates are strings, parsed against inputDateFormat, whose default is
MM-DD-YYYY. The parse is forgiving in a way that matters: it tries your
configured format strictly first, and falls back to a permissive parse if that
fails.
That combination has one consequence worth building a rule around. Measured on
apexgantt 3.18.0, the same task rendered four ways:
startTime you pass | inputDateFormat | Renders on |
|---|---|---|
'05-01-2026' | default | 1 May 2026 |
'05-01-2026' | 'DD-MM-YYYY' | 5 January 2026 |
'2026-01-05' | default | 5 January 2026 |
'2026-01-05' | 'MM-DD-YYYY' | 5 January 2026 |
Read the first two rows again. The same string lands four months apart, with
no error, no warning, and a chart that looks entirely plausible either way. If
your data came from a European system and your inputDateFormat says
month-first, every date in the plan is silently wrong and nothing tells you.
The bottom two rows show the way out. Pass ISO YYYY-MM-DD and set
inputDateFormat: 'YYYY-MM-DD' to match. A four-digit leading year has only
one reading, so the ambiguity cannot arise, and almost every task system exports
ISO already: do not reformat your dates on the way in.
Setting the format matters as soon as anyone can edit. The permissive fallback
only helps on the way in. Everything the chart writes back, a dragged bar, a
resized end, a dialog save, goes into your tasks in inputDateFormat, so under
the default a task that arrived as 2026-01-05 leaves a drag as 01-07-2026,
in the same array as the untouched ISO rows. The task-list Start column displays
in inputDateFormat as well, and on 3.19 and earlier the edit dialog reads dates
only in it, so under the default it opens ISO dates as blank fields. With the
format set to ISO, all of them agree with your data.
Parents, and the dates you lose to them
parentId builds the hierarchy, and a task with children behaves differently
from a leaf. showSummaryBar defaults to true, which means a parent's bar
spans the earliest start and latest end of its descendants, and its own
startTime and endTime are ignored.
That matters when converting a real task list, because parent rows in an issue
tracker usually carry their own dates. Those dates will not be what you see.
Summary bars are also always read-only: drag, resize and progress editing are
disabled on them. If you need a parent's own dates respected, give that task
showSummaryBar: false and it renders as an ordinary bar.
With parsing, only mapped fields reach the task, so a flag on the raw row is
dropped unless you map it. From 3.20.0 parsing.showSummaryBar takes a path
like any other field:
parsing: {
// ...the fields above
showSummaryBar: 'rollup', // a row with rollup: false keeps its own dates
}
Before 3.20.0 there is no such key: run DataParser.parse(rows, parsing)
yourself, set showSummaryBar: false on the parents that need it, and pass the
result as series without parsing. Releases before 3.20.0 also skip a row
with no start date when parsing, so a parent row that carries no dates of its
own disappears along with its place in the tree.
From 3.20.0 a row with no start date is kept when it is the parent of a dated
row, directly or further down, and its summary bar spans its children. Any other
row with no start date (an unscheduled backlog item, a row with only an end
date, null dates) is still skipped, with a console warning:
DataParser: Skipping item at index N: it has no start date and no dated child rows.
A parent row with only an end date is drawn as a summary bar too. Parent ids are
compared by value, so a numeric parent column finds a string task_id, and a
parent pointer that loops back on itself (a row naming itself, or two rows
naming each other) puts the row at the root with a warning instead of hanging
the page.
Dependencies: a string, or an object
The short form is a task id, which is read as finish-to-start with no lag:
{ id: 'T-2', name: 'Build', startTime: '2026-01-19', endTime: '2026-02-27', dependency: 'T-1' }
The long form adds a type and a lag:
dependency: { taskId: 'T-1', type: 'FS', lag: 2 }
type is one of FS, SS, FF and SF. Lag is the detail worth knowing.
With a working calendar configured, a lag of 2 means two working days and skips
weekends and holidays; without one it means two calendar days. lagUnit is
accepted but has no effect (it is deprecated from 3.20.0), so the calendar alone
decides. Lag also does less than the word suggests: it feeds the critical path
and the arrow tooltip, and links never move tasks. A successor whose dates break
the lag stays where its own dates put it.
A row takes one dependency. When your export lists several predecessors, add
the others after render with gantt.addDependency(fromId, toId). From 3.20.0
that call throws for a link from a task to itself, a link that would close a
cycle, and a link between a task and its own parent or child, so check it with
gantt.canAddDependency(fromId, toId).ok first when the export may contain
such rows. Links added this way are not in getTasks(); read them back with
getDependencies() (3.20.0) when you save the chart.
What breaks first
| Symptom | Cause |
|---|---|
| Every date is off by months, chart looks fine | Ambiguous day/month strings against the wrong inputDateFormat. The table above. Switch the input to ISO and set inputDateFormat: 'YYYY-MM-DD'. |
Edited tasks come back as MM-DD-YYYY among ISO rows | Edits are written in inputDateFormat, which still has its default. Set it to match your data. |
Nothing renders, console says Task must have an id, start, and end date | A row with no end date and no type, on a release before 3.20.0. Map type for your milestones. |
series is not a valid option / no tasks appear | You copied a framework example. The core option is series; the React wrapper takes a tasks prop instead and derives series from it. See the React guide. |
| Constructor throws or nothing mounts | A selector string was passed instead of an element. |
| A parent task ignores its own dates | showSummaryBar defaults to true. The section above. |
| A parent task cannot be dragged | Summary bars are read-only by design. |
| A parent row with no dates is missing | Before 3.20.0, parsing skips a row with no start date. From 3.20.0 it is kept only when a row below it has dates. |
A backlog row is missing, console says it has no start date and no dated child rows | A row with no start date and no dated descendants is skipped (3.20.0). Give it dates, or leave it out of the timeline. |
An error says Task "<id>" has no startTime and no children | A task with no start date and no children was passed in series without parsing (3.20.0). On first render nothing draws; on update({ series }) the chart keeps its previous data. |
| One task is a bar when it should be a diamond | It has no type: 'milestone' and still has an end date. Map type from your data. |
| Some rows have wrong values, others fine | A transform threw. Check the console for DataParser: Transform function failed. |
When a Gantt chart is the wrong shape
| What you have | Reach for |
|---|---|
| Tasks with dates, dependencies, and a hierarchy | A Gantt chart. This is the case. |
| Tasks with a status but no dates | A board, not a timeline. A Gantt chart with invented dates is a plan nobody agreed to. |
| A reporting hierarchy rather than a schedule | An org chart. Same flat-rows-to-hierarchy conversion, different renderer. |
| Resource allocation as the question, not sequence | A resource histogram, or the timeline grouped by team. |
| Thousands of tasks at once | Collapse by default and expand on demand. A timeline nobody can scan is a slow way to draw a table. |
| A single deadline countdown | Not a chart. A date and a number. |
Which plan covers this?
ApexGantt is included in the Premium plan and above and has no free tier: the Community License, free under $2M in annual revenue, budget or funding, does not cover it. Nothing in the family is open source, and source published on GitHub is not an open licence. Without a licence key the chart renders with a trial watermark for evaluation, so this whole recipe is testable against your own data before you buy anything. The pricing page has the details.
The field-mapping demo, with sourceSee the pieces running
Reference documentation
Frequently Asked Questions
Do I have to reshape my task data for ApexGantt?
No. The parsing option maps ApexGantt's fields to paths in whatever shape your data already has, including dot-notation paths and a per-field transform for coercion, and series then accepts your raw rows. It is typed TaskInput[] | Record<string, unknown>[], so passing unmapped rows alongside parsing type-checks cleanly.
What date format does ApexGantt expect?
Dates are strings parsed against inputDateFormat, which defaults to MM-DD-YYYY. The parse tries your configured format strictly and falls back to a permissive parse, so ISO YYYY-MM-DD is read correctly whatever the setting is. Pass ISO and set inputDateFormat to YYYY-MM-DD as well: a leading four-digit year has only one reading, and everything the chart writes back, from a drag to a dialog save, uses inputDateFormat, so under the default your edited dates come back as MM-DD-YYYY strings.
Why are all my Gantt dates months out?
Because an ambiguous string was read against the wrong inputDateFormat. Measured on apexgantt 3.18.0, the string 05-01-2026 renders on 1 May under the default MM-DD-YYYY and on 5 January under DD-MM-YYYY, with no error and a plausible-looking chart either way. Switch the input to ISO and set inputDateFormat to YYYY-MM-DD, rather than trying to match the format to your data.
How do I make a task a milestone?
Set type to "milestone" (with parsing, map a field to type) and leave endTime off. The task renders as a diamond on startTime. From apexgantt 3.20.0 a task with no endTime and no type is a milestone too, but earlier releases throw on such a row and the chart does not render, so set the type whenever your users may be on an older version.
Why does my parent task ignore its own start and end dates?
Because showSummaryBar defaults to true, so a task with children spans the earliest start and latest end of its descendants and its own dates are ignored. Summary bars are also read-only. Set showSummaryBar to false on that task if you need its own dates drawn; with parsing, map it through parsing.showSummaryBar, which arrived in 3.20.0.
Related
See the field mapping running
The data-parsing demo wires a non-standard task shape straight into a timeline, with source.