Skip to content

GGanttChart Component

The GGanttChart component is the main container component for creating Gantt charts in your Vue 3 application. It handles the overall layout, time management, and coordination between all child components.

Basic Usage

Here's a minimal example of using the GGanttChart component:

vue
<template>
  <g-gantt-chart
    :chart-start="chartStart"
    :chart-end="chartEnd"
    :precision="precision"
    :bar-start="barStart"
    :bar-end="barEnd"
  >
    <g-gantt-row
      v-for="row in rows"
      :key="row.label"
      :label="row.label"
      :bars="row.bars"
    />
  </g-gantt-chart>
</template>

Component API

Props

Prop NameTypeDefaultDescription
chartStartstring | DateRequiredThe start date of the chart's visible range
chartEndstring | DateRequiredThe end date of the chart's visible range
precision'hour' | 'day' | 'week' | 'month''day'Time unit precision for the chart
barStartstringRequiredProperty name for bar start dates
barEndstringRequiredProperty name for bar end dates
widthstring'100%'Chart width
hideTimeaxisbooleanfalseHide the time axis
colorSchemestring | ColorScheme'default'Color scheme for the chart
gridbooleanfalseShow background grid
pushOnOverlapbooleanfalsePush bars when they overlap
pushOnConnectbooleanfalsePush connected bars when moving
noOverlapbooleanfalsePrevent bars from overlapping
rowHeightnumber40Height of each row in pixels
fontstring'inherit'Font family for the chart
labelColumnTitlestring''Title for the label column
labelColumnWidthstring'150px'Width of the label column
sortablebooleantrueEnable row sorting functionality
multiColumnLabelLabelColumnConfig[][]Array of columns to display in the header
commandsbooleantrueShow chart control commands
enableMinutesbooleanfalseEnable minutes precision for hour view
enableConnectionsbooleantrueEnable connections between bars
defaultConnectionTypeConnectionType'straight'Default type for bar connections
defaultConnectionColorstring'#ff0000'Default color for connections
defaultConnectionPatternConnectionPattern'solid'Default pattern for connections
defaultConnectionAnimatedbooleanfalseEnable connection animations
defaultConnectionAnimationSpeedConnectionSpeed'normal'Speed of connection animations
maxRowsnumber0Maximum number of visible rows
initialSortSortState'none'Initial sorting column and direction
initialRowsChartRow[][]Initial rows data
currentTimebooleanfalseShow current time indicator
currentTimeLabelstring''Label for current time indicator
dateFormatstring | false'YYYY-MM-DD HH:mm'Format for dates
milestonesGanttMilestone[][]List of milestone
holidayHighlightstring``Country Cody of date-holidays
rowClass(row: ChartRow) => string``Method to add classes to data rows
rowLabelClass(row: ChartRow) => string``Method to add classes to label rows
dayOptionLabelDayOptionLabel[]['day']Customization for time unit day
localestring'en'Locale for dayjs

Events

Event NamePayloadDescription
click-bar{ bar: GanttBarObject, e: MouseEvent }Bar clicked
mousedown-bar{ bar: GanttBarObject, e: MouseEvent }Mouse down on bar
mouseup-bar{ bar: GanttBarObject, e: MouseEvent }Mouse up on bar
dblclick-bar{ bar: GanttBarObject, e: MouseEvent }Bar double clicked
dragstart-bar{ bar: GanttBarObject, e: MouseEvent }Bar drag started
drag-bar{ bar: GanttBarObject, e: MouseEvent }Bar being dragged
dragend-bar{ bar: GanttBarObject, e: MouseEvent, movedBars?: Map }Bar drag ended
sort{ direction: SortState }Sort rows column and direction

Slots

Slot NamePropsDescription
defaultNoneMain content slot for GGanttRow components
label-column-titleNoneCustom label column header
label-column-NoneCustom label column row
current-time-labelNoneCustom current time indicator label
bar-label{ bar: GanttBarObject }Custom bars label content
milestone{ bar: GanttBarObject }Custom milestones content
milestone-{ bar: GanttBarObject }Custom specific milestone content

Advanced Features

Keyboard Navigation

The component supports keyboard navigation:

  • Arrow keys for moving through the timeline
  • +/- for zooming
  • Page Up/Down for faster navigation
  • Home/End for jumping to start/end

Time Management

vue
<template>
  <g-gantt-chart
    chart-start="2024-01-01"
    chart-end="2024-12-31"
    precision="day"
    :enable-minutes="true"
    date-format="YYYY-MM-DD HH:mm"
  />
</template>

Released under the MIT License.