Skip to content

Gantt-Chart

A high-performance Gantt chart component supporting Tree Data, Auto-scheduling, Virtual scrolling and Resource conflict detection.


TIP

YH-UI GanttChart is designed for complex project management scenarios, supporting virtual scrolling for tens of thousands of tasks, dynamic tree display, auto-scheduling based on dependencies, and milestone visualization.

Basic Usage

The Gantt chart component aims to provide an intuitive timeline view of task progress and dependency relationships.

search
Zoom
Task Name
Start Date
End Date
R&D Center (Rollup)
2024-03-01
2024-03-31
Regression Testing
2024-04-01
2024-04-10
Product Release (Milestone)
2024-04-12
2024-04-12
2024-02
2024-03
2024-04
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
Regression Testing
Basic Usage

Interaction, Search & Zoom

Built-in integrated toolbar supports keyword search, stepless zooming (slider adjustment), and one-click view mode switching. With draggable enabled, users can adjust task time and progress via drag-and-drop.

search
Zoom
Task Name
Start Date
End Date
R&D Center (Rollup)
2024-03-01
2024-03-31
Regression Testing
2024-04-01
2024-04-10
Product Release (Milestone)
2024-04-12
2024-04-12
2024-02
2024-03
2024-04
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
Regression Testing
Interaction Example

Milestone

When a task's start and end dates are the same, the component automatically renders it as a diamond-shaped symbol, which is a Milestone.

Auto Recognition

You only need to set startDate and endDate to the same value (e.g., midnight of the same day), and the component will internally convert it to milestone style.

Tree Structure & Rollup

Supports task hierarchy nesting. The parent task's time range is automatically rolled up from its children. Additionally, Tree Lines are automatically rendered in the table to facilitate observation of complex relationships.

Summary Bar Style

Summary tasks are displayed with a special "Summary Bar" on the timeline, featuring downward vertical marks (ears) at both ends, conforming to industrial Gantt chart visual standards.

search
Zoom
Task Name
Start Date
End Date
Core Engine Dev (Rollup)
2024-03-01
2024-03-31
2024-02
2024-03
2024-04
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
01
02
03
04
05
06
07
Tree View Demo

Auto-scheduling

Modifying a predecessor task will cause successor tasks to automatically shift accordingly.

search
Zoom
Task Name
Start Date
End Date
Predecessor (Drag me)
2024-03-01
2024-03-05
Successor Task
2024-03-10
2024-03-15
2024-02
2024-03
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
Predecessor (Drag me)
Successor Task
Auto-scheduling Demo

Large Data Virtual Scrolling

Supports rendering massive amounts of data without performance lag.

search
Zoom
Task Name
Start Date
End Date
Test Task #0
2024-03-01
2024-03-05
Test Task #1
2024-03-01
2024-03-05
Test Task #2
2024-03-01
2024-03-05
Test Task #3
2024-03-01
2024-03-05
Test Task #4
2024-03-01
2024-03-05
Test Task #5
2024-03-01
2024-03-05
Test Task #6
2024-03-01
2024-03-05
Test Task #7
2024-03-01
2024-03-05
Test Task #8
2024-03-01
2024-03-05
Test Task #9
2024-03-01
2024-03-05
Test Task #10
2024-03-01
2024-03-05
Test Task #11
2024-03-01
2024-03-05
Test Task #12
2024-03-01
2024-03-05
Test Task #13
2024-03-01
2024-03-05
Test Task #14
2024-03-01
2024-03-05
Test Task #15
2024-03-01
2024-03-05
Test Task #16
2024-03-01
2024-03-05
2024-02
2024-03
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
Test Task #0
Test Task #1
Test Task #2
Test Task #3
Test Task #4
Test Task #5
Test Task #6
Test Task #7
Test Task #8
Test Task #9
Test Task #10
Test Task #11
Test Task #12
Test Task #13
Test Task #14
Test Task #15
Test Task #16
Virtual Scrolling Demo

Resource Conflict Detection

Intelligently identifies and highlights resource allocation conflicts.

search
Zoom
Task Name
Start Date
End Date
Module A Dev
2024-03-01
2024-03-10
Req Review (Conflict)
2024-03-05
2024-03-06
2024-02
2024-03
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
Module A Dev
Req Review (Conflict)
Resource Conflict Demo

Advanced Usage

Custom Task Rendering

The task-content slot allows full customization of the task block content, adding icons, progress percentages, etc.

