Gantt
Project-scheduling chart component (data family): a WBS row tree (parent summary bars span the union of their children's time) against a horizontal time axis, with three bar forms (task / milestone / summary) plus progress fill; dependency links (FS/SS/FF/SF, drawn on a single SVG overlay); a drag trio (drag to reschedule, edge handles to resize, in-bar handle to change progress — written back once on pointerup with events); six time scales (hour/day/week/month/quarter/year) with a two-tier header; today line and weekend/holiday column highlights; row virtualization for tens of thousands of tasks; three readonly levels plus per-task disabling. The data contract is a flat parent pointer list (nested children input is flattened automatically).
Basic Usage
WBS row tree + dependency links + milestones + progress (tasks JSON; flat parent / nested children both accepted)
- Parent tasks render summary bars (time = union of children, progress = duration-weighted average); the row toggle collapses/expands children; the expanded set is written back to the
expandedattribute (JSON array) withoas-expand-change; collapsed sub-rows hide together with their dependency links (links follow row visibility, they do not reroute to the summary bar); - Milestones render as diamonds: an explicit
type: "milestone"takes precedence (a task renders as a milestone even when it carriesend; theendis ignored with a one-timeconsole.warnabout the data conflict); tasks withoutendalso infer as milestones; a task with children always renders as a summary bar (children carry the aggregation semantics, so form and aggregation must agree; a one-timeconsole.warnabout the data conflict fires only whentype: "milestone"is also declared explicitly); astartafterend(reversed dates) is swapped automatically at the sanitize layer with a one-timeconsole.warn(no 2px ghost bar); dependenciesdeclare links (typedefaults tofs;fs/ss/ff/sfsupported) drawn as polylines with arrowheads on a single SVG canvas;- Hovering a bar shows a tooltip (name + range + progress);
template[slot="tooltip"]overrides the content (bind points[data-task-name]/[data-task-range]/[data-task-progress]).
Time Scales (scale)
Six scales: hour / day (default) / week / month / quarter / year (two-tier header: merged major tier + per-unit minor tier)
Changing scale re-lays the time axis (column width adapts per tier, with a floor that keeps labels legible) and dispatches oas-scale-change; invalid values fall back to day. When the container squeezes columns too narrow for labels, minor ticks are thinned by N (grid lines kept, some texts hidden — e.g. every 2nd day on a narrow day axis) so day/month numbers never collide. Dragging snaps to the current scale unit (snap="false" disables snapping and shifts by pixel ratio, preserving time precision).
Drag Trio
Drag body to reschedule / edge handles to resize / dot handle for progress (written back once on pointerup; Esc or pointercancel cancels with zero events)
- Drag the body = move as a whole (duration kept); drag edge handles = change start/end (cannot cross the opposite side); drag the in-bar dot = change progress;
- Written back on pointerup with
oas-task-change(detail: { id, task, oldStart, oldEnd, start, end }) /oas-progress-change(detail: { id, task, progress }) plusoas-tasks-change(full list); releasing without movement dispatches nothing; - Esc (or pointercancel) while dragging cancels → visual rollback, zero events; rewriting
tasksexternally mid-drag aborts the drag (external data wins); - With a bar focused, Shift + ←/→ reschedules by one unit (mirrored in RTL);
- While dragging a bar / resizing / drawing a link, moving near a viewport edge auto-scrolls horizontally and vertically (faster the closer to the edge; stops at the boundary); row reorder auto-scrolls vertically only.
Row Reparent / Reorder (reparent)
Drag a left-column row: top/bottom half = before/after the target (same level), pointer deep to the right = become a child of the target; settles with oas-reparent
Drag a left-column row onto a target: the top half inserts before the target (same level); the bottom half inserts after it (same level); a pointer deep to the right makes it a child of the target. On settle it dispatches oas-reparent (detail: { id, parent, index }, parent null means root level) plus oas-tasks-change (full list). Dropping a parent into its own descendant is rejected (cycle guard, zero events); readonly or a per-task disabled never starts the drag; Esc / pointercancel cancels with zero events.
Dependency Link Editing
Hover a bar for link dots: drag from the left/right dot onto a target task to create a dependency (endpoints pick FS/SS/FF/SF); click a link to select, then Delete to remove
Hovering a bar reveals two link dots: drag the right (finish) dot onto a target bar to create a dependency; the left (start) dot works the same way. A milestone has start == end, so it shows a single finish dot (fs convention; its ss/sf as a predecessor are equivalent to fs/ff). The drop side of the target — left half (start) / right half (finish) — combined with the source endpoint picks the type (FS / SS / FF / SF). The dependency is recorded on the successor task. Click an existing link to select (highlighted), then press Delete / Backspace to remove it (only while the component holds focus; host inputs are not hijacked; pressing Delete on a focused task bar does not delete a selected link). On settle it dispatches oas-dependencies-change (detail: { taskId, dependencies }) plus oas-tasks-change. With readonly, link dots and hit areas are not rendered and removal is disabled; Esc / pointercancel cancels with zero events. On touch, tap a bar to reveal its link dots; a link hit path is focusable and Enter/Delete removes that dependency.
Multi-select, Rename & Keyboard
Click a row to select (Ctrl/Cmd adds, Shift for a range); double-click the name to rename; Delete removes the selection; Alt+↑/↓ reorder siblings, Alt+←/→ outdent/indent; focus a link and press Enter to delete
- Multi-select: click a left row name to select (single); Ctrl/Cmd click toggles; Shift click selects a range; state is exposed via the
selectionproperty (id array, readable/writable) and theoas-selection-changeevent. Delete/Backspace removes the selection (with descendants), or callremoveTasks(ids). - Inline rename: double-click a name → input (Enter commits / Esc restores / blur commits), updates
nameand dispatchesoas-tasks-change. - Keyboard: with a row focused, ↑/↓ move focus, Space selects, Alt+↑/↓ reorder among siblings, Alt+→ indents under the previous sibling, Alt+← outdents, F2 renames; a link hit path is focusable, Enter/Delete removes that dependency (focus returns to the component after removal, so the keyboard position is not lost).
- Accessibility: the name column is a
role="tree"; eachtreeitemcarriesaria-level/aria-posinset/aria-setsize(full sibling set, including collapsed children; dangling/cyclic parents count as roots); selection mirrors toaria-selectedand expansion toaria-expanded. - Touch: tap a bar to reveal its link dots (no hover); the drag handle (⋮⋮) at the start of a left row drives touch row reorder (a full-row vertical drag conflicts with list scrolling on touch, so the handle carries it; the handle owns the gesture while the rest of the row still scrolls). A plain tap on the handle does not change selection.
Task Management (Create / Edit / Dependencies / Export)
Drive create/update/delete with imperative methods instead of rewriting tasks wholesale (writes go through the sanitizer and dispatch oas-tasks-change):
addTask(task?, opts?): add a task, returns the new id;opts: { parent?, before?, after? }. Defaults: name from i18ngantt.newTask, start = today, non-milestone gets a 1-day (inclusive) end.moveTask(id, { parent?, index? }): reparent / reorder; dispatchesoas-reparent+oas-tasks-change.duplicateTask(id, opts?): deep-copy the task and its subtree (fresh ids), right after the original subtree; returns the new root id.addDependency(taskId, dep)/removeDependency(taskId, dep)/updateDependency(taskId, from, to): add / remove / rewrite a dependency (dep: { id, type? }); dispatchesoas-dependencies-change.updateTasks(patches): batch shallow-merge ([{ id, ...patch }]), returns the applied count, dispatches a singleoas-tasks-change.- Zoom:
zoomIn()/zoomOut()step through the six scales;fit()picks the finest scale that still fits all tasks. - Attribute
creatable(boolean, off by default): enables the trailing "+" per row (adds a subtask on summary rows, a sibling after on leaf rows) and double-click empty space to create a task at the clicked date; the new task enters inline rename. No button on readonly / per-task-disabled rows. - Event
oas-task-add(detail{ id, task }): dispatched after imperative or inline creation, so the host can locate and open an editor.
Imperative task management: add / duplicate selected / add dependency / delete selected / zoom / export; creatable inline add (click the trailing + or double-click empty space)
Assemble a task detail editor with oas-modal + oas-form (the component only dispatches oas-task-dblclick; no built-in dialog):
<oas-gantt id="g" creatable></oas-gantt>
<oas-modal id="edit" title="Edit task">
<oas-form id="edit-form">
<oas-form-item label="Name" name="name" required><oas-input name="name"></oas-input></oas-form-item>
<oas-form-item label="Start" name="start" required><oas-date-picker name="start"></oas-date-picker></oas-form-item>
<oas-form-item label="End" name="end"><oas-date-picker name="end"></oas-date-picker></oas-form-item>
<oas-form-item label="Progress" name="progress"><oas-slider name="progress" show-value></oas-slider></oas-form-item>
</oas-form>
</oas-modal>
<script>
const g = document.getElementById('g')
const modal = document.getElementById('edit')
const form = document.getElementById('edit-form')
const field = (name) => form.querySelector(`oas-input[name="${name}"], oas-date-picker[name="${name}"], oas-slider[name="${name}"]`)
let editing = ''
g.addEventListener('oas-task-dblclick', (e) => {
editing = e.detail.id
const t = e.detail.task
field('name').value = t.name
field('start').value = t.start
field('end').value = t.end ?? ''
field('progress').value = t.progress ?? 0
modal.setAttribute('visible', '') // controlled open (the modal closes itself on OK)
})
modal.addEventListener('oas-ok', () => form.submit())
form.addEventListener('oas-submit', (e) => {
const v = e.detail.values // form values are always strings; coerce numeric fields as needed
g.updateTask(editing, { ...v, progress: Number(v.progress) })
})
</script>
oas-task-dblclick/oas-task-clickandoas-task-renderlet the host own editing and custom rendering; the component only guarantees a closed loop of data and interaction.
Task Management Extras (Auto-scheduling / Marquee / Drag-to-create)
- Dependency auto-scheduling:
auto-schedule(boolean, off by default) — after a date change (drag / keyboard /updateTask/updateTasks) or a dependency add/update, successors are pushed minimally later (duration preserved) along FS/SS/FF/SF; skips disabled and summary rows; cycle-safe; dispatchesoas-reschedule(detail{ ids }) plus the resultingoas-tasks-change. - Marquee multi-select: drag vertically on empty left-list space to select by row band; drag on empty timeline space (when
creatableis off) to select by bar intersection;Ctrl/Cmdadds. The result is written toselectionand dispatchesoas-selection-change; marquee still works in readonly (selection is a view state). - Drag-to-create: with
creatableon, drag a range on empty timeline space to create a task spanning that range (double-click still creates a single-day task).
Touch: a timeline-space drag conflicts with 2D scrolling, so marquee / drag-to-create on the timeline do not claim touch gestures (native scrolling is left alone); on touch, create via the trailing "+" or double-click, and marquee via a vertical drag on the left list. Under
auto-schedule, when a summary task is a predecessor, its aggregated descendant range is used (the summary's own date fields are ignored).
auto-schedule: drag the “Prototype” bar right and “Implementation” follows via FS; drag empty timeline space to create a task; drag empty left-list space to marquee-select rows
Scheduling Depth (Dependency lag/lead + Critical Path)
- Dependency lag/lead:
dependencies: [{ id, type?, lag? }]—lagis in days and may be negative (negative = lead/overlap), folded into theauto-scheduleconstraints (fs: successor start ≥ predecessor end + lag;ss: successor start ≥ predecessor start + lag;ff/sflikewise on end). Defaults to 0 (backward compatible). Values outside ±11574 days (≈31 years) or non-finite values are treated as 0 with a one-time devWarn (extreme values would otherwise produce 5-digit years the component cannot read back). - Critical path:
show-critical-path(boolean, off by default) — with the current schedule as the baseline (ES taken from the current start), runs a backward pass over the dependency graph + durations to compute total float; tasks with zero float get a.criticalhighlight on their bar (color via--oas-gantt-critical-color). Read-only; does not change data. - Float marks: total float 0 →
.critical(solid outline); negative total float (already violating a successor constraint) →.conflict(dashed outline,--oas-gantt-conflict-color). A fractionallag(e.g.0.5) inel.taskspromotes that row's date strings to time precision (round as needed).
Critical path: a → b (long) and a → c (short) both follow a — b is highlighted on the critical path, c has float and is not (turn show-critical-path off to drop the highlight)
Scheduling Constraints & Working-Days Calendar
- Task constraints:
GanttTask.constraint('asap'default /'snet'start-no-earlier-than /'mso'must-start-on /'fnlt'finish-no-later-than) +constraintDate. Underauto-schedule:snetsets a start floor,msopins the start (not pushed by dependencies),fnltis a soft deadline (no auto-move). Violations (snetearlier than the floor /msoconflicting with dependencies or off the pin /fnltover deadline) are marked.conflictwhenshow-critical-pathorauto-scheduleis on. Constraints on summary rows are meaningless (dates are derived) → ignored with a one-time warning. - Working-days calendar:
workdays(JSON weekday array[0..6], opt-in; absent/empty = any weekday) +holidays(holidays are always non-working, regardless ofworkdays).auto-schedulesnaps pushed landing points to the next working day (skipping holidays and days outsideworkdays). Changingworkdays/holidaysat runtime, or rewritingtasks, re-normalizes. - Per-resource calendars:
resources(JSON[{ id, name?, workdays?, holidays?, shifts? }]) +GanttTask.resources. For a task assigned multiple resources,workdaysis intersected andholidaysare unioned;shifts: []means no available shift. Inhourscale,auto-schedulesnaps the start into shift windows (inside a shift stays; between/after shifts moves to the next shift start); when a task has multiple resources, the windows of every resource that declaresshiftsare intersected, resources withoutshiftsdo not constrain, and with no common window the start is not snapped into either side's one-sided shift. Day-level scheduling still consumes only workdays/holidays. When a task calendar is empty (shifts: []or an empty workdays intersection), dependency-driven pushes never schedule the task onto an unavailable day — the task keeps its original dates, a one-time devWarn is emitted, and the task is marked.conflict(visible even when devWarn is silent in production); downstream tasks use the frozen original dates as their dependency anchor (they may land before an ancestor's right edge, and the violated dependency is still marked on the predecessor); an explicitmsoanchor is not blocked by this guard. - Resource lanes:
group-by-resourcecreates summary lanes from each task's firstresourcesentry (lane name uses the resourcename, falling back to id); multi-resource tasks appear only under their first resource, and unassigned tasks stay top-level. When bothgroup-by-resourceandgroup-by-projectare set, resource lanes win. Embedded lane load: each lane summary row renders a whole-axis load thumbnail for its resource at the row end (fixed-cell downsampled overview, peak-preserving; cell height ∝ load%, >100% takes the danger channel) — colors reuse the load-panel token family (--oas-gantt-load-bg/--oas-gantt-load-over-bg, row width token--oas-gantt-lane-load-widthdefault 72px), dark/print via tokens; a decorative layer (aria-hidden+ hover title with the peak %), not in tab order. Load statistics share the same cache and semantics as theshow-resource-loadpanel (full-data signature cache; skipped in windowed mode with a devWarn once). - Event order: with
auto-scheduleon and dependent corrections applied, the order is uniformlyoas-reschedule(dependent corrections) →oas-tasks-change(final corrected data), whether the change comes from an interaction commit (drag / keyboard /updateTask/updateTasks) or the host rewritingtasksdirectly (attribute channel); a drag/keyboard settle then dispatchesoas-task-change(the dragged task, withstart/endcarrying the corrected final values). One operation dispatchesoas-tasks-changeexactly once. Hosts should readel.tasks/detail.task.
Working-days calendar: with workdays=[Mon–Fri], drag the predecessor and the successor snaps to the next working day; a +2 (lag) label is visible on the link
Per-resource calendars: resource A holiday + resource B alternate-day shift; workdays intersect
Resource lanes: group by first assigned resource; multi-resource tasks appear once
Hour-level shifts: dependency pushes to 19:00; auto-schedule snaps to next day 09:00
Hour-level shift intersection: A 09-18 × B 11-12; successor lands next day 11:00
Host Integration Recipes (Undo/Redo / Edit Dialog / Export)
The component only guarantees a closed loop of data + interaction; the capabilities below are provided as official recipes (no changes to the component itself):
Undo / Redo (built-in history, opt-in)
history (off by default) records snapshots for updateTask / updateTasks / addTask / removeTasks / moveTask / duplicateTask / dependency mutations and drag commits (up to 100 steps). Use undo() / redo() / canUndo / canRedo / clearHistory(); each undo/redo/new commit dispatches oas-history-change with { canUndo, canRedo, action }. Turning history off or replacing tasks wholesale with different content clears the stack; writing the same tasks back (semantically equal, key-order differences included) does not.
import type { OASGantt } from '@oas-ui/ui'
const gantt = document.querySelector('oas-gantt') as OASGantt
gantt.setAttribute('history', '')
gantt.updateTask('t1', { end: '2026-03-10' })
gantt.undo()
gantt.redo()history: update a task, then undo/redo; button state follows oas-history-change
If the host treats
tasksas the controlled source of truth and writes it back, keeping a host-owned stack is still recommended: the built-in stack is cleared by the next wholesale rewrite and host business actions may be coarser than task commits.
Edit dialog (double-click a task bar)
The component only dispatches oas-task-dblclick; compose a detail editor with oas-modal + oas-form. Resource assignment rides the same edit channel: pool-registered resources render as a multi-select group (oas-checkbox-group, options from getSharedResourcePool().list()), while unregistered ids referenced by the task render as read-only chips (preserved verbatim on save, no data loss); saving goes through updateTask(id, { resources }) (an empty array clears the assignment — the sanitize layer drops the field naturally):
Double-click a task bar to open the edit dialog (oas-modal + oas-form): name/dates/progress + resource assignment multi-select (pool-checked, unregistered read-only chips); Save writes back via updateTask
The task manager (the "Task Management" demo above) is the second entry into the same edit channel: select a row and use the "Toggle assignee" button to reassign via
updateTask— both entries share the pool registry and the write-back contract, aligned wherever they can be. Unregistered ids (e.g.ghost) are read-only chips in the dialog: excluded from the checked set, preserved verbatim on save, and they upgrade to checkable options automatically once registered.
Export (JSON / print / image)
- JSON:
el.tasksis serializable data (nested input is flattened) —JSON.stringify(el.tasks). - Print: add
@media printto expand the timeline and hide unrelated UI; or callfit()thenwindow.print(). - Image / PDF: render on the host side (HTML→canvas or SVG serialization), e.g.
new XMLSerializer().serializeToString(el.shadowRoot.querySelector('.inner'))then to canvas.
Export: click to output the current tasks JSON (the host can persist or download it)
Readonly Levels + Per-task Disable
readonly (all) / dates-readonly (no rescheduling) / progress-readonly (no progress drag); readonly states render no drag handles (visual = semantics)
disabled: true in task data locks only that task's own data: it cannot be dragged (as a source), cannot be a dependency successor, and cannot be a reparent drop-inside target; it can still act as another task's predecessor (link source) and as a reparent before/after sibling target.
Today Line & Weekend/Holiday Highlights
Today line (show-today on by default) + weekend column highlights (weekends on by default) + holidays (demo range dynamically covers today)
Today line off / weekend highlights off / holiday highlights (holidays JSON)
The today line is decorative (aria-hidden) and renders only when today falls inside the axis range; weekend/holiday column tints apply on the day/hour tiers.
Baseline Comparison (show-baseline)
show-baseline on: a translucent baseline bar under the actual bar, title showing the delta (N days later/earlier, or on baseline)
With show-baseline on (off by default), a task carrying baseline: { start, end? } renders a translucent baseline bar under the actual bar; the bar title shows the actual-vs-baseline delta (N days later/earlier, or "on baseline"). Baseline data is owned by the host; the component is read-only on it. baseline.progress is baseline progress 0-100; when present, a progress overlay renders inside the baseline bar (--oas-gantt-baseline-progress-color). The baseline bar also exposes data-start-delta / data-end-delta / data-duration-delta / data-progress-delta (days/percent) for host variance panels; computeVariance(tasks) is available as well. The deadline line uses --oas-gantt-deadline-color.
Project Grouping & Variance Badge (group-by-project / show-variance)
group-by-project: auto project root summaries; show-variance: end-date delta after the row name
GanttTask.project: project key for root tasks. Withgroup-by-project, the component creates synthetic project root summaries in first-seen order (row id__oas_project__:<project>) and moves root tasks under them without mutating the original array.windowedrequires host-flattened rows and does not auto-group.show-variance: with a baseline, renders a.variancebadge after the row name (Δ±Nd, primarily end-date delta) and exposesdata-start-delta/data-end-delta/data-duration-delta/data-progress-delta; positive values are red, negative green, and the full delta is intitle/aria-label.
Deadlines, Float & Baseline Variance (deadline / show-float / baseline.progress)
show-baseline + show-float: baseline progress, total/free float; a missed deadline gets .conflict
GanttTask.deadline: due date (YYYY-MM-DD; hour scale may include time). When the bar ends after it, the bar gets.conflictand the chart renders a dashed.deadlinemarker.GanttTask.deadlines: optional multiple due dates. Merged and deduplicated withdeadline; each date renders one.deadlinemarker (data-deadline-index). Missing any one marks.conflict. Deadlines on summary rows are still ignored with a devWarn.show-float: shows total float (LF − EF) and free float (slack before the nearest successor); the bar also exposesdata-total-float/data-free-floatin days. Summaries are excluded from CPM; windowed mode skips it with a devWarn because a slice lacks the full dependency graph.baseline.progress: baseline progress 0-100; withshow-baseline, a.baseline-progressoverlay renders inside the baseline bar.- Hosts can use the exported pure function
computeVariance(tasks)for baseline variance:
import { computeVariance } from '@oas-ui/ui'
const rows = computeVariance(el.tasks)
// [{ id, startDelta, endDelta, durationDelta, progressDelta }]
// Positive = later than baseline / longer duration / more progress; progressDelta is null without baseline.progressEffort Column (show-effort)
show-effort on: the label area becomes two columns (name | effort), effort right-aligned, missing renders empty
With show-effort (off by default) the left label area switches from a single column to two (name | effort): GanttTask.effort (in days, may be fractional, display-only data — never participates in scheduling/dependency math) renders right-aligned at the end of each row; missing/non-finite renders empty. The header text comes from i18n (gantt.effort), the column width from --oas-gantt-effort-width (default 56px, shared by header and rows). Off state renders no nodes and leaves the existing single-column form untouched.
Task Grid Panel (task-columns / checkable)
Work-order scheduling form: check column + order/operation names + product detail + qty, tri-state select-all in the header row
task-columns (JSON array, off by default) upgrades the label area from a single name column into a declarative multi-column grid (header row + optional check column):
- Column contract:
[{ key, title?, width?, align? }].keypoints at anyGanttTaskfield (custom passthrough fields included; the task name joins the grid via{"key":"name"});titlefalls back to the key;widthis px (unset columns share the remaining space via flex:1);alignisleft(default) /center/right(right maps to inline-end, mirrored in RTL). Cell values are display-only:undefined/nullrender empty, numbers become strings, objects render asJSON.stringify. - Header row:
role="row"+role="columnheader"cells, sharing the exact width/align template with row cells; rows keep the existingrole="treeitem"tree semantics (hierarchical indent moves into the first column's content, so the column frame no longer drifts with depth). - Width constraint: when the declared widths (plus the drag-handle column, check column and gaps) exceed the label-area width, right-hand columns are clipped (v1 has no horizontal scroll) — raise
--oas-gantt-list-width(default 220px) or narrow the columns. - Check column
checkable(boolean, off by default): a 32px check column on the far left (--oas-gantt-check-width), with a tri-state select-all/indeterminate/none checkbox in the header (role="checkbox"+aria-checked, accessible name from i18ngantt.selectAll); row checkboxes two-way sync with theselectionproperty — ticking writes the selection set and dispatchesoas-selection-change(same contract as row click / marquee, no new event name). Counting and select-all scope = currently visible rows (children under a collapsed parent are not counted and their checked state is left untouched);disabledrows follow the existing row-selection stance and remain checkable (no disabled visual on the checkbox, consistent with row click). - Priority: with
template[slot="row"]present the template wins (task-columnsis ignored + one devWarn); withshow-efforton the grid wins (the effort column is no longer rendered separately — keep it by declaring{"key":"effort"}). In grid form, single-column trailing decorations (variance badge / creatable "+" / swimlane load strip) yield as well, so column alignment is never squeezed. - Fault tolerance: invalid JSON (or zero valid column entries) devWarns once and falls back to the single-column form;
[]counts as an explicit clear and falls back silently;checkable="false"turns the column off explicitly (guards against accidental boolean bindings). - windowed boundary: select-all only affects the currently loaded slice (explained in the header title + one devWarn); for full-coverage selection, write
selectionyourself based ontotal. - Parts:
task-grid(row content container) /task-grid-cell(cell) /task-grid-head(header container) /check-cell(check cell).
Status Line & Planned-Progress Ticks (show-status-line / status-date)
show-status-line on: a vertical line at status-date on the timeline + planned-progress ticks inside bars (milestones are binary)
Turning on show-status-line (off by default) does two things at once:
- Status line: a vertical line at
status-date(invalid/missing falls back to today; under SSR it is the server's today — hosts that need snapshot determinism should pass it explicitly; the attribute is not parsed whileshow-status-lineis off — zero added cost on the default path), colored by--oas-gantt-status-line-color(default--oas-color-warning, distinct from the danger-colored today line); renders only when inside the axis range, decorative layeraria-hidden. - Planned-progress ticks: each normal task bar draws a narrow vertical tick at its planned ratio — inclusive day-granularity: the calendar-day count between
status-dateand start (status day counted, start day = 1), clamped to the duration and divided by it (same formula ascomputeEvm's planned) — and exposesdata-plan-ratio(0-1, two decimals) for hosts. Milestones use the binary ratio (0 before start / 1 at or after), summaries draw none. The tick is display-only: no coloring, no warnings, actual progress stays data-driven.
Multiple Baselines (baselines / baseline-id)
baselines + baseline-id selecting the second plan (Plan B, 2 days later than Plan A)
GanttTask.baselines (multiple baselines, opt-in data extension): [{ id, start, end?, progress? }] — rendering and computeVariance both read from it; the baseline-id attribute selects which plan is shown (defaults to the first; an unknown id falls back to the first and devWarns once). The existing single baseline field stays fully compatible — the sanitize layer normalizes it to [{ id: 'default', ...baseline }] and is not deprecated; when both are present baselines wins. The baseline bar visuals match the single-baseline path (--oas-gantt-baseline-color).
// Variance against a chosen baseline (pure-function second argument; defaults to the first)
computeVariance(el.tasks, 'plan-b')
// [{ id, startDelta, endDelta, durationDelta, progressDelta }]Resource Pool & Over-allocation Detection (pool)
pool enabled: overlapping tasks on the same resource get .conflict on bar & row name + oas-resource-conflict badge
The pool attribute (opt-in, default off) connects the task resources ids to the shared resource pool (getSharedResourcePool() from @oas-ui/ui/data/resource/pool, sharing the same registry state as the oas-resource component):
- Pool-driven display: hovering a bar appends pool resource names and rates to the tooltip (
costRate, e.g. "Alice 120/h"); ids missing from the pool are ignored. The custom tooltip template can bind the same text via[data-task-resources]. - Cross-task over-allocation detection: on update, tasks sharing a resource are checked for time-range overlap — any intersection > 0 is an over-allocation (half-open ranges, touching edges excluded; day-precision ends are inclusive, so sharing one day counts); milestones are treated as points and never trigger, summaries are excluded; only registered pool resources are checked (unregistered ids are treated as host legacy data). Over-allocated bars and row names get
.conflict(reusing the violation visual channel--oas-gantt-conflict-color). oas-resource-conflictevent:detail: { conflicts }, each{ taskA, taskB, resourceId, overlapStart, overlapEnd }(inclusive day-precision dates). Idempotent — not re-emitted for the same snapshot; re-emitted after data/pool changes when the signature differs; an empty array is emitted on resolution. The event is emitted synchronously from theupdatecaused by data/pool changes: attach the listener before writing the data (e.g.addEventListenerfirst, then assigntasks), otherwise the first result never reaches the listener. A resource with > 2 concurrent tasks in the same window triggers one dev console warning.- Pool changes do not notify the component: retrigger a recalc after registering (e.g. re-assign
tasks). Detection is skipped in windowed mode with a devWarn (full data required for a correct verdict). - Scale limit: conflict detection re-runs on every update with an O(n²) pairwise scan per resource. Hundreds of tasks (normal project planning) are fine; if a single resource grows to thousands of dense tasks with frequent updates, measure frame time first before considering incremental detection (not implemented, noted for the record).
import { getSharedResourcePool } from '@oas-ui/ui/data/resource/pool'
const pool = getSharedResourcePool()
pool.register([{ id: 'alice', name: 'Alice', costRate: 120 }])
// Retrigger a recalc after pool changes (the pool does not notify the component):
ganttEl.tasks = ganttEl.tasksInstance isolation — shared singleton is optional, not mandatory. When multiple views / multiple canvases / multi-tenant scenarios need separate registries, create an independent pool with createResourcePool() (private state, invisible to the shared singleton and to each other) and inject it via the JS-only resourcePool property; tooltip resource names, over-allocation detection, and the load panel all switch to that instance at once (recomputed on write, no manual update needed). Writing null restores the shared singleton (default channel, backward compatible):
import { createResourcePool } from '@oas-ui/ui/data/resource/pool'
const pool = createResourcePool()
pool.register([{ id: 'alice', name: 'Alice (Canvas A)', costRate: 120 }])
ganttEl.resourcePool = pool // instance isolation; write null to restore the shared singletonSSR / multi-tenant boundary — the shared singleton's state is mounted on globalThis and survives across requests: in Node SSR / runtimes that reuse one process for multiple requests (Next/Nuxt-style server sides), resources registered by a previous request leak into the next one (data cross-talk). Always create a fresh instance per request with createResourcePool() (injected via the resourcePool property) and drop it with the component when the request ends; the shared singleton is only for cross-view sharing within a single browser page session.
Never compare the active pool by reference — getSharedResourcePool() returns a new ResourcePool wrapper each call (each copy / bundler instance gets its own wrapper), semantically equivalent but === is always false. To detect pool changes compare version (incremented on every effective change, no-ops don't bump it) or diff list() contents — never compare wrapper references:
const seen = pool.version
pool.register(batch)
if (pool.version !== seen) ganttEl.tasks = ganttEl.tasks // recalc only when contents changedLoad visualization (load buckets, >100% over-allocation channel) is delivered by
show-resource-load, see the next section; the resource swimlane is delivered bygroup-by-resource(see the section above, with the embedded lane load thumbnail); automatic schedule avoidance is delivered by thelevelConflicts()method (invoked manually, see the "Over-allocation Avoidance" section below, supportingmode: 'reassign'); task-resource assignment editing is covered by the recipe in the "Edit dialog" section (pool-checked multi-select + unregistered read-only chips, written back viaupdateTask).
Over-allocation Avoidance (levelConflicts)
Over-allocation avoidance: Alice's overlapping tasks → one click shifts the victim forward until the conflict clears (undo restores)
levelConflicts(options?) (manual, requires pool on) iteratively resolves each registered-resource conflict until no conflict remains or the iteration cap is hit. Returns { moved, unresolved, truncated, skipped }: moved is the final state of shifted/reassigned tasks ({ id, start, end }, already applied to the component, no write-back needed); unresolved lists conflict pairs still present in the final check (non-empty when both sides cannot yield or the run was truncated); truncated means the maxIter cap (default 500, aligned with the resource levelResources) was reached — never silent; skipped reports non-participating tasks with reasons (summary / milestone / off-pool / invalid-dates, same scope as the detection).
- Mode
mode(default'shift', behavior unchanged):shift: shift the victim forward as a whole (moves dates, preserves duration);reassign: reassign the victim — dates untouched; the conflicting resource is swapped for a pool resource with conflict-free headroom for the whole span. The target criterion shares the detection's source (any task on the target overlapping the victim's range disqualifies it — reassignment must not create new conflicts; touching edges don't count); candidate calendar schedulability participates too: the task calendar is taken with a probe task (other resources kept, the conflicting id swapped for the candidate), and an emptydaysset = never schedulable disqualifies the candidate (taskCalendarsemantics — resources withshifts: [], or workdays whose intersection with the task's other resources / the global set is empty, are never picked, even when fully idle in time); multi-resource tasks only replace the conflicting id (array order and off-pool ids preserved); targets ranked by fewest active participants (least busy first, pool first-seen order on ties); each successful reassign counts as one step (sharedmaxIterbudget). With no feasible target the pair is given up and reported honestly inunresolved— never degraded into shifting;movedentries carry the full reassignedresourcesarray, committed via oneupdateTaskscall. Invalidmodevalues fall back to shift with a devWarn once.
- Victim order: tasks that are
disabled, have an empty resource-calendardaysset (no bookable day), or carryconstraint: "mso"never yield; tasks with adeadlineyield after those without (among deadline holders the latest deadline yields last); ties break by later start first, then later input order first. - Resource calendars in leveling (authoritative contract): the snap calendar = task calendar ∩ resource calendar — the data contract is the
resourcesattribute'sGanttResource(workdaysintersect the global set,holidaysunion with the global set,shifts: []means unavailable all week; pool-sidecapacityOverridesare not part of this contract). A task whose merged calendar has an emptydaysset is locked and never yields (same rank asdisabled/mso). - Shift and snap (shift mode): each step moves a task forward by exactly 1 day (wall-clock preserved across DST; duration unchanged); after convergence the resting positions snap forward to working days (per the resource-calendar contract above, day-by-day with the same 400-day cap), then overlaps are rechecked once — if the snap created new conflicts the iteration continues. Every step moves strictly forward (monotone), so termination is bounded.
- Apply and events: when tasks moved or were reassigned,
oas-levelis emitted first (detail: { moved, unresolved, truncated }), then one commit throughupdateTasks= one undo entry + oneoas-tasks-change(leveling/reassignment is a single transaction; undo restores both dates and assignments); zero changes = zero writes, zero events, zero history (idempotent, safe to call repeatedly). - Guards (one devWarn + empty result):
pooloff,windowed(leveling on a slice would produce wrong results),readonly/dates-readonly.
const r = ganttEl.levelConflicts() // or levelConflicts({ maxIter: 200 }), levelConflicts({ mode: 'reassign' })
if (r.truncated) console.warn('iteration cap reached with residual conflicts', r.unresolved)
ganttEl.addEventListener('oas-level', (e) => {
console.log(`avoidance moved ${e.detail.moved.length} tasks, ${e.detail.unresolved.length} conflicts remain`)
})reassign mode: Alice's overlapping tasks → dates untouched, the victim is reassigned to the idle Bob (undo restores)
reassign calendar filter: r3 has empty shifts (never schedulable) → never picked even when idle; the reassignment lands on schedulable Bob
Resource Load View (show-resource-load)
show-resource-load resource load: Alice's two tasks overlap (03-05..03-06 buckets at 200%, danger channel), Bob stays normal (≤100% primary)
The show-resource-load attribute (opt-in, default off; explicit "false" disables) renders a resource load panel below the chart: one row per resource, with load buckets aligned to the time axis.
- Load semantics (same meaning as the pool over-allocation detection, aggregated per bucket and visualized): each bucket's load = covered days of every task assigned to that resource intersected with the bucket, accumulated per task (day-precision, inclusive ends) — overlapping tasks on the same resource accumulate past 100% (Alice's 03-05..03-06 in the example → 200%); such buckets take the danger channel
--oas-gantt-load-over-bg, ≤100% takes the primary family--oas-gantt-load-bg(dark variants via tokens). Milestones count 0 days as points, summaries are excluded; ids outside the pool are listed too (the load view does not require pool registration). - Granularity maps from scale: hour/day → day buckets, week → week buckets (anchored on week start), month/quarter/year → month buckets. The panel's name column shares the side-list token (
--oas-gantt-list-width) so buckets align column-by-column with the chart timeline, and zoom/pan stay in sync (reuses update-time axis params without recomputation; horizontal panning follows the content layer, same formula in RTL). Row height token--oas-gantt-load-row-height(default 24px). - Row names: with
poolon they come from the pool ("Alice", "Bob" above); with it off, resource ids. - ARIA: the panel is
role="img"with an aria-label summary (resource count · peak resource and percentage); purely visual, not in tab order — screen readers get the summary, not a bucket-by-bucket narration. Buckets carry a nativetitlewith the load percentage (visible on hover). - Performance: load is computed once over the full data and cached by signature (tasks/axis range/granularity/pool changes recompute; the virtual row window only trims rendering, not statistics). Empty data / no resource refs fall back to the i18n empty state. Skipped in windowed mode with a devWarn (slices would undercount; aligned with the pool detection stance).
// The same semantics as a pure function (zero runtime deps) — call it independently for your own load views:
import { computeResourceLoad } from '@oas-ui/ui/data/resource/load'
const r = computeResourceLoad(tasks, {
unit: 'week', // 'day' (default) | 'week' | 'month'
from: '2026-03-01',
to: '2026-03-31',
pool: getSharedResourcePool().list(), // optional: matching rows take the pool name
})
// r: { resources: [{ id, name?, buckets, peak }], bucketStart, bucketDays, unit }
// load% = buckets[i] / bucketDays[i]; >100% means overlapping over-allocation inside the bucketRow Virtualization (10k-scale tasks)
height + row-height enable viewport windowing (300 rows demoed; only the visible window + buffer renders)
stripe is an opt-in switch (off by default). The example enables it for demonstration and can be turned off at any time; disabling removes the stripe layer without affecting virtualization or task interactions. Weekend/holiday columns mix against the component background, so they do not inherit the zebra row color.
Methods: scrollToTask(id) to bring a task row into view, scrollToDate(date) / scrollToToday() for horizontal positioning, updateTask(id, patch) for single-task incremental updates (sanitized, dispatches oas-tasks-change).
Server-side row window (windowed)
For hundreds of thousands of rows: the host supplies only the slice near the visible window and the component holds no full dataset. The row window is computed from the scroll position and, when not covered by the loaded range,
oas-window-requestis emitted; the host refills and rows render by absolute row index.
Attributes: windowed (enable) + total (full row count) + window-start (absolute row index of the slice's first row) + range-start / range-end (host-managed time-axis extent, ISO dates, range-end inclusive — required when the slice does not span the full date range). Events:
oas-window-request:detail: { start, end, reason }(half-open, absolute row indices;reason=init/scroll/resize/data); the same expected window is not emitted twice.oas-range-request: emitted when the visible time window approaches an axis edge;detail: { startMs, endMs, reason }for the host to extend the range.
<oas-gantt windowed total="200000" window-start="0" range-start="2026-01-01" range-end="2026-12-31"
height="360" scale="day"></oas-gantt>
<script>
const el = document.querySelector('oas-gantt[windowed]')
el.addEventListener('oas-window-request', (e) => {
const { start, end } = e.detail
el.setAttribute('window-start', String(start))
el.setAttribute('tasks', JSON.stringify(fetchTasks(start, end))) // fetch from your backend
})
</script>Conventions in windowed mode: the slice must be flat (a hierarchical slice with parent/children triggers a devWarn and renders flat — flatten on the host side); auto-schedule and the critical path would be wrong on partial data and are skipped with a devWarn; row drag-reorder is disabled (index only makes sense within the slice); out-of-range slices (window-start + loaded rows > total) are clamped to total (overflow rows are not rendered) with a one-time devWarn; cross-window links are not drawn — if the predecessor is outside the loaded slice, that dependency link is skipped (the component only holds the slice and cannot locate an off-slice endpoint; to show complete links, include the relevant predecessors in the slice or render them in an aggregation layer); one user action emits oas-tasks-change exactly once; oas-tasks-change carries only the slice in detail.tasks — the host must merge by id into the full dataset, never replace it wholesale.
For the full host recipe (segment fetch, abort in-flight, merge by id, atomic refill) and a runnable example, see Server-side windowed data.
Controlled Expansion / Labels & Snapping / Localization
- Custom fields pass through:
GanttTaskmay carry arbitrary business fields (e.g.assignee,tag) — they are preserved as-is (visible inel.tasks/oas-task-render/ templates) and do not affect scheduling; render them via the bar-label template oroas-task-render, and edit via theoas-modal+oas-formrecipe orupdateTask. - Custom row-name template:
<template slot="row">is cloned per row into.name, where[data-task-name]gets the task name; it may hold any controls — this is where an assignee column goes (carry the assignee as a custom field; the template renders and edits it). Controls inside the template are not hijacked by row drag/select. Example:
<oas-gantt id="g">
<template slot="row">
<span data-task-name></span>
<oas-select class="owner" size="small" options='[{"label":"Alice","value":"alice"},{"label":"Bob","value":"bob"}]'></oas-select>
</template>
</oas-gantt>
<script>
const g = document.getElementById('g')
const tasks = [{ id: 'a', name: 'Design', start: '2026-03-02', end: '2026-03-06', owner: 'alice' }]
g.tasks = tasks
// Fill per-row controls after cloning
g.shadowRoot.querySelectorAll('.row-name').forEach((row) => {
const t = tasks.find((x) => x.id === row.dataset.key)
row.querySelector('.owner').value = t.owner
})
// Change owner → write back the custom field
g.addEventListener('oas-change', (e) => {
const row = e.target.closest('.row-name')
if (row && e.target.classList.contains('owner')) g.updateTask(row.dataset.key, { owner: e.target.value })
})
</script>expanded as a controlled set (JSON array = expanded set; explicit [] collapses all) + label-position (default none, since the row-name column already shows names; inside / right must be opted in)
snap=false (pixel-ratio shift keeps time precision) + locale / first-day-of-week
template[slot="task"] overrides in-bar label content ([data-task-name] binding; labels are not rendered by default with label-position="none", so the template takes effect only after opting in); each rendered bar dispatches oas-task-render (detail: { task, element }) so hosts can rewrite its DOM.
Pro helpers (on-demand)
The gantt data-processing capabilities are also shipped as 4 pure-function helper subpaths, imported separately from the component: their runtime closure carries no component runtime, no core and no i18n (the component core is untouched; helpers are not part of the L1/CDN bundles) — they only enter your build when explicitly imported:
// CSV export (nested flattening + default columns + standard escaping)
import { toCsv } from '@oas-ui/ui/data/gantt/export'
// Earned value management (budget / PV / EV / AC / spi / cpi)
import { computeEvm } from '@oas-ui/ui/data/gantt/evm'
// Backward CPM: latest dates and total float
import { computeLateDates } from '@oas-ui/ui/data/gantt/alap'
// Recurring task expansion
import { expandRecurring } from '@oas-ui/ui/data/gantt/recurring'toCsv(tasks, opts?): flattens nested children in the same order as the component's sanitize layer, with default columns id,name,start,end,type,progress,parent,project; a milestone's end falls back to start; type is derived when missing (has children = summary, no end = milestone, otherwise task); standard CSV escaping (quote when the cell contains the delimiter/quotes/newlines, double the quotes), bom: true for Excel; delimiter / columns (string | { key, label? }) are customizable, and array fields (resources / dependencies) are only emitted for custom columns (ids joined with |).
const csv = toCsv(tasks, { bom: true })
const csv2 = toCsv(tasks, {
delimiter: ';',
columns: [{ key: 'name', label: 'Task' }, 'start', 'end', 'progress', 'resources'],
})computeEvm(tasks, opts): day-precision earned value. Summaries (tasks with children or referenced via parent) are excluded — their progress is derived from children, and counting them would double-book — byTask and totals never include them; an explicit type: "milestone" takes precedence — duration counts 0 and end is ignored (budget only via taskCost; PV counts fully when start ≤ statusDate); budget = rates.taskCost[id] first, otherwise Σ(assigned resources × duration hours × rates.resourceHourly[rid]); planned is capped by the elapsed-day ratio at statusDate; earned = budget × progress%; actualCost accepts a global number or a per-task record and defaults to EV (neutral); spi / cpi return null when pv / ac is 0; start after end self-heals by swapping (sanitize-layer semantics).
const r = computeEvm(tasks, {
rates: { resourceHourly: { zhang: 100 }, taskCost: { fix: 800 } },
statusDate: '2026-03-10',
actualCost: 5200, // or Record<taskId, number>
hoursPerDay: 8,
})
// r: { pv, ev, ac, sv, cv, spi, cpi, byTask }computeLateDates(tasks, opts?): treats the current schedule as-is (no forward re-scheduling) and derives each task's latest start/finish and total float from fs/ss/ff/sf + lag (totalFloatDays; negative = the current schedule is infeasible relative to projectEnd — schedule-drift only; constraint (snet/mso/fnlt) and deadline violation detection are out of scope for the helper and remain the component's job); summaries (tasks with children) are excluded, and projectEnd defaults to the latest finish within the dependency graph; dangling dependencies are skipped, dependency cycles are handled best-effort without throwing (deterministic but input-order sensitive); output preserves the hour part of the input.
const lates = computeLateDates(tasks, { projectEnd: '2026-04-30' })
// [{ id, lateStart: 'YYYY-MM-DD', lateFinish: 'YYYY-MM-DD', totalFloatDays }, …]expandRecurring(tasks, range, opts?): expands tasks carrying a recurring rule into instances within the window. Rules support daily / weekly (byWeekday defaults to the start's weekday, week anchor = the Monday of that week) / monthly (same day of month, skipped in short months) plus interval / count / until; count / until default to unlimited, but when provided and invalid (count < 1, unparseable until) the whole rule is void and the master is not expanded; instances get id ${id}#${seq} (seq = occurrence number in the series, stable across windows), masterId + recurringInstance: true, progress: 0, shifted dates preserving duration and the hour part; instances drop children / dependencies / recurring, array-valued fields are slice-cloned, and type summary is coerced to task (milestone kept); the master is dropped by default (keepMaster: true keeps it).
const expanded = expandRecurring(
[{ id: 'standup', name: 'Standup', start: '2026-03-02', recurring: { freq: 'weekly', byWeekday: [1, 3, 5] } }],
{ start: '2026-03-01', end: '2026-03-31' },
)
expanded.forEach((t) => ganttEl.addTask(t)) // merge back as needed before feeding the componentWhen using helpers in docs-site page scripts, await the custom element before grabbing the component instance (
await customElements.whenDefined('oas-gantt')); the helpers themselves are pure functions and can run at any time. Helper sizes (gzip, first budget measured 2026-11-01): export 1110 B / evm 1097 B / alap 1423 B / recurring 1380 B.
Row hover highlight (hover)
Default: hovering a name row highlights the whole timeline row (decorative layer, pointer-events:none); hover="false" turns it off
Enabled by default: hovering a name row in the left column highlights the matching timeline row through a decorative layer (stacking order stripe < hover < selected), cleared on mouse leave; hover="false" disables the highlight entirely. Touch devices have no hover semantics and are unaffected.
API
oas-gantt
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
auto-schedule | Dependency auto-scheduling (boolean, off by default): after a date change (drag/keyboard/updateTask/updateTasks) or a dependency add/update, successors are pushed minimally (later only, duration preserved) along FS/SS/FF/SF; skips disabled and summary rows; cycle-safe. Dispatches oas-reschedule | string | — |
baseline-id | Multi-baseline selector (with GanttTask.baselines): picks which baseline is rendered/measured; defaults to baselines[0]; an unknown id falls back to the first baseline and devWarns once. The single baseline field is equivalent to [{ id: 'default', ... }] (normalized in the sanitize layer) | string | — |
checkable | Check column (boolean, off by default; with task-columns): a 32px check column on the far left of the grid (token --oas-gantt-check-width, part check-cell), tri-state select-all/indeterminate/none in the header (role=checkbox + aria-checked, accessible name from i18n gantt.selectAll); row checkboxes two-way sync with the selection property — ticking writes the selection set and dispatches oas-selection-change (same contract as row click / marquee, no new event name). In windowed mode select-all only affects the currently loaded slice (header title explains + one devWarn). No effect without task-columns | string | — |
creatable | Inline creation (boolean, off by default): when enabled, a trailing "+" appears per row (adds a subtask on summary rows, a sibling after on leaf rows) and double-clicking empty space creates a task at the clicked date; the new task enters inline rename. No button on readonly or per-task-disabled rows | boolean | — |
dates-readonly | No rescheduling/resizing (progress still draggable) | boolean | — |
expanded | Expanded set (JSON array, controlled): defaults to fully expanded when absent; explicit [] collapses all; written back on toggle | string | — |
first-day-of-week | Week start day (0-6); defaults to locale derivation (used for week-tier alignment) | string | — |
group-by-project | Group root tasks by project into synthetic summary rows (row id __oas_project__:<project>) without mutating the task array; windowed mode requires host-flattened rows | string | — |
group-by-resource | Group root tasks into summary lanes by their first resources entry (lane name from resources.name, falling back to id); multi-resource tasks appear only under their first resource; unassigned tasks stay top-level; resource lanes win over group-by-project | string | — |
height | Component height in px (default 320; accepts a plain number or Npx): mapped to the custom property --oas-gantt-height. The height is applied to the internal canvas (.gantt) — the host's own inline height only frames the outer box, while the inner canvas height is still governed by the height attribute / --oas-gantt-height and is not stretched by the host's inline height; to change the overall height use the height attribute or --oas-gantt-height. While the height attribute is present and valid (>0 plain number or Npx) the component takes over this variable — writing it inline on the host and overriding any --oas-gantt-height the host set itself; an empty/whitespace value is treated as unset; an invalid value writes nothing and only clears a value this instance wrote earlier, so a host token is never affected; after the attribute is removed the component-written value is cleared to zero, so the height falls back to the token default (320) or host CSS, and the host's previous inline value is not restored; when the height attribute was never set the component never writes the variable, and a --oas-gantt-height set by the host (inline or via class rules) is left completely untouched | string | 320 |
history | Built-in undo/redo (boolean, off by default): records task commits (max 100), used with undo()/redo()/canUndo/canRedo/clearHistory(); replacing tasks wholesale with different content clears the stack (an equivalent write-back does not) | string | — |
holidays | Holiday list (JSON ["YYYY-MM-DD",…]): matching columns highlighted (takes precedence over weekend tint); holidays are always non-working (regardless of workdays) and are skipped by auto-schedule | string | — |
hover | Row hover background switch (on by default): hovering a row name or task bar lights up the whole row (name + timeline share the same background). Color via --oas-gantt-row-hover-bg (defaults to --oas-color-bg-hover, independent of the zebra stripe); "false" disables | string | — |
label-position | Bar label position: inside / right / left; default none (the row-name column already shows the name, so the bar does not repeat it); invalid values fall back to none | string | — |
locale | Localization (overrides config-provider injection and the global locale) | string | — |
pool | Resource pool mode (boolean, default off): task resources reference the shared resource pool (getSharedResourcePool() from @oas-ui/ui/data/resource/pool) — hovering a bar shows pool resource names and rates (costRate; unregistered ids ignored); plus cross-task over-allocation detection for the same resource: tasks whose time ranges overlap (half-open, touching edges excluded; milestones treated as points, summaries excluded) get .conflict on bar and row name, conflict pairs emitted via oas-resource-conflict. Pool changes do not notify the component automatically — retrigger a recalc (e.g. re-assign tasks) after registering; detection is skipped in windowed mode with a devWarn; load visualization lives in show-resource-load (load% >100% shares this semantics); automatic schedule avoidance is delivered by the levelConflicts() method (manual, see Methods) | string | — |
progress-readonly | No progress dragging (dates still draggable) | boolean | — |
range-end | Host-managed time-axis end (ISO date YYYY-MM-DD, inclusive); pair with range-start | string | — |
range-start | Host-managed time-axis start (ISO date YYYY-MM-DD): when provided the axis extent is no longer derived from data; use with range-end to support windowed mode (the slice may not span the full date range) | string | — |
readonly | Whole chart read-only (no rescheduling/progress, drag handles not rendered) | boolean | — |
resources | Per-resource calendars (JSON): [{ id, name?, workdays?, holidays?, shifts? }] used with GanttTask.resources; workdays intersect, holidays union; shifts: [] means no available shift; hour-scale auto-schedule snaps into the first assigned resource with shifts, day scale uses workdays/holidays only | string | — |
row-height | Row height in px (default 36, minimum 20) | string | 36 |
scale | Time scale: hour / day (default) / week / month / quarter / year; invalid values fall back to day | string | — |
show-baseline | Baseline comparison (boolean, off by default): tasks with baseline render a baseline bar under the actual bar (baseline.progress renders an overlay), with a title showing the delta (N days later/earlier or same) | boolean | — |
show-critical-path | Critical path (boolean, off by default): runs a CPM pass over the dependency graph + durations to compute total float and adds a .critical highlight to zero-float tasks (color via --oas-gantt-critical-color); read-only | string | — |
show-effort | Effort column (boolean, off by default): the label area becomes two columns (name | effort); effort is right-aligned, header from i18n gantt.effort; cells get an accessible name from i18n gantt.effortValue ("Effort {value}d" unit copy). Missing/negative/non-finite GanttTask.effort renders empty (sanitize drops them, same policy as costRate); huge values switch to scientific notation. Column width token --oas-gantt-effort-width (default 56px); off state renders no nodes and keeps the single-column layout unchanged | string | — |
show-float | Show total/free float (boolean, off by default): computed only on a complete dependency graph; the bar gets a total/free float label plus data-total-float/data-free-float in days. Summaries are excluded; windowed mode skips it with a devWarn. | string | — |
show-resource-load | Resource load panel (boolean, default off): renders time-axis-aligned load buckets below the chart (one row per resource, row height token --oas-gantt-load-row-height; name column shares the side list token --oas-gantt-list-width). Load semantics: covered days accumulate per task (task∩bucket intersection, day-precision inclusive ends; milestones count 0 days as points, summaries excluded); load% = covered days / bucket days, >100% (same-resource overlapping over-allocation) takes the danger channel --oas-gantt-load-over-bg, ≤100% the primary family --oas-gantt-load-bg (dark variants via tokens). Granularity maps from scale (hour/day→day buckets, week→week buckets anchored on week start, month/quarter/year→month buckets), zooms/pans in sync with the chart timeline (reuses update-time axis params without recomputation; pan follows syncHeaderOffset rect-diff, same formula in RTL). Load is computed once per signature over full data (tasks/axis/pool changes recompute; virtual row window does not affect it); empty data / no resource refs fall back to the i18n empty state. ARIA: panel role="img" + aria-label summary (resource count · peak resource and percentage), not in tab order. With pool on, row names come from the pool; otherwise ids. Skipped in windowed mode with a devWarn (full-data semantics). Pure implementation in shared/resource-load.ts (shared with the data/resource/load helper entry) | string | — |
show-status-line | Status line + planned-progress ticks (boolean, off by default): (1) renders a vertical progress line at status-date on the timeline (token --oas-gantt-status-line-color, falls back to the warning color family; status-date is not parsed while the switch is off — zero added cost on the default path); (2) inside each task bar draws a narrow tick at the planned ratio and writes data-plan-ratio (0-1, two decimals) — the planned ratio uses inclusive day granularity: calendar-day difference between status-day and start (status day counted, start day = 1), clamped to the duration (same formula as computeEvm's planned); milestones use the binary ratio (0 before / 1 after), summaries draw none; the tick is display-only — no coloring, no warnings | string | — |
show-today | Today line (on by default; false to disable) | string | — |
show-variance | Render a Δ±Nd variance badge after the row name when a baseline exists; exposes data-start-delta/data-end-delta/data-duration-delta/data-progress-delta | string | — |
snap | Snap drags to the current scale unit (on by default; false shifts by pixel ratio and keeps time precision) | string | — |
status-date | Status date ('YYYY-MM-DD', hour scale may carry a time): the reference date for show-status-line; invalid/missing falls back to today (server-side today under SSR — pass it explicitly when snapshot determinism matters) | string | — |
stripe | Row zebra striping (boolean, off by default): tints rows by the absolute row index parity (stable under virtualization/windowing, no DOM-order flicker); color via --oas-gantt-row-stripe-bg (default --oas-color-bg-hover); selection/weekend backgrounds override the stripe | string | — |
task-columns | Task grid panel (JSON array, off by default): declarative multi-column label area [{ key, title?, width?, align? }] — key points at any GanttTask field (custom passthrough included; the task name joins via {"key":"name"}); title falls back to the key; width is px (unset columns share remaining space via flex:1); align is left (default)/center/right (right maps to inline-end, mirrored in RTL). Cell values are display-only: undefined/null empty, numbers stringified, objects JSON.stringify. With template[slot="row"] present the template wins (task-columns ignored + one devWarn); with show-effort on the grid wins (effort not rendered separately — declare {"key":"effort"} to keep it). Invalid JSON / zero valid entries devWarn once and fall back to the single-column form; [] is an explicit silent clear. Default (neither this nor checkable) keeps the single-column form node-for-node unchanged | string | — |
tasks | Gantt tasks (JSON): [{ id?, name, start, end?, type?, progress?, parent?, children?, dependencies?, color?, disabled?, expanded?, baseline? (start/end?/progress?), baselines? ([{ id, start, end?, progress? }] multiple baselines; wins over the single baseline when both are present), resources?, deadline?, deadlines?, constraint? ('asap'|'snet'|'mso'|'fnlt'), constraintDate?, effort? (effort estimate in days, fractional allowed, display-only — never feeds scheduling) }] — flat parent pointers are the primary contract; nested children are flattened automatically; explicit type:"milestone" takes precedence (rendered as milestone even with end, which is ignored) but a task with children is always a summary; no end also infers milestone; start/end are swapped automatically when start is after end | GanttTask[] | [] |
total | Full row (task) count in windowed mode; 0 or invalid disables windowed (falls back to local mode) | string | — |
weekends | Weekend column highlights (on by default; applies on day/hour tiers; false to disable) | string | — |
window-start | Absolute row index (within the full dataset) of the first row in the slice (windowed mode) | string | 0 |
windowed | Server-side row-window mode (boolean, off by default): with total / window-start the host supplies only the visible window slice (rendered by absolute row index); when the expected row window is not covered, oas-window-request is emitted for the host to refill. Local full-dataset capabilities (auto-schedule / critical path) would be wrong on partial data and are skipped with a devWarn. Non-windowed behavior unchanged | boolean | — |
workdays | Working weekdays (JSON [0-6], 0=Sunday…6=Saturday; opt-in, absent/empty = unrestricted): auto-schedule results snap to the next working day (combined with holidays) | string | — |
Property (JS property; see each row for attribute reflection)
| Property | Description | Type | Default |
|---|---|---|---|
resourcePool | Resource pool instance (isolation channel, JS-only property): el.resourcePool = createResourcePool() switches the pool consumers (tooltip resource names / over-allocation conflicts / load panel) to that instance, recomputing immediately on write (no manual update); null / non-instance values restore the shared singleton getSharedResourcePool() (default channel, backward compatible); reads return the active pool | ResourcePool | null | — |
selection | Selected task ids (string[]): el.selection reads (copy); el.selection = [...] writes (re-renders selection + dispatches oas-selection-change); removeTasks(ids) batch-removes (with descendants) | string[] | — |
tasks | Gantt tasks (GanttTask[]): el.tasks reads (copy; nested input already flattened to parent pointers); el.tasks = [...] writes (syncs the tasks attribute + re-renders + dispatches oas-tasks-change) | GanttTask[] | [] |
Methods
| Method | Signature | Description |
|---|---|---|
updateTask | updateTask(id: string, patch: Partial<GanttTask>): boolean | Incrementally update a single task by id (shallow-merges the patch, then runs sanitize; returns false when the id is missing or the patch is invalid) |
scrollToTask | scrollToTask(id: string): void | Scroll to the given task row (delegates to the internal viewport under virtual scrolling; the target row is centered vertically); no-op when not found |
scrollToDate | scrollToDate(date: string): void | Scroll to the given date (centered horizontally); invalid dates are ignored. RTL uses the real browser negative scrollLeft model |
scrollToToday | scrollToToday(): void | Scroll to today |
undo | undo(): boolean | Undo the most recent task data commit; returns whether anything was actually undone |
redo | redo(): boolean | Redo the most recent undo; returns whether anything was actually redone |
clearHistory | clearHistory(): void | Clear the undo/redo history (current tasks are unchanged) |
removeTasks | removeTasks(ids: string[]): void | Delete tasks in bulk (including their descendants); missing ids are ignored |
addTask | addTask(task: Partial<GanttTask>, opts: { parent?: string | null; before?: string; after?: string }): string | Add a task (imperative authoring channel): returns the new task id; invalid input returns '' (no changes, no events) |
moveTask | moveTask(id: string, opts: { parent?: string | null; index?: number }): boolean | Move a task to position index under the given parent (opts.parent omitted keeps the current parent; null moves it to the root level) |
duplicateTask | duplicateTask(id: string, opts: { id?: string; name?: string; parent?: string | null }): string | null | Duplicate a task and all its descendants (deep copy, new ids, parent pointers remapped to the new ids), inserted right after the original subtree, returning the new root id |
addDependency | addDependency(taskId: string, dep: { id: string; type?: 'fs' | 'ss' | 'ff' | 'sf'; lag?: number }): boolean | Add a dependency (successor taskId depends on dep.id): type defaults to fs; the optional lag (days, may be negative) is omitted by default (equivalent to 0) |
removeDependency | removeDependency(taskId: string, dep: { id: string; type?: 'fs' | 'ss' | 'ff' | 'sf' }): boolean | Remove a dependency: when dep.type is given only that (id,type) is removed; otherwise all types for that id are removed. Returns false when not found |
updateDependency | updateDependency(taskId: string, from: { id: string; type?: 'fs' | 'ss' | 'ff' | 'sf'; lag?: number }, to: { id: string; type?: 'fs' | 'ss' | 'ff' | 'sf'; lag?: number }): boolean | Rewrite a dependency: returns false when from is not found, to.id does not exist or points to itself, or nothing actually changes (including lag) |
updateTasks | updateTasks(patches: Array<{ id: string } & Partial<GanttTask>>): number | Shallow-merge in bulk (per item: skip when the id does not exist; skip the item when a non-empty end fails to parse; otherwise run sanitize per item) |
levelConflicts | levelConflicts(options: GanttLevelOptions): GanttLevelResult | Automatic schedule avoidance (manual, requires pool): shifts the victim of each registered-resource conflict forward until conflict-free or maxIter (default 500; truncation reported honestly). Victim order: disabled / empty calendar days / constraint=mso never yield; deadline holders yield after non-holders (among holders the latest deadline yields last); later start first; later input order first. Day steps preserve wall clock and duration; working-day snap after convergence with a recheck loop. Returns { moved, unresolved, truncated, skipped }; moved is already applied (zero moves = zero writes, zero events, zero history, idempotent); guards (pool off / windowed / readonly / dates-readonly) devWarn + empty resultMode options.mode (default 'shift'): 'reassign' reassigns the victim — dates untouched, the conflicting resource replaced by a pool resource with conflict-free headroom for the whole span (target criterion shares the detection's source: no new conflicts on the target; calendar-unschedulable candidates are skipped too — a probe task with the candidate swapped in must not have an empty days set, so resources with shifts: [] or an empty workdays intersection are never picked even when idle; multi-resource tasks only replace the conflicting id; with no feasible target the pair is reported honestly in unresolved, never degraded into shifting; each successful reassign counts as one step). Invalid values fall back to shift with a devWarn once. In reassign mode, moved entries carry the full reassigned resources array, committed via one updateTasks call (one undo restores both dates and assignments). |
zoomIn | zoomIn(): void | Step one level finer (writes the scale attribute; existing callbacks dispatch oas-scale-change); no-op at the finest level |
zoomOut | zoomOut(): void | Step one level coarser; no-op at the coarsest level |
fit | fit(): void | Zoom to fit all tasks: picks the finest level where "columns for the span in that unit × the minimum column width at that level ≤ available width" |
Events
| Event | Description |
|---|---|
oas-dependencies-change | Dispatched when a link drag creates a dependency or a selected link is deleted, detail: { taskId, dependencies } (taskId is the successor whose dependencies changed) |
oas-expand-change | Dispatched on row tree collapse/expand, detail: |
oas-history-change | With history enabled, dispatched after each undoable commit/undo/redo/clear, detail: { canUndo, canRedo, action } (change/undo/redo/clear) |
oas-level | Emitted before avoidance results are applied (levelConflicts with actual movement; zero moves emit nothing), detail: { moved, unresolved, truncated } (moved = final state of shifted tasks [{ id, start, end }], already applied by the call; unresolved = conflict pairs remaining in the final check; truncated = maxIter cap reached). Event order: oas-level → oas-tasks-change; in reassign mode, moved entries carry resources (the full reassigned array) |
oas-progress-change | Dispatched when a progress handle drag settles, detail: |
oas-range-request | Emitted when the time axis is host-managed (range-start/range-end) and the visible time window approaches an axis edge; detail: { startMs, endMs, reason } (the neighbouring range requested). The same expected range is not emitted twice |
oas-reparent | Dispatched when a row drag reparent/reorder settles, detail: { id, parent, index } (parent null means root level; index is the sibling position) |
oas-reschedule | Dispatched when auto-scheduling moved successor tasks (auto-schedule on), detail: { ids } (ids of the rescheduled tasks) |
oas-resource-conflict | Emitted with pool enabled when the over-allocation result is computed (idempotent: not re-emitted for the same snapshot; re-emitted after data/pool changes, empty array on resolution), detail: { conflicts } ([{ taskA, taskB, resourceId, overlapStart, overlapEnd }], taskA precedes taskB in input order, overlap dates are inclusive day-precision) |
oas-scale-change | Dispatched when the scale attribute changes, detail: { scale }; not dispatched on initial absorption |
oas-selection-change | Dispatched when the multi-select set changes (click / keyboard / property write), detail: { ids } (selected task ids) |
oas-task-add | Dispatched after imperative creation (addTask / duplicateTask / creatable inline create), detail: { id, task } (id is the new task id) |
oas-task-change | Dispatched when a drag/resize/keyboard reschedule settles (pointerup), detail: { id, task, oldStart, oldEnd, start, end }; not dispatched on zero movement |
oas-task-click | Dispatched on task bar/milestone click, detail: |
oas-task-dblclick | Dispatched on task bar double-click, detail: { id, task } — hosts attach an edit form |
oas-task-render | Dispatched after each task bar renders, detail: { task, element } — hosts may rewrite bar DOM |
oas-tasks-change | Dispatched on task data change (programmatic tasks write / updateTask / drag write-back), detail: |
oas-window-request | Emitted in windowed mode when the expected row window is not covered by the loaded range; detail: { start, end, reason } (half-open, absolute row indices; reason is init / scroll / resize / data). The same expected window is not emitted twice |
Slots
| Name | Description |
|---|---|
template[slot="empty"] | Empty-state content (defaults to "No tasks") |
template[slot="row"] | Custom row-name template (cloned per row into .name; [data-task-name] gets the task name; may contain controls to render/edit custom fields such as an assignee; row drag/select does not hijack those controls) |
template[slot="task"] | Task bar label template (cloned into the bar; [data-task-name] nodes get the task name) |
template[slot="tooltip"] | Hover tooltip template ([data-task-name] / [data-task-range] / [data-task-progress] bind points) |
CSS Variables
| CSS Variable | Description | Default |
|---|---|---|
--oas-gantt-bar-bg | — | color-mix(in srgb, var(--oas-gantt-bar-color, var(--oas-color-primary)) 22%, var(--oas-color-bg)) |
--oas-gantt-bar-height | — | 22px |
--oas-gantt-bar-progress-bg | — | var(--oas-gantt-bar-color, var(--oas-color-primary)) |
--oas-gantt-baseline-color | Baseline bar color (default translucent secondary text) | color-mix(in srgb, var(--oas-color-text-secondary-strong) 55%, transparent) |
--oas-gantt-baseline-progress-color | — | var(--oas-color-text-secondary-strong) |
--oas-gantt-check-width | Check column width (task-columns + checkable task grid, default 32px; shared by the header and row check cells) | 32px |
--oas-gantt-conflict-color | Conflict (negative-float) highlight color (default --oas-color-danger) | var(--oas-color-danger-text) |
--oas-gantt-critical-color | Critical-path highlight color (default --oas-color-danger) | var(--oas-color-danger) |
--oas-gantt-deadline-color | Deadline marker color (default --oas-color-danger) | var(--oas-color-danger) |
--oas-gantt-effort-width | Effort column width (show-effort, default 56px; shared by the header and row cells) | 56px |
--oas-gantt-grid-line-color | — | var(--oas-color-border) |
--oas-gantt-header-bg | — | var(--oas-color-bg) |
--oas-gantt-header-height | — | 44px |
--oas-gantt-height | — | 320px |
--oas-gantt-holiday-bg | — | color-mix(in srgb, var(--oas-color-warning) 12%, var(--oas-color-bg)) |
--oas-gantt-lane-load-width | Embedded lane load thumbnail width (end-of-row overview strip on group-by-resource lane summary rows) | default 72px | 72px |
--oas-gantt-link-color | — | var(--oas-color-primary) |
--oas-gantt-list-width | — | 220px |
--oas-gantt-load-bg | Load bucket bar color (≤100%, default primary 45% mixed over bg; dark variants via tokens) | color-mix(in srgb, var(--oas-color-primary) 45%, var(--oas-color-bg)) |
--oas-gantt-load-max-height | Load panel body max height (show-resource-load, scrolls vertically beyond it; default 240px, data is not truncated) | 240px |
--oas-gantt-load-over-bg | Load bucket bar over-allocation color (>100%, default danger; dark variants via tokens) | var(--oas-color-danger) |
--oas-gantt-load-row-height | Load panel row height (show-resource-load, default 24px) | 24px |
--oas-gantt-milestone-color | — | var(--oas-color-warning) |
--oas-gantt-row-height | — | 36px |
--oas-gantt-row-hover-bg | — | var(--oas-color-bg-hover) |
--oas-gantt-row-stripe-bg | — | var(--oas-color-bg-hover) |
--oas-gantt-status-line-color | Status line / planned-progress tick color (show-status-line, default --oas-color-warning) | var(--oas-color-warning) |
--oas-gantt-summary-bg | — | var(--oas-color-text-secondary-strong) |
--oas-gantt-today-color | — | var(--oas-color-danger) |
--oas-gantt-weekend-bg | — | color-mix(in srgb, var(--oas-color-bg-hover) 60%, var(--oas-color-bg)) |