@xpyjs/gantt-vue

Vue wrapper for x-gantt
3,486 352
Install
npm install @xpyjs/gantt-vue
Latest Version:0.1.3
Vue:3
License:MIT
Last Updated:Aug 28, 2026
Links: GitHub  ·  npm
Maintainer: jeremyjone

XGantt Vue 组件

基于 XGantt 核心的 Vue 3 组件封装。

安装

npm install @xpyjs/gantt-vue
# 或
pnpm add @xpyjs/gantt-vue

使用

全局注册

import { createApp } from 'vue'
import XGanttVue from '@xpyjs/gantt-vue'
import '@xpyjs/gantt-vue/style.css'

const app = createApp(App)
app.use(XGanttVue)

局部注册

<template>
  <XGanttChart
    :data="ganttData"
    :width="1200"
    :height="600"
    :table="tableConfig"
    primary-color="#1890ff"
    @move="onTaskMove"
    @select="onTaskSelect"
  />
</template>

<script setup lang="ts">
import { XGanttChart } from '@xpyjs/gantt-vue'
import '@xpyjs/gantt-vue/style.css'

const ganttData = ref([
  {
    id: '1',
    name: '任务1',
    startTime: '2024-01-01',
    endTime: '2024-01-15',
    progress: 80
  }
])

const tableConfig = {
  columns: [
    { field: 'name', label: '任务名称', width: 200 },
    { field: 'progress', label: '进度', width: 80 }
  ]
}

const onTaskMove = (moved) => {
  console.log('任务移动:', moved)
}

const onTaskSelect = (selected, checked, all) => {
  console.log('任务选择:', { selected, checked, all })
}
</script>

属性 (Props)

属性名 类型 默认值 说明
data Array [] 甘特图数据
width Number undefined 甘特图宽度
height Number undefined 甘特图高度
primaryColor String "#eca710" 主色调
dateFormat String "YYYY-MM-DD" 日期格式
unit String "day" 时间刻度
locale String "en" 显示语言
fields Object {...} 字段映射配置
table Object {...} 表格配置
chart Object {...} 图表配置

事件 (Events)

事件名 参数 说明
move moved 任务拖拽移动完成
select selected, checked, all 任务选择
click:row event, row 行点击
dblclick:row event, row 行双击
error error 错误事件

方法 (Methods)

方法名 参数 返回值 说明
jumpTo date? boolean 跳转到指定日期
getOptions - object 获取甘特图选项
render - void 重新渲染
getInstance - XGantt 获取甘特图实例

开发

# 安装依赖
pnpm install

# 开发
pnpm dev

# 构建
pnpm build

许可证

MIT

Related Packages

@infectoone/vue-ganttastic

A simple and customizable Gantt chart component for Vue.js

303,460 718
hy-vue-gantt

Evolution of vue-ganttastic package

39,308 42
vue-ganttastic

A simple and customizable Gantt chart component for Vue.js

35,238 718
@dlhsoft/ganttcharthyperlibrary

Gantt Chart library for JavaScript and TypeScript with Angular, React, and Vue e...

2,650 2
@adesin-fr/vue-ganttastic

A simple and customizable Gantt chart component for Vue.js

1,061 0

Version History

Version Released Vue License
0.1.3 ^3.0.0 MIT
0.1.2 ^3.0.0 MIT
0.1.1 ^3.0.0 MIT
0.1.0 ^3.0.0 MIT
0.0.3 ^3.0.0 MIT
Pre-releases (15)
Version Released Vue License
0.0.1-rc.5 ^3.0.0 MIT
0.0.1-rc.4 ^3.0.0 MIT
0.0.1-rc.3 ^3.0.0 MIT
0.0.1-rc.2 ^3.0.0 MIT
0.0.1-rc.1 ^3.0.0 MIT