Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Vue3 Gantt Chart Component. 基于Vue3的甘特图组件

License

NotificationsYou must be signed in to change notification settings

ddmy/vue3-gantt

Repository files navigation

gantt

简体中文

Introduction

A simplified Gantt chart component developed based on vue3.x:

  • Supports exporting the Gantt chart to an Excel file.
  • Supports exporting the Gantt chart as an image.
  • Supports displaying overlapping schedules.
  • Supports dynamic configuration for responsive updates.
  • Responsive layout, compatible with small screens.

If you encounter any issues during use, feel free to raise issues 😊.

Demo Online Preview

Usage

<Gantt:data="data"itemText="Project"dateText="Date":dateRangeList="dateRangeList"/>
import{ref}from'vue'importGanttfrom'vue3-gantt'import'vue3-gantt/dist/style.css'constdateRangeList=ref(['2022-01-01','2022-03-05'])constdata=ref([{type:'normal',color:'',name:'Project 1',schedule:[{id:333330,name:'900 Warriors Simultaneous Online Celebration Event',desc:'This event is very important, generating millions of revenue. It is a cross-departmental collaboration and a major project with the CEO personally present to command. Everyone must work together!',backgroundColor:'rgb(253, 211, 172)',textColor:'rgb(245, 36, 9)',days:["2022-01-15","2022-02-05"]},{id:555550,name:'XXXXXX',desc:'This event is very important, generating millions of revenue. It is a cross-departmental collaboration and a major project with the CEO personally present to command. Everyone must work together!',backgroundColor:'#28f',textColor:'#fff',days:["2022-02-15","2022-02-25"]},],},{type:'normal',color:'',name:'Meteor Butterfly Sword',schedule:[{id:222221,name:'Chinese New Year Event',desc:'This event is very important, generating millions of revenue. It is a cross-departmental collaboration and a major project with the CEO personally present to command. Everyone must work together!',backgroundColor:'#482',textColor:'#fff',days:["2022-02-25","2022-03-10"]}],},])

Component Props

KeyTypeDefaultDescription
dataArray[Object][]antt chart data
dateRangeListArray[]The date range within the current chart. This array should have a length of 2, with elements as the start and end date in the format 'YYYY-MM-DD'.
itemTextStringnullThe header description for the items in the Gantt chart.
dateTextStringnullThe header description for the dates in the Gantt chart.
activeDateStringTodayThe day to be highlighted on the timeline (does not override schedule styles). Format: 'YYYY-MM-DD'.
repeatModeObjectSee belowConfiguration for handling overlapping schedules.
itemWidthNumber40-
itemHeightNumber40-
scheduleTitleFunctionnull-
borderColorString'#eee'-

The content width of the component needs to be controlled manually to ensure the minimum width.

Component Events

EventTypeDescription
scheduleClickFunctionCallback event when clicking on a schedule. Receives the schedule details as a parameter.
scrollXEndFunctionEvent triggered when the horizontal scrollbar reaches the end.
scrollYEndFunctionEvent triggered when the vertical scrollbar reaches the end.

Data Configuration: data Array[Object]

KeyValueDescription
type'alike'||'normal'The project type (display style).
colorCSS color formatBackground color for the current project. Applicable when the type is 'alike'.
nameStringThe name of the current project.
scheduleArray[Object]The project schedules.

Schedule Configuration: schedule Object

For easier development, you can extend additional fields based on the following.

KeyDescription
idA globally unique ID for the schedule.
nameThe name of the schedule.
descDescription of the schedule.
backgroundColorBackground color for the schedule.
textColorText color for the schedule name.
daysArray of Schedule Dates

repeatMode Configuration: Object

KeyOptionsDefault说Description明
mode'cover'||'extract''cover'Handling mode for overlapping schedules. 'cover' will simply overlap schedules, while 'extract' will extract and group overlapping schedules separately.
backgroundColorCSS color format'#FFFFCC'Background color for the extracted schedules in 'extract' mode.
textColorCSS color format'#336666'Text color for the extracted schedules in 'extract' mode.
nameString||Function'Overlapping Schedules'Text to display for overlapping schedules. If it's a function, it receives a list of overlapping schedules as a parameter.
descString||Function'These are multiple schedules.'Description to display for overlapping schedules. If it's a function, it receives a list of overlapping schedules as a parameter.

Component Instance Methods

Export Full Snapshot Image of the Current Gantt Chart

<Ganttref="gantt".../><button@click="exportImg">Download Image</button>
constgantt=ref(null)constexportImg=()=>{gantt.value.exportImg({download:true,waterValue:'Made by YiJio'})}

The exportImg method accepts an Object to configure the behavior of exporting the image. It returns a Promise, and upon successful completion, it receives the base64 value of the image.

ParameterOptional ValuesDefault ValueDescription
downloadBooleantrueWhether to automatically download the image.
waterValueString''Watermark text to be added to the image. If empty, no watermark will be added. Customizing the text style is not supported at the moment.

Exporting Current Gantt Chart to Excel

<Ganttref="gantt".../><button@click="exportGanttExcel">Export Excel</button>
constgantt=ref(null)constexportGanttExcel=()=>{gantt.value.exportGanttExcel({fileName:'TestList'})}

The exportGanttExcel method receives an Object named file to configure the export file information.

ParameterOptional ValuesDefault ValueDescription
fileNameString'数据'The name of the exported file.

[8]ページ先頭

©2009-2025 Movatter.jp