search
Zoom
Task Name
Start Date
End Date
Frontend Dev
2024-03-01
2024-03-10
Backend Dev
2024-03-05
2024-03-15
Testing
2024-03-12
2024-03-20
2024-02
2024-03
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
TaskFrontend Dev75%
TaskBackend Dev50%
TaskTesting30%
Custom Task Rendering

Custom Table Cells

The table-cell slot provides custom rendering for each cell in the sidebar table, enabling status tags, avatars, and other complex displays.

search
Zoom
Task Name
Status
Assignee
Requirements Analysis
Completed
John
System Design
Planned
Jane
Coding Implementation
In Progress
Bob
2024-02
2024-03
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Requirements Analysis
System Design
Coding Implementation
Custom Table Cells

Event Handling

Listen to various interaction events to implement custom logic. Supports click, double-click, drag, etc.

Event Log:
Click, double-click or drag tasks to see event triggers...
search
Zoom
Task Name
Start Date
End Date
Try clicking me
2024-03-01
2024-03-05
Try dragging me
2024-03-06
2024-03-10
Try double-clicking me
2024-03-11
2024-03-15
2024-02
2024-03
23
24
25
26
27
28
29
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
Try clicking me
Try dragging me
Try double-clicking me
Event Handling Example

Best Practices

Performance Optimization

  1. Use Virtual Scrolling for Large Data: When the number of tasks exceeds 100, it is recommended to enable the virtual property.
  2. Set Appropriate View Mode: For long-duration projects, use week or month views.
  3. On-demand Loading: For deep tree structures, consider lazy loading child nodes.
vue
<yh-gantt-chart v-model:data="tasks" :columns="columns" virtual view-mode="week" :row-height="40" />

Data Structure Recommendations

typescript
// ✅ Recommended: Use ISO 8601 date format
const task = {
  id: 'task-1',
  name: 'Dev Task',
  startDate: '2024-03-01',
  endDate: '2024-03-15',
  progress: 60
}

// ✅ Recommended: Explicit dependency relationships
const tasks = [
  { id: 't1', name: 'Req Analysis', startDate: '2024-03-01', endDate: '2024-03-05' },
  {
    id: 't2',
    name: 'Design',
    startDate: '2024-03-06',
    endDate: '2024-03-10',
    dependencies: ['t1']
  },
  { id: 't3', name: 'Dev', startDate: '2024-03-11', endDate: '2024-03-20', dependencies: ['t2'] }
]

Resource Management

Allocate resources rationally to avoid conflicts:

typescript
const tasks = [
  {
    id: 'task-1',
    name: 'Frontend Dev',
    startDate: '2024-03-01',
    endDate: '2024-03-10',
    assignees: ['developer-1', 'developer-2']
  },
  {
    id: 'task-2',
    name: 'Backend Dev',
    startDate: '2024-03-01',
    endDate: '2024-03-10',
    assignees: ['developer-3'] // Avoid resource conflict with task-1
  }
]

FAQ

How to export Gantt chart as an image?

You can use the html2canvas library:

typescript
import html2canvas from 'html2canvas'

const exportGanttChart = async () => {
  const ganttElement = document.querySelector('.yh-gantt-chart')
  if (ganttElement) {
    const canvas = await html2canvas(ganttElement)
    const link = document.createElement('a')
    link.download = 'gantt-chart.png'
    link.href = canvas.toDataURL()
    link.click()
  }
}

How to implement batch operations on tasks?

typescript
// Batch update task status
const updateTasksStatus = (taskIds: string[], status: string) => {
  tasks.value = tasks.value.map((task) => {
    if (taskIds.includes(task.id)) {
      return { ...task, status }
    }
    return task
  })
}

// Batch delete tasks
const deleteTasks = (taskIds: string[]) => {
  tasks.value = tasks.value.filter((task) => !taskIds.includes(task.id))
}

How to customize timeline scale?

Adjust the timeline display via view-mode and zoom:

vue
<yh-gantt-chart v-model:data="tasks" v-model:view-mode="viewMode" :columns="columns" />

<!-- Toolbar will automatically show view switcher buttons -->

How to handle cross-timezone tasks?

Uniformly use UTC time or explicitly specify the timezone:

typescript
import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
import timezone from 'dayjs/plugin/timezone'

dayjs.extend(utc)
dayjs.extend(timezone)

const task = {
  id: 'task-1',
  name: 'Global Meeting',
  startDate: dayjs.tz('2024-03-01 09:00', 'America/New_York').toISOString(),
  endDate: dayjs.tz('2024-03-01 10:00', 'America/New_York').toISOString()
}

Use in Nuxt

YhGanttChart can be used directly in Nuxt 3/4 projects. After registering YH-UI, the component supports SSR for the static structure, and interactive behaviors continue to work normally after hydration.

