Gantt Charts

A Gantt Chart or timeline that displays a list of events in chronological order.

The GanttChart (Timeline) component lets you visualize project schedules as horizontal bars across a time axis, making it easy to track tasks and dependencies in your Nuxt app.

Basic Usage

Props

PropTypeDefaultDescription
dataT[]RequiredArray of timeline events. Each element represents a task or item on the timeline.
categoriesRecord<string, BulletLegendItemInterface>RequiredSeries configuration: name and color for each category.
x(d: T) => numberRequiredAccessor function returning the start time/position for each item.
length(d: T) => numberRequiredAccessor function returning the duration/length for each item.
type(d: T) => stringRequiredAccessor function returning the category type for each item.
heightnumberundefinedHeight of the chart in pixels.
titlestringundefinedOptional title for the timeline chart.
labelWidthnumber220Width of the label area in pixels.
showLabelsbooleantrueIf true, displays labels for each timeline row.
lineWidthnumber12Width of the timeline bars in pixels.
rowHeightnumber24Height of each row in the timeline in pixels.
xNumTicksnumberundefinedDesired number of ticks on the x-axis.
xTickLinebooleanfalseShow tick lines on the x-axis.
xTickFormat(tick: number | Date, i?: number, ticks?: number[] | Date[]) => stringundefinedCustom formatter for x-axis tick labels.
xMinMaxTicksOnlybooleanfalseIf true, only show first and last ticks on the x-axis.
xTickValuesnumber[] | Date[]undefinedForce specific tick values on the x-axis.
xGridLinebooleanfalseShow grid lines along the x-axis.
xDomainLinebooleanfalseShow domain line on the x-axis.
hideLegendbooleanfalseIf true, hides the chart legend.
legendPositionLegendPositionLegendPosition.TopRightPosition of the legend.
legendStylestring | Record<string, string>undefinedCustom CSS style for the legend container.
hideTooltipbooleanfalseIf true, hides the chart tooltip.
tooltipTitleFormatter(data: T) => string | numberundefinedCustom formatter for tooltip titles.
getTooltipText(label: string, index: number, data: T[]) => stringundefinedCustom tooltip text generator function.
crosshairConfigCrosshairConfigundefinedCrosshair configuration for customizing the crosshair line.
xAxisConfigAxisConfigundefinedAxis configuration for customizing the x-axis appearance.
yAxisConfigAxisConfigundefinedAxis configuration for customizing the y-axis appearance.
tooltipTooltipConfigundefinedTooltip configuration (hideDelay, showDelay, followCursor).
durationnumberundefinedAnimation duration in milliseconds.

Events

EventPayloadDescription
click{ event: MouseEvent, data: { index: number, item: T } }Fired when a timeline bar is clicked.
scrollnumberFired when the timeline is scrolled, returns the scroll distance.
labelHoverT | undefinedFired when hovering over a label, returns the item data.

Slots

SlotPropsDescription
labelTooltip{ values: T | undefined }Custom tooltip content for label hover.
fallback{}Fallback content while chart loads.

Data Format

The data should be an array of objects representing timeline items:

types.ts
interface TimelineItem {
  name: string
  color: string
  startDate: number
  endDate: number
  department: string
  description?: string
  label?: string
}

Categories Format

Categories define the visual appearance for each timeline category:

types.ts
interface BulletLegendItemInterface {
  name: string
  color: string
}

type GanttCategories = Record<string, BulletLegendItemInterface>