Gantt API
Complete API reference for @oge-ui/gantt. The kernel — the task-tree index, calendar-true time scales, forward auto-scheduling, the critical-path backward pass, orthogonal dependency routing and the gesture math — is pure TypeScript in the framework-free @oge-ui/gantt-engine package, which the React Gantt runs too; live demos are on the overview page.
Properties Methods Events Types
OgeGantt
oge-ganttProperties 49
Data
| Name | Type | Default | Description |
|---|---|---|---|
tasks | readonly T[] | [] | Task items — a plain array, copied into an internal working set; the input is never mutated. Edits surface through the past-tense events. |
dependencies | readonly D[] | [] | Dependency links between tasks; same working-set semantics as tasks. |
keyExpr / parentKeyExpr / titleExpr / startExpr / endExpr / progressExpr / colorExpr | string | ((item: T) => unknown) | 'id' / 'parentId' / 'title' / 'start' / 'end' / 'progress' / 'color' | Task field mapping: names (dotted paths reach nested objects) or getter functions. String dates parse as local wall time and write back in the same storage shape. |
baselineStartExpr / baselineEndExpr | string | ((item: T) => unknown) | 'baselineStart' / 'baselineEnd' | Baseline plan fields — tasks with both render the original plan as a slim bar under the live bar. |
dependencyKeyExpr / predecessorKeyExpr / successorKeyExpr / dependencyTypeExpr | string | ((item: D) => unknown) | 'id' / 'predecessorId' / 'successorId' / 'type' | Dependency field mapping. Types are 'FS' | 'SS' | 'FF' | 'SF' (dx numeric codes 0–3 also parse); missing type means FS. |
resources | readonly OgeGanttResource[] | [] | Resource choices: labels next to the bars, the multi-assignment tag editor in the task dialog, the workload band rows — and a resource's own calendar overrides workCalendar for its tasks (first assigned resource with a calendar wins). |
resourceIdExpr | string | ((item: T) => unknown) | 'resourceId' | The task's assigned resource field — a single id or an array of ids (multi-assignment). Write-back preserves the storage shape: array stores stay arrays, scalar stores stay scalar while at most one id is assigned. |
dependencyLagExpr / dependencyLagUnitExpr | string | ((item: D) => unknown) | 'lag' / 'lagUnit' | Link lag / lead: an amount (negative = lead) and its unit, 'days' (working days on a workCalendar) or 'hours'. Drawn as a +2d badge on the arrow, honoured by auto-scheduling for all four link types, edited in the dependency editor (double-click an arrow, or Enter on a clicked one) and in the predecessors column (3FS+2d). |
manuallyScheduledExpr | string | ((item: T) => unknown) | 'manuallyScheduled' | Per-task scheduling mode — true pins the task: auto-scheduling never moves it, and a link it breaks is reported as a dependency conflict. Bars draw a hatched pattern. |
constraintTypeExpr / constraintDateExpr | string | ((item: T) => unknown) | 'constraintType' / 'constraintDate' | Task constraint (MS Project vocabulary): 'ASAP' | 'ALAP' | 'SNET' | 'SNLT' | 'FNET' | 'FNLT' | 'MSO' | 'MFO' and its date. SNET/FNET set a floor, MSO/MFO pin the task, SNLT/FNLT cap it; links win over SNLT/FNLT/MSO and the violation is reported. ALAP slides the task as late as its successors allow (backward pass). A dated type without a date reads as ASAP. |
deadlineExpr | string | ((item: T) => unknown) | 'deadline' | Target finish: a flag marker on the bar row, an overdue state (and a deadline conflict) when the task ends later. |
segmentsExpr | string | ((item: T) => unknown) | 'segments' | Split tasks: [{ start, end }, …] — two or more pieces draw as separate bars joined by a dotted line; the task spans its pieces. Moving drags every piece; resizing moves the first piece's start or the last piece's end. |
baselinesExpr | string | ((item: T) => unknown) | 'baselines' | Several baselines: [{ start, end }, …], index = baseline number − 1. Wins over baselineStartExpr/baselineEndExpr (which remain baseline 1). The toolbar shows a chooser when a task carries more than one. |
unitsExpr / effortExpr | string | ((item: T) => unknown) | 'units' / 'effort' | Assignment units in % (a number for every assigned resource, an array aligned with the resource ids, or an id-keyed map; default 100) and work in hours (effortDriven). |
Appearance & behavior
| Name | Type | Default | Description |
|---|---|---|---|
scaleType | 'hours' | 'days' | 'weeks' | 'months' | 'quarters' | 'years' | 'days' | Timeline scale — calendar-true ticks (real month lengths, DST-safe). Two-way ([(scaleType)]); the toolbar zoom and Ctrl+wheel write it. |
firstDayOfWeek | number | undefined | — | First day of week (0 = Sunday) for the weeks scale; undefined resolves from the locale. |
columns | readonly OgeGanttColumn[] | title / start / end / duration | Task-list columns: built-in fields (title, start, end, duration, progress, wbs, predecessors, totalSlack, freeSlack, constraint, deadline, resources, units, effort) or any data field, with optional header, widthPx, format, editor (false = read-only), allowSorting and frozen (pinned to the start edge, frozen columns lead). |
taskListWidth | number | 360 | Initial width (px) of the task pane; the splitter between the panes drags. |
taskTitlePosition | 'inside' | 'outside' | 'none' | 'inside' | Where the task title renders relative to its bar. |
showDependencies / showRowLines | boolean | true | Dependency arrows / horizontal row guides. |
showCriticalPath | boolean | false | Outlines the zero-slack chain (backward-pass latest-finish relaxation over all four link types). |
weekendsHighlighted / holidays | boolean / readonly Date[] | true / [] | Off-day shading on the days scale. |
weekendDays | readonly number[] | undefined | — | Weekend days (0 = Sunday … 6 = Saturday) weekendsHighlighted shades. undefined resolves from the locale via Intl.Locale#getWeekInfo() (Friday + Saturday in he-IL), falling back to Saturday + Sunday. A workCalendar takes precedence. |
workCalendar | OgeGanttWorkCalendar | null | null | Work-time calendar ({ workingDays?, holidays? }, 0 = Sunday): shades every off day and makes auto-scheduling roll pushed starts onto working days, preserving durations in working days. The holidays input merges in; per-resource calendars override it per task. |
showResourceWorkload | boolean | false | Renders the per-resource workload band under the chart: merged assignment segments per resource, overallocated stretches (concurrent assignments) in the danger color. |
stripLines | readonly OgeGanttStripLine[] | [] | Vertical markers: { start, end?, label?, color? } — a line without end, a shaded range with it (dx parity). |
timeZone | string | undefined | undefined | The display zone (IANA, e.g. 'America/New_York'); unset = the browser’s. Stored dates stay instants: the bars, the scale, the today marker, the progress line, strip lines and the work calendar’s working days follow this zone’s clocks (core’s Intl offset math — DST-exact, no time-zone database), and every edit, drag and dialog save writes the instant back. |
locale | string | undefined | — | BCP 47 locale for every Intl format; defaults to the config locale, then the browser locale. |
messages | Partial<OgeGanttMessages> | {} | Per-instance message overrides, merged over the DI config per top-level block. |
rtlEnabled | boolean | undefined | undefined | Right-to-left layout: the task tree moves to the right, the timeline runs from right to left (dependency arrows, baselines, today line and drag tip included), pointer drags and the splitter invert their direction and the Left/Right keys mirror — Left expands a summary, Alt+Shift+Left indents and Ctrl+Left moves a bar later. Unset follows the page: the computed direction or the nearest dir attribute, read after the first render and kept current while it changes; an explicit value also sets dir on the host. The built-in context menu opens towards the inline-start side of the pointer and its back arrow mirrors (Right closes it in RTL), and the PNG / PDF exports mirror the picture while the Excel export writes a right-to-left sheet (MS Project XML is direction-neutral data). |
selectedTaskKey | RowKey | null | null | The selected task. Two-way ([(selectedTaskKey)]). |
Scheduling
| Name | Type | Default | Description |
|---|---|---|---|
autoScheduling | boolean | false | Project-level auto-scheduling: after every edit the engine places each auto-scheduled task at the earliest date its links (with lag) and constraint allow — moving tasks earlier as well as later — then slides ALAP tasks late (backward pass). Manually scheduled tasks stay put. scheduleProject() runs it on demand. |
projectStart | Date | null | null | Where unlinked ASAP tasks start while auto-scheduling; null keeps their current start (only links and constraints move a task). |
baselineIndex | number | 0 | Which baseline renders (0-based); -1 hides baselines. Two-way ([(baselineIndex)]); the toolbar chooser writes it. |
showProgressLine / statusDate | boolean / Date | null | false / null | The progress line: a zig-zag through every visible row from the status date to the point each started task's progress has reached (status date default: today). |
showRollups | boolean | false | Draws every child milestone onto its summary bar (useful when the summary is collapsed). |
zoomPresets | readonly OgeGanttZoomPreset[] | null | null | The toolbar's scale chooser: { scaleType, tickWidth?, label? } entries; null lists one per scale (hours … years). |
Task list
| Name | Type | Default | Description |
|---|---|---|---|
inlineEditing | boolean | false | Edits task-list cells in place: double-click a cell or press F2 on a row; Enter commits, Escape cancels, Tab / Shift+Tab commit and move along the row. Text, date, number, duration (days) and predecessor (3FS+2d, 5SS) editors; summaries keep their rolled-up dates read-only. Every commit is one undoable update through the cancelable pipeline. |
allowSorting | boolean | false | Header click / Enter sorts (ascending → descending → off) — siblings within each parent, WBS numbers keep the store order. aria-sort on the header. |
allowColumnResizing / allowColumnReordering | boolean | false | Header edge drag or Alt+Left/Right (Shift: 1px) resizes a column; header drag or Ctrl+Shift+Left/Right moves it. Headers become one roving tab stop (Left/Right between them, Down into the rows). |
filterRow / searchPanel | boolean | false | A filter row under the headers (per column) and a toolbar search box (any column): fold-insensitive “contains” on the cell text; matches keep their ancestors and open collapsed summaries. |
selectionMode | 'single' | 'multiple' | 'single' | 'multiple': Ctrl/Cmd-click toggles, Shift-click and Shift+Up/Down extend, Ctrl+Space toggles, Ctrl+A selects all; Delete, Alt+Shift+Left/Right and the context menu act on the whole selection as one undo step. |
selectedTaskKeys | readonly RowKey[] | [] | Every selected key in multiple mode (the primary row is selectedTaskKey). Two-way ([(selectedTaskKeys)]). |
Resources & views
| Name | Type | Default | Description |
|---|---|---|---|
effortDriven / hoursPerDay | boolean / number | false / 8 | Effort-driven scheduling: changing a task's resources, units or work recomputes its finish as work ÷ (hoursPerDay × Σ units) in working days. |
showResourceHistogram | boolean | false | Per-resource utilization rows under the chart: one bar per timeline period (units × overlap), a dashed capacity line (OgeGanttResource.capacity, default 100%), over-allocated periods in the danger colour; each row's accessible name summarizes the peak and the periods over capacity. |
viewMode | 'tasks' | 'resources' | 'tasks' | 'resources' regroups the rows by resource (an Unassigned group last); assignment rows edit the real task. The toolbar toggle (shown when resources exist) writes the two-way model. |
Editing gates
| Name | Type | Default | Description |
|---|---|---|---|
editingEnabled | boolean | true | Master editing switch (dx editing.enabled). |
allowTaskAdding / allowTaskUpdating / allowTaskDeleting / allowDependencyAdding / allowDependencyDeleting | boolean | true | Per-capability editing gates. |
readOnly | boolean | false | Display-only shorthand: equivalent to editingEnabled=false, hides every editing affordance. |
Methods 24
| Name | Type | Description |
|---|---|---|
insertTask(taskData) / updateTask(taskData, patch) / deleteTask(taskData) | void | Programmatic CRUD through the same cancelable pipelines as interactive editing — one undo step each. |
insertDependency(predecessorKey, successorKey, type?, options?) / deleteDependency(dependencyData) | void | Guarded link CRUD; inserting runs the same cycle check as interactive drawing and takes an optional { lag, lagUnit }. |
undo() / redo() | void | Snapshot history — every applied edit, drags included, is exactly one step (depth: config undoLimit). |
zoomIn() / zoomOut() / zoomToFit() | void | Steps the scale (hours ⇄ days ⇄ weeks ⇄ months ⇄ quarters ⇄ years) / picks the scale that fits the whole plan and scrolls to it. |
scrollToDate(date) | void | Scrolls the chart so date is in view. |
expandAll() / collapseAll() / expandAllToLevel(level) / expandToTask(key) | void | Tree expansion control; expandToTask also selects and reveals the row. |
showTaskDetailsDialog(taskData?) | void | Opens the task dialog — edit form for the given task, prefilled create form without one. |
indentTask(task) / outdentTask(task) | void | Reparents through the guarded update pipeline: indent makes the task a child of its previous sibling (MS Project parity), outdent lifts it to the grandparent. Also on the built-in context menu and Alt+Shift+Left/Right on the focused row. |
focus() | void | Focuses the task tree (roving row). |
getExportData() | OgeGanttExportData<T> | Snapshot for the exporters: every task in tree order (collapse ignored), the resolved columns with pane-identical formatting, the chart range and the critical-path keys. |
Scheduling, task list & selection
| Name | Type | Description |
|---|---|---|
scheduleProject() | void | Runs the scheduling engine now — even with autoScheduling off — as one undo step. |
updateDependency(dependencyData, patch) | void | Updates a link's fields (type, lag, lag unit…) through the cancelable dependencyUpdating pipeline; auto-scheduling re-runs. |
getTaskSlack(key) | OgeGanttSlack | null | Total and free slack of a leaf task in days (working days on a calendar) — also the totalSlack / freeSlack columns. |
setBaseline(index?) | void | Saves every leaf task's current dates as baseline index (0-based, default 0) — MS Project “Set Baseline”, one undo step. |
applyZoomPreset(index) | void | Applies a zoom preset (scale + tick width) by index. |
sortBy(field, direction?) / setFilter(field, text) / setSearchText(text) / clearFilters() | void | Programmatic sort (null clears), filter-row text and search. |
setColumnWidth(field, widthPx) / moveColumn(field, toIndex) | void | Column width (clamped 40–600px) and order — the same paths as the header gestures, with their events. |
editCell(task, field?) | boolean | Opens the inline editor on a cell (unset field = the first editable one); false when the cell is read-only. |
getSelectedTasks() / selectAll() / clearSelection() | OgeGanttTask<T>[] / void | The multi-selection in tree order, select every visible task, clear. |
deleteTasks(items) / indentTasks(tasks) / outdentTasks(tasks) | void | Bulk edits — each one undo step and one plural announcement. |
Export entry points (lazy, optional peers)
| Name | Type | Description |
|---|---|---|
exportGanttToExcel(gantt, options?) / buildGanttExcelWorkbook(data, options?) | @oge-ui/gantt/export-excel | Lazy Excel export (exceljs peer): the task tree as a typed worksheet — indented titles, bold summary rows, real Date cells, an appended resource column; a right-to-left sheet when the Gantt is RTL (rtl option overrides). Import the entry point dynamically so exceljs stays out of the initial bundle. |
exportGanttToPdf(gantt, options?) / buildGanttPdfDocument(data, options?) | @oge-ui/gantt/export-pdf | Lazy PDF export (jspdf peer): the chart drawn as vector graphics — scale header, bars with progress fill, summary brackets, milestone diamonds, optional critical-path outlining, multi-page pagination. An RTL Gantt exports mirrored — title column on the right, timeline running right to left, right-aligned text — unless rtl: false is passed. Text outside WinAnsi (Turkish ğ ş ı İ, Central European, Greek, Cyrillic) needs a Unicode TrueType font — per export, or once for every PDF via setOgePdfDefaultFont({ family, normal, bold }) from @oge-ui/behavior; without one the built-in Helvetica cannot draw it (a dev-mode warning says so). |
exportGanttToPng(gantt, options?) / buildGanttCanvas(data, options?) | @oge-ui/gantt/export-image | Lazy PNG export with no dependencies — plain canvas drawing of the same chart (configurable width, pixel ratio, background and critical-path outlining), mirrored for an RTL Gantt like the PDF (rtl option overrides). |
exportGanttToMsProject(gantt, options?) / importMsProjectXml(xml) | @oge-ui/gantt/export-msproject | MS Project XML (MSPDI) without dependencies: the export writes tasks with WBS, outline levels, manual mode, constraints, deadlines and baselines, links with LinkLag, resources with max units, assignments with units and work, and the calendar (working weekdays + holiday exceptions), then downloads (download: false returns the XML only). The import parses with a small DOM-free reader (no Trusted Types sink, no DTD entities) into plain tasks / dependencies / resources / workCalendar in the default field names — bind them. Midnight-to-midnight dates map to 08:00–17:00 and back, so a round trip is lossless. MSPDI is direction-neutral data, so an RTL Gantt writes the same XML. |
Events 12
Editing (cancelable pipeline)
| Name | Type | Description |
|---|---|---|
taskInserting / taskUpdating / taskDeleting | OgeGanttTask*ingEvent<T> | Cancelable pre-events — set cancel = true to veto before the store changes. |
taskInserted / taskUpdated / taskDeleted | OgeGanttTask*edEvent<T> | Fired only for applied changes — persist from these. |
dependencyInserting / dependencyDeleting | OgeGanttDependency*ingEvent | Cancelable link pre-events; inserting carries predecessorKey, successorKey and type. |
dependencyInserted / dependencyDeleted | OgeGanttDependency*edEvent<D> | Applied link changes. |
taskEditDialogShowing | OgeGanttDialogShowingEvent<T> | Cancelable, before the task dialog opens; replace formItems to customize the form (dx onTaskEditDialogShowing parity). |
Interaction
| Name | Type | Description |
|---|---|---|
taskClick / taskDblClick / taskContextMenu | OgeGanttTaskClickEvent<T> | Bar/row pointer events with the normalized task and the raw MouseEvent. Right-click — or Shift+F10 / the ContextMenu key on a row — also opens the built-in context menu (edit, new task/subtask, indent/outdent, delete — labels in messages.menu; Up/Down/Home/End move, Escape or the inline-start arrow closes it and returns to the row); listen to taskContextMenu to add your own entries alongside it. |
selectionChanged | OgeGanttSelectionChangedEvent<T> | Selection changed: task (the primary row, or null) and tasks (every selected task; multiple mode). |
scaleTypeChange / selectedTaskKeyChange | OgeGanttScaleType / RowKey | null | The two-way model outputs. |
Scheduling & task list
| Name | Type | Description |
|---|---|---|
schedulingConflict | OgeGanttSchedulingConflictEvent<T> | The conflict set changed (also when it empties): conflicts with the task, the kind ('dependency' | 'constraint' | 'deadline'), the violated link / constraint / date and a readable message. Conflicted bars draw a dashed danger outline and a ! badge; their row labels name the conflict. |
dependencyUpdating / dependencyUpdated | OgeGanttDependencyUpdat*Event<D> | Cancelable link update (type / lag) and its applied twin. |
sortChanged / columnResized / columnReordered | OgeGanttSortChangedEvent / OgeGanttColumnResizedEvent / OgeGanttColumnReorderedEvent | Task-list state changes: { field, direction } (null = cleared), { field, widthPx }, { field, fromIndex, toIndex }. |
selectedTaskKeysChange / baselineIndexChange / viewModeChange | readonly RowKey[] / number / OgeGanttViewMode | The model halves of the multi-selection, the baseline chooser and the view toggle. |
Types 17
| Name | Type | Description |
|---|---|---|
OgeGanttTask<T> | interface | The normalized task — the payload of events and templates: key, parentKey, source (the original item), title, start/end, progress, color, baseline dates and baselines, isSummary/isMilestone, level, wbs, manuallyScheduled, constraintType/constraintDate, deadline, segments, resourceIds with aligned units, and effort. |
OgeGanttDependency<D> | interface | The normalized link: key, source, predecessorKey, successorKey, type, lag (negative = lead) and lagUnit. |
OgeGanttDependencyType | 'FS' | 'SS' | 'FF' | 'SF' | Finish-to-start, start-to-start, finish-to-finish, start-to-finish. |
OgeGanttScaleType | 'hours' | 'days' | 'weeks' | 'months' | 'quarters' | 'years' | The timeline scale units. |
OgeGanttColumn | interface | A task-list column: { field, header?, widthPx?, format?, editor?, allowSorting?, frozen? }. |
OgeGanttStripLine | interface | { start, end?, label?, color? } — a chart marker line or range. |
OgeGanttWorkCalendar | interface | { workingDays?, holidays? } — the work-time calendar (0 = Sunday; default working week Monday-Friday). |
OgeGanttResource | interface | { id, text, color?, calendar?, capacity? } — one assignable resource (the resources item type); capacity (%, default 100) is the histogram's over-allocation line. |
OgeGanttExportData<T> / OgeGanttExportColumn<T> | interface | The exporter snapshot: tasks, columns (header + pane-identical text()), rangeStart/rangeEnd, critical keys, resourceText(), and (optional, for hand-built snapshots) dependencies, resources, workCalendar and slack. |
OgeGanttTaskTitlePosition | 'inside' | 'outside' | 'none' | Task title placement relative to the bar. |
[ogeGanttTaskTemplate] | structural directive (OgeGanttTaskTemplate) | Replaces the bar's title content; context OgeGanttTaskTemplateContext: { $implicit: OgeGanttTask<T> }. |
[ogeGanttTooltipTemplate] | structural directive (OgeGanttTooltipTemplate) | Replaces the hover tooltip's content (default: title, dates + duration, progress, resources); context OgeGanttTooltipTemplateContext: { $implicit: OgeGanttTask<T> }. |
OgeGanttConstraintType / OgeGanttLagUnit | 'ASAP' | 'ALAP' | 'SNET' | 'SNLT' | 'FNET' | 'FNLT' | 'MSO' | 'MFO' / 'days' | 'hours' | Constraint types and the lag unit. |
OgeGanttSegment / OgeGanttSlack | interface | { start, end } (split piece or baseline) / { totalSlack, freeSlack } in days. |
OgeGanttZoomPreset | interface | { scaleType, tickWidth?, label? } — one zoom-chooser entry. |
OgeGanttSchedulingConflict<T> / OgeGanttConflictKind | interface | { key, task, kind, constraintType?, dependencyKey?, date?, message }. |
OgeGanttViewMode / OgeGanttSelectionMode / OgeGanttSortDirection / OgeGanttCellEditorType | string unions | 'tasks' | 'resources', 'single' | 'multiple', 'asc' | 'desc', 'text' | 'number' | 'date' | 'duration' | 'predecessor'. |
Configuration
Properties 5
| Name | Type | Default | Description |
|---|---|---|---|
provideOgeGanttConfig(config) | Provider | — | Configures every Gantt below the provider (OgeGanttConfigInput); shallow merge over OGE_DEFAULT_GANTT_CONFIG per top-level key — a partial messages replaces whole nested blocks. The token is OGE_GANTT_CONFIG (OgeGanttConfig). |
messages | OgeGanttMessages | — | Every user-facing string, aria labels included: toolbar (OgeGanttToolbarMessages), columns (OgeGanttColumnMessages), dialog (OgeGanttDialogMessages), grid (OgeGanttGridMessages, aria templates with {token} placeholders) and announcements (OgeGanttAnnouncementMessages, live-region templates, ICU plurals for counts), plus the optional scales, scheduling and dependencyEditor blocks — keys added after 1.1 are optional and filled from English (fillGanttMessages). Defaults: OGE_DEFAULT_GANTT_MESSAGES. |
locale | string | undefined | — | BCP 47 locale for every Intl format in scope; a per-instance [locale] input wins. |
rowHeight | number | 36 | Fixed row height in px — the invariant behind the row virtualization of both panes. |
undoLimit | number | 50 | Undo history depth. |
Notes
- Dates are plain local
Dates throughout (Intl-only house rule — no date library, no adapter, no timezone database). The time scales are calendar-true: month ticks span real month lengths and DST transitions never shift a bar. - No WAI-ARIA APG gantt pattern exists. The widget composes the treegrid pattern: the task pane is a
role="treegrid"with roving-tabindex rows (arrows, Left/Right collapse/expand, Enter opens the dialog, Delete deletes), and the focused row drives its bar: Ctrl+Left/Right moves, Ctrl+Shift+Left/Right resizes as the keyboard equivalent of drag, announced through a polite live region. The chart itself is a focusable scroll region. - Binding plain arrays never mutates them — edits land in an internal working set and the past-tense events carry the data to persist. Every applied edit, interactive or programmatic, is exactly one snapshot undo/redo step.