search
Zoom
Task Name
Start Date
End Date
Nuxt SSR Task
2024-03-01
2024-03-05
State Syncing
2024-03-06
2024-03-10
2024-02
2024-03
W7
W8
W9
W10
W11
Nuxt SSR Task
State Syncing
Usage in Nuxt

SSR Compatibility Notes:

  • First Screen Rendering: The initial structure, task list, and timeline scales support SSR, improving SEO and speed.
  • State Sync: Supports two-way binding for v-model:data and v-model:view-mode, ensuring perfect hydration.
  • Auto-import: All components and types are directly usable after enabling YH-UI in Nuxt config.
  • ⚠️ Browser APIs: Dragging interaction and scroll monitoring only work in the client environment; environment isolation is already handled.

Production Choice

For large projects with thousands of tasks, it is recommended to enable the virtual attribute in Nuxt to obtain ultimate scrolling performance.

API

Props

NameDescriptionTypeDefault
dataTask data, supports tree structureGanttTask[][]
columnsLeft table column definitionsGanttColumn[][{ prop: 'name', label: 'Task Name', width: 200 }]
view-modeView mode, controls timeline granularity'day' | 'week' | 'month' | 'year''day'
start-dateForced Gantt chart start dateDate | stringAuto-calculated
end-dateForced Gantt chart end dateDate | stringAuto-calculated
draggableWhether to allow task timing draggingbooleanfalse
progress-draggableWhether to allow progress draggingbooleanfalse
auto-scheduleWhether to enable auto-schedulingbooleantrue
virtualEnable virtual scrollingbooleanfalse
show-resource-loadShow resource load detectionbooleantrue
show-dependenciesShow task dependency linesbooleantrue
row-heightRow height (px)number40
header-heightHeader height (px)number60
borderedWhether to show bordersbooleantrue
loadingWhether to show loading statusbooleanfalse
teleportedWhether internal tooltips are teleported to bodybooleantrue
theme-overridesTheme variable overridesComponentThemeVarsundefined

Events

NameDescriptionParameters
update:dataTriggered when task data is updated(data: GanttTask[])
update:view-modeTriggered when view mode changes(mode: GanttViewMode)
task-clickTriggered when a task block is clicked(task: GanttTask, event: MouseEvent)
task-dblclickTriggered when a task block is double-clicked(task: GanttTask, event: MouseEvent)
task-drag-endTriggered when task dragging ends(task: GanttTask)
progress-drag-endTriggered when progress dragging ends(task: GanttTask)
dependency-clickTriggered when a dependency line is clicked(from: GanttTask, to: GanttTask, event: MouseEvent)

Slots

NameDescriptionParameters
task-contentCustom content inside task block{ task: GanttTask }
table-cellCustom sidebar table cell{ row: GanttTask, column: GanttColumn, index: number }
tooltipCustom hover tooltip content{ task: GanttTask }

Expose

This component does not expose public instance methods or properties.

GanttTask Type

NameDescriptionTypeRequired
idUnique IDstring | numberYes
nameTask namestringYes
startDateStart datestring | number | DateYes
endDateEnd datestring | number | DateYes
progressProgress (0-100)numberNo
dependenciesList of dependent task IDs(string | number)[]No
childrenList of child tasksGanttTask[]No
assigneesList of resource IDsstring[]No
statusPreset status token'success' | 'warning' | 'danger' | 'info' | 'default'No
colorCustom background colorstringNo
textColorCustom text colorstringNo
parentIdParent task IDstring | numberNo
expandedExpanded statebooleanNo

GanttColumn Type

NameDescriptionTypeDefault
propField namestringRequired
labelColumn headerstringRequired
widthColumn widthstring | numberauto
alignAlignment'left' | 'center' | 'right''left'

Theme Variables

NameDescriptionDefault
--yh-gantt-border-colorBorder colorvar(--yh-border-color-light)
--yh-gantt-bg-colorBackground colorvar(--yh-bg-color)
--yh-gantt-header-bg-colorHeader background colorvar(--yh-fill-color-light)
--yh-gantt-task-colorTask block primary colorvar(--yh-color-primary)
--yh-gantt-line-colorGrid line colorvar(--yh-border-color-lighter)

Type Exports

NameDescription
YhGanttChartPropsComponent props type
YhGanttChartEmitsComponent emits type
YhGanttTaskTask data type
YhGanttColumnColumn config type
YhGanttChartSlotsComponent slots type
YhGanttChartInstanceComponent instance type

Released under the MIT License.