Examples
Basic usage
vue
<template>
<div class="w-full h-[142px] overflow-hidden">
<vue-gantt :data="data" start-date="2024-09-23" end-date="2025-09-23" />
</div>
</template>
<script setup lang="ts">
import { reactive } from "vue";
const data = reactive([
{
position: "Product",
name: "Xu Quan",
projects: [
{ name: "Project 1", startDate: "2024-09-24", endDate: "2024-09-30" },
{ name: "Project 2", startDate: "2024-10-01", endDate: "2024-10-02" },
{ name: "Project 3", startDate: "2024-10-03", endDate: "2024-10-15" },
],
},
{
position: "Design",
name: "Lei Yufei",
projects: [
{ name: "Project 1", startDate: "2024-10-05", endDate: "2024-10-28" },
{ name: "Project 2", startDate: "2024-12-12", endDate: "2025-01-09" },
{ name: "Project 3", startDate: "2025-02-01", endDate: "2025-02-27" },
],
},
{
position: "Development",
name: "Jing Yixian",
projects: [
{ name: "Project 1", startDate: "2024-09-24", endDate: "2024-09-30" },
{ name: "Project 2", startDate: "2024-10-01", endDate: "2024-10-02" },
{ name: "Project 3", startDate: "2024-10-03", endDate: "2024-10-15" },
],
},
{
position: "Testing",
name: "Liu Xinwei",
projects: [
{ name: "Project 1", startDate: "2024-07-20", endDate: "2024-08-18" },
{ name: "Project 2", startDate: "2024-11-10", endDate: "2024-12-07" },
{ name: "Project 3", startDate: "2025-01-15", endDate: "2025-02-12" },
],
},
]);
</script>
Name
Xu Quan
Lei Yufei
Jing Yixian
Liu Xinwei
09/23
09/30
10/07
10/14
10/21
10/28
11/04
11/11
11/18
11/25
12/02
12/09
12/16
12/23
12/30
01/06
01/13
01/20
01/27
02/03
02/10
02/17
02/24
03/03
03/10
03/17
03/24
03/31
04/07
04/14
04/21
04/28
05/05
05/12
05/19
05/26
06/02
06/09
06/16
06/23
06/30
07/07
07/14
07/21
07/28
08/04
08/11
08/18
08/25
09/01
09/08
09/15
09/22
Project 1
Project 2
Project 3
Project 1
Project 2
Project 3
Project 1
Project 2
Project 3
Project 2
Project 3
Event Handler
vue
<template>
<div class="w-full h-[142px] overflow-hidden">
<vue-gantt :data="data" start-date="2024-09-23" end-date="2025-09-23"
@dragend-bar="handleDragEnd($event.e, $event.bar, $event.barIndex, $event.rowIndex)"
@click-bar="handleClickBar($event.e, $event.bar, $event.barIndex, $event.rowIndex)"
@click-row="handleClickRow($event.e, $event.row, $event.time, $event.rowIndex)"
/>
</div>
</template>
<script setup lang="ts">
const handleDragEnd = (
e: MouseEvent,
bar: Project,
barIndex: number,
rowIndex: number) => {
console.log('---drag-end---', e, bar, barIndex, rowIndex);
data[rowIndex].projects[barIndex] = bar;
}
const handleClickBar = (
e: MouseEvent,
bar: Project,
barIndex: number,
rowIndex: number) => {
console.log('---click-bar---', e, bar, barIndex, rowIndex);
}
const handleClickRow = (
e: MouseEvent,
row: Gantt,
time: string,
rowIndex: number) => {
console.log('---click-row---', e, row, time, rowIndex);
}
</script>
Name
Xu Quan
Lei Yufei
Jing Yixian
Liu Xinwei
09/23
09/30
10/07
10/14
10/21
10/28
11/04
11/11
11/18
11/25
12/02
12/09
12/16
12/23
12/30
01/06
01/13
01/20
01/27
02/03
02/10
02/17
02/24
03/03
03/10
03/17
03/24
03/31
04/07
04/14
04/21
04/28
05/05
05/12
05/19
05/26
06/02
06/09
06/16
06/23
06/30
07/07
07/14
07/21
07/28
08/04
08/11
08/18
08/25
09/01
09/08
09/15
09/22
Project 1
Project 2
Project 3
Project 1
Project 2
Project 3
Project 1
Project 2
Project 3
Project 2
Project 3
Custom Slots
vue
<template>
<div class="w-full h-[142px] overflow-hidden">
<vue-gantt
:data="data"
start-date="2024-09-23"
end-date="2025-09-23"
@dragend-bar="handleDragEnd($event.e, $event.bar, $event.barIndex, $event.rowIndex)"
>
<template #gantt-left-head>
<div class="size-full grid grid-cols-3">
<div class="px-1 border-r">Position</div>
<div class="px-1 border-r">Name</div>
<div class="px-1">Hours</div>
</div>
</template>
<template #gantt-left-row="{ row }">
<div class="size-full grid grid-cols-3">
<div class="px-1 border-r whitespace-nowrap overflow-hidden text-ellipsis">{{ row.position }}</div>
<div class="px-1 border-r whitespace-nowrap overflow-hidden text-ellipsis">{{ row.name }}</div>
<div class="px-1 whitespace-nowrap overflow-hidden text-ellipsis">{{ calculateWorkingHoursForRow(row.projects) }}</div>
</div>
</template>
<template #gantt-head-cell="{ cell }">
<span class="text-zinc-400 text-sm leading-8 px-2" :title="cell.format('YYYY-MM-DD')">{{ cell.format('DD') }}</span>
</template>
<template #gantt-bar-content="{ project }">
<div class="w-full h-full overflow-hidden text-sm flex justify-center items-center" :title="project.name">
<span class="overflow-hidden whitespace-nowrap text-ellipsis">{{ `${project.startDate} : ${project.endDate}`
}}</span>
</div>
</template>
</vue-gantt>
</div>
</template>
Position
Name
Hours
Product
Xu Quan
128
Design
Lei Yufei
448
Development
Jing Yixian
128
Testing
Liu Xinwei
488
23
24
25
26
27
30
01
02
03
04
07
08
09
10
11
14
15
16
17
18
21
22
23
24
25
28
29
30
31
01
04
05
06
07
08
11
12
13
14
15
18
19
20
21
22
25
26
27
28
29
02
03
04
05
06
09
10
11
12
13
16
17
18
19
20
23
24
25
26
27
30
31
01
02
03
06
07
08
09
10
13
14
15
16
17
20
21
22
23
24
27
28
29
30
31
03
04
05
06
07
10
11
12
13
14
17
18
19
20
21
24
25
26
27
28
03
04
05
06
07
10
11
12
13
14
17
18
19
20
21
24
25
26
27
28
31
01
02
03
04
07
08
09
10
11
14
15
16
17
18
21
22
23
24
25
28
29
30
01
02
05
06
07
08
09
12
13
14
15
16
19
20
21
22
23
26
27
28
29
30
02
03
04
05
06
09
10
11
12
13
16
17
18
19
20
23
24
25
26
27
30
01
02
03
04
07
08
09
10
11
14
15
16
17
18
21
22
23
24
25
28
29
30
31
01
04
05
06
07
08
11
12
13
14
15
18
19
20
21
22
25
26
27
28
29
01
02
03
04
05
08
09
10
11
12
15
16
17
18
19
22
23
2024-09-24 : 2024-09-30
2024-10-01 : 2024-10-02
2024-10-03 : 2024-10-15
2024-10-05 : 2024-10-28
2024-12-12 : 2025-01-09
2025-02-01 : 2025-02-27
2024-09-24 : 2024-09-30
2024-10-01 : 2024-10-02
2024-10-03 : 2024-10-15
2024-11-10 : 2024-12-07
2025-01-15 : 2025-02-12