API & types
The reference surface: what each package exports, the data-model interfaces, the scene shape, and the tables for events, services and commands. Types are shown in TypeScript; the packages ship .d.ts so your editor knows all of this.
Data model
type ViewMode = 'Day' | 'Week' | 'Month'
interface Task {
id: string
name: string
start: string | Date
end: string | Date
kind?: 'task' | 'milestone'
progress?: number // 0–1
dependencies?: string[] // predecessor task ids
className?: string
draggable?: boolean
tooltip?: string
[key: string]: unknown // extra fields for column formatters
}
interface Row {
id: string
name: string
tasks: Task[]
level?: number
parentId?: string
hasChildren?: boolean
expanded?: boolean
[key: string]: unknown
}Engine options
interface GanttOptions {
rows?: Row[]
viewMode?: ViewMode // 'Week'
startDate?: string | Date | null
endDate?: string | Date | null
rowHeight?: number // 50
dayWidth?: number // 60 (× 1.5 Day, × 1 Week, × 0.5 Month)
barPadding?: number // 6
highlightToday?: boolean // true
draggable?: boolean // true
virtualize?: boolean // true
overscanRows?: number // 4
overscanCols?: number // 6
dateAdapter?: DateAdapter // defaultDateAdapter
}GanttEngine
Full method list see The core engine for descriptions.
class GanttEngine {
// registries (public fields)
events: EventBus
commands: CommandRegistry
services: ServiceRegistry
ui: UiRegistry
hooks: { rows: Hook; scene: Hook }
store: Store
constructor(options?: GanttOptions)
// plugins
use(plugin: Plugin): this
hasPlugin(name: string): boolean
removePlugin(name: string): void
destroy(): void
// read
getState(): GanttState
getOptions(): ResolvedOptions
getRows(): Row[]
getScene(): Scene
getTimeScale(): TimeScale
getWindow(): Window | null
// mutate
setRows(rows: Row[]): void
updateTask(id: string, patch: Partial<Task>): boolean
updateTaskDates(id: string, start: string | Date, end: string | Date): boolean
setViewMode(mode: ViewMode): void
selectTask(id: string | null): void
setLoading(loading: boolean): void
setDateAdapter(adapter: DateAdapter): void
setViewport(vp: Viewport): void
setDragPreview(id: string, start: string | Date, end: string | Date): void
clearDragPreview(): void
refresh(): void
// geometry
hitTest(x: number, y: number): { taskId: string; handle: 'left' | 'right' | null } | null
hitTestRegion(x1: number, y1: number, x2: number, y2: number): string[]
// services (sugar over this.services)
provide(key: string, service: unknown): () => void
consume<T>(key: string): T | undefined
onSceneChange(listener: (scene: Scene) => void): () => void
}Scene
interface Scene {
width: number
height: number
layers: SceneLayer[]
}
interface SceneLayer { name: string; primitives: ScenePrimitive[] }
type ScenePrimitive = RectPrim | LinePrim | PathPrim | PolygonPrim | TextPrim
interface BasePrim {
key: string
className?: string
taskId?: string
title?: string
data?: Record<string, string | number> // → data-* attributes
}
interface RectPrim extends BasePrim { type: 'rect'; x; y; width; height; rx? }
interface LinePrim extends BasePrim { type: 'line'; x1; y1; x2; y2 }
interface PathPrim extends BasePrim { type: 'path'; d: string; markerEnd? }
interface PolygonPrim extends BasePrim { type: 'polygon'; points: string; transform? }
interface TextPrim extends BasePrim { type: 'text'; x; y; text; anchor?; baseline? }Base layer order (paint order): backgrounds → grid → dependencies → bars → handles → milestones → labels. Plugins splice their layers in relative to these.
Layout entry (passed to scene hooks)
interface TaskLayout {
task: Task
rowId: string
rowIndex: number
isMilestone: boolean
x: number; y: number; width: number; height: number
cy: number // vertical centre handy for milestones/connectors
}TimeScale
class TimeScale {
start: Date; end: Date; viewMode: ViewMode
dayWidth: number
totalDays: number
width: number
days: Day[]; weeks: Week[]; months: Month[]
dateToX(date: Date): number
xToDayIndex(x: number): number
}
interface Day {
key: string; date: Date; dayOfMonth: number
weekday: string; isWeekend: boolean; isToday: boolean; isoWeek: number
}DateAdapter
Every date operation goes through this interface. Implement it (or spread defaultDateAdapter) for exotic calendars.
interface DateAdapter {
parse(value: string | Date): Date
startOfDay(d: Date): Date
startOfMonth(d: Date): Date
endOfMonth(d: Date): Date
startOfWeek(d: Date): Date
addDays(d: Date, n: number): Date
diffDays(a: Date, b: Date): number
isoWeek(d: Date): number
isWeekend(d: Date): boolean
isSameDay(a: Date, b: Date): boolean
toKey(d: Date): string
weekdayShort(d: Date): string
monthLabel(d: Date): string
monthShort(d: Date): string
}
createIntlAdapter(locale: string, options?: {
weekStartsOn?: number // 0=Sun … 6=Sat
weekend?: number[] // day indices
}): DateAdapterEvents
| Event | Payload |
|---|---|
scene:change | { scene, reason: 'data' | 'viewport' | 'preview' } |
daterange:change | { start, end } |
rows:change | { rows } |
viewmode:change | { viewMode } |
selection:change | { taskId } |
task:click | { task, row, originalEvent } |
task:hover | { task, row, handle, clientX, clientY } |
task:hoverend | {} |
task:dragstart | { task, row, mode } |
task:dragmove | { task, row, mode, start, end, changed } |
task:dragend | { task, row, mode, start, end, changed } |
row:toggle | { rowId } |
Service keys
| Key | Provided by | Shape |
|---|---|---|
gantt:sidebar | plugin-columns | { getColumns, getSidebarWidth, getCellValue, getRowIndent } |
gantt:i18n | plugin-i18n | { t, locale, subscribe, setLocale } |
gantt:viewport | the renderer | { clientToScene(x, y) } |
Constants GANTT_VIEWPORT_SERVICE and UI_SLOTS are exported from core so you don't hardcode the strings.
Commands
| Command | Registered by | Args |
|---|---|---|
columns.set | plugin-columns | (columns) |
tree.toggle / expand / collapse | plugin-tree | (rowId) |
tree.expandAll / collapseAll | plugin-tree | () |
filter.setRowFilter / setTaskFilter | plugin-filter | (predicate) |
filter.clear | plugin-filter | () |
deps.add / remove | plugin-dependencies | (predecessorId, successorId) |
deps.reschedule | plugin-dependencies | () |
baseline.capture / clear | plugin-baseline | () |
Core exports
Everything @ganttkit/core exports. Most apps only touch the first row; the rest are the building blocks renderers and advanced plugins use.
| Group | Exports |
|---|---|
| Engine | GanttEngine |
| Registries & primitives | EventBus, CommandRegistry, ServiceRegistry, UiRegistry, Store, Hook |
| Time | TimeScale, defaultDateAdapter, createIntlAdapter, deriveDateRange, effectiveDayWidth |
| Scene | buildScene, computeTaskLayouts, computeDependencyLinks, contentHeight, hitTestScene, hitTestRegion, SCENE_MARKERS |
| Viewport | resolveWindow, sameViewport |
| Interaction | beginDrag, updateDrag, resolveDraggedDates, dragVisualDelta, resolvePan, stepViewMode, wheelToViewMode |
| Constants | UI_SLOTS, GANTT_VIEWPORT_SERVICE, VIEW_MODE_ORDER, VIEW_MODE_SCALE |
The compute* / buildScene / hitTest* helpers are pure functions the same ones the engine calls internally. A custom renderer or an offline exporter can call them directly without an engine instance.