Constructor

Create a new timeline instance.

new TempisTimeline(context: string | HTMLCanvasElement, options: TempisTimelineOptions)

The context parameter accepts either a CSS selector string pointing to a <canvas> element, or a direct reference to one.

// Using a selector
const timeline = new TempisTimeline('#my-canvas', { items: [...] });

// Using an element reference
const canvas = document.getElementById('my-canvas') as HTMLCanvasElement;
const timeline = new TempisTimeline(canvas, { items: [...] });

TempisTimelineOptions

PropertyTypeDefaultDescription
itemsTempisTimelineItem[]requiredThe items to display.
responsivebooleanfalseWhether to automatically resize the canvas to match parent container dimensions.
verticalFill"content" | "fill-canvas" | "grow-canvas""content"Defines how the timeline fills vertical space.
rtlbooleanfalseWhether to use right-to-left rendering.
stackMode"compact" | "stable""stable"The item stacking behaviour.
selection"none" | "single" | "multi""none"Item selection mode.
categoriesTempisTimelineCategory[]Item categories.
bandsTempisTimelineBand[]Timeline bands.
dependenciesTempisTimelineDependency[]Item dependencies rendered as connector arrows.
rangeTempisTimelineRangeOptionsRange configuration.
legendTempisTimelineLegendOptionsLegend configuration.
tooltipTempisTimelineTooltipOptionsTooltip configuration.
styleTempisTimelineStyleOptionsStyle overrides.
scrollbarTempisTimelineScrollbarOptionsScrollbar options.
groupingTempisTimelineGroupingOptionsGrouping options.
accessibilityTempisTimelineAccessibilityOptionsAccessibility options (keyboard, ARIA).
minimapTempisTimelineMinimapOptionsMinimap overview bar. Provide to enable.
When using responsive: true, the canvas must be inside a container with explicit dimensions. The timeline resizes to fill its parent — if the parent has no width or height, the canvas will collapse to zero.

Instance Methods

MethodDescriptionDetails
setItems(items)Replace all items and redraw.Items
getItems()Get current item definitions.Items
setCategories(categories)Replace all categories and redraw.Categories
getCategories()Get current category definitions.Categories
setBands(bands)Replace all bands and redraw.Bands
setDependencies(deps)Replace all dependencies and redraw.Dependencies
setGroupCollapsed(group, collapsed?)Set or toggle a group's collapsed state.Grouping
isGroupCollapsed(group)Check if a group is collapsed.Grouping
focus(options?)Navigate to an item, date, or range.Focus
getRange()Get the current visible range.Range
setSelection(ids)Programmatically select items by ID.Selection
getSelection()Get selected item IDs.Selection
clearSelection()Deselect all items.Selection
toImage(options?)Export as PNG, JPEG, or WebP blob.Image Export
redraw()Force a redraw.
destroy()Clean up all listeners and resources.

destroy()

Removes all event listeners, disconnects observers, cancels animations, and clears the canvas. Always call this before removing the timeline from the DOM to prevent memory leaks.

In single-page applications, always call destroy() when removing the timeline from the DOM to prevent memory leaks from orphaned event listeners and resize observers.
timeline.destroy();

In frameworks like React, the <TempisTimeline> component handles this automatically on unmount.