Skip to content

GGanttRow Component

The GGanttRow component represents a single row in the Gantt chart. It manages the display and interaction of task bars within its scope.

Basic Usage

vue
<template>
  <g-gantt-row
    label="Development Tasks"
    :bars="bars"
    :highlight-on-hover="true"
  />
</template>

Component API

Props

Prop NameTypeDefaultDescription
labelstringRequiredRow label
barsGanttBarObject[]RequiredArray of bar objects
highlightOnHoverbooleanfalseHighlight row on hover
idstring | number``Row identifier
childrenChartRow[][]Array of child rows

Events

Event NamePayloadDescription
drop{ e: MouseEvent, datetime: string | Date }Item dropped on row

Slots

Slot NamePropsDescription
labelNoneCustom row label content
bar-label{ bar: GanttBarObject }Custom bar label content

Bar Configuration (ganttBarConfig)

PropertyTypeDefaultDescription
idstringRequiredUnique identifier for the bar
labelstringundefinedLabel displayed on the bar
htmlstringundefinedCustom HTML content for the bar
hasHandlesbooleanfalseShows resize handles on the bar
immobilebooleanfalseWhen true, bar cannot be moved
bundlestringundefinedIdentifier to group multiple bars
pushOnOverlapbooleanundefinedIf true, pushes other bars when overlapping
pushOnConnectbooleanundefinedIf true, pushes connected bars when moving
dragLimitLeftnumberundefinedLeft limit for dragging
dragLimitRightnumberundefinedRight limit for dragging
styleCSSPropertiesundefinedCustom CSS styles for the bar
classstringundefinedCustom CSS classes for the bar
connectionsGanttBarConnection[]undefinedArray of connections to other bars
milestoneIdstringundefinedIdentifier of milestone associated with the bar

Bar Connection Configuration

The connections property in ganttBarConfig accepts an array of GanttBarConnection objects. Each connection has the following properties:

PropertyTypeDefaultDescription
targetIdstringRequiredID of the target bar to connect to
type'bezier' | 'straight' | 'squared''straight'Visual style of the connection line
colorstring'#ff0000'Color of the connection line
pattern'solid' | 'dot' | 'dash' | 'dashdot''solid'Line pattern style
animatedbooleanfalseWhether the connection should be animated
animationSpeed'slow' | 'normal' | 'fast''normal'Speed of the connection animation

Keyboard Controls

Bars within the row support the following keyboard controls:

KeyActionWith Shift
Left ArrowMove bar backwardMove 12 units
Right ArrowMove bar forwardMove 12 units
Up ArrowExpand barExpand 12 units
Down ArrowShrink barShrink 12 units

The actual unit size depends on the chart's precision setting (hours, days, etc.). The step increment or shift is greater if Shift is held down

Bar Configuration

Each bar in the bars array should follow this structure:

typescript
interface GanttBarObject {
  [key: string]: any;
  ganttBarConfig: {
    id: string;
    label?: string;
    html?: string;
    hasHandles?: boolean;
    immobile?: boolean;
    bundle?: string
    pushOnOverlap?: boolean
    pushOnConnect?: boolean
    dragLimitLeft?: number
    dragLimitRight?: number
    style?: CSSProperties;
    class?: string;
    connections?: GanttBarConnection[];
    milestoneName?: string
  }
}

Example with Custom Bar Configuration

vue
<script setup lang="ts">
const bars = [{
  start: '2024-01-01',
  end: '2024-01-15',
  ganttBarConfig: {
    id: '1',
    label: 'Task 1',
    hasHandles: true,
    style: {
      background: '#42b883',
      borderRadius: '4px'
    },
    connections: [{
      targetId: '2',
      type: 'straight'
    }]
  }
}]
</script>

<template>
  <g-gantt-row
    label="Project Phase"
    :bars="bars"
  >
    <template #bar-label="{ bar }">
      <div class="custom-label">
        {{ bar.ganttBarConfig.label }}
      </div>
    </template>
  </g-gantt-row>
</template>

Best Practices

  1. Use unique IDs for each bar
  2. Keep bar data immutable
  3. Implement error boundaries for bar rendering
  4. Handle edge cases for date ranges
  5. Consider performance with large datasets

Each component documentation includes a comprehensive API reference, practical examples, and best practices for implementation. The content maintains a professional tone while being accessible to developers of all skill levels.

Released under the MIT License.