<p align="center"><img src="https://raw.githubusercontent.com/w1301625107/vue-gantt-chart/master/screenshot/icon.png" alt="logo" width="180"></p>
<h1 align="center">vue-gantt-chart</h1>
<p align="center">基于 Vue 实现的 gantt-like 图表 ,用于排班展示</p>
<p align="center"></p>
[](https://www.npmjs.com/package/v-gantt-chart)
[](https://img.shields.io/npm/dt/v-gantt-chart.svg)

[](http://hits.dwyl.io/w1301625107/Vue-Gantt-chart)
[](https://npmjs.org/package/v-gantt-chart)
## [React版本](https://github.com/w1301625107/React-Gantt-chart)
## [Demo预览地址](https://w1301625107.github.io/Vue-Gantt-chart/demo/index.html)
## Catalog
- [Feature](#feature)
- [Screenshot](#screenshot)
- [Install](#install)
- [Use](#use)
- [template code](#template-code)
- [script code](#script-code)
- [data](#data)
- [Slot](#slot)
- [block 容器块slot 有 __`两种`__ 需要注意](#block-容器块slot-有-__两种__-需要注意)
- [⭐️ `customGenerateBlocks` 为 `false`(默认值) 的情况](#⭐️-customgenerateblocks-为-false默认值-的情况)
- [⭐️ `customGenerateBlocks` 为 `true` 的情况](#⭐️-customgenerateblocks-为-true-的情况)
- [left 行名slot](#left-行名slot)
- [markline 时间标记线slot](#markline-时间标记线slot)
- [timeline 行名slot](#timeline-时间轴slot)
- [title 标题slot](#title-标题slot)
- [API](#api)
- [Param](#param)
- [Method](#method)
- [Event](#event)
- [Run Demo](#run-demo)
- [Caution](#caution)
- [Update](#update)
- [License](#license)
## Feature
- 虚拟列表,快速渲染可视区域,支持大量数据渲染
- 可变时间轴,1 分钟,2 分钟,3 分钟,4 分钟~~~到一天
- 可变单元格
- 标记线
- 支持自定义描述和容器块
## Screenshot

## Install
### npm 安装
```bash
npm i v-gantt-chart --save
```
Include plugin in your `main.js` file.
```js
import Vue from 'vue'
import vGanttChart from 'v-gantt-chart';
Vue.use(vGanttChart);
```
### 使用链接引入
```html
<script src="https://unpkg.com/v-gantt-chart/dist/v-gantt-chart.umd.min.js"></script>
```
```html
<body>
<div id="app">
<v-gantt-chart></v-gantt-chart>
</div>
</body>
<!-- 先引入vue -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- 再引入v-gantt-chart.js -->
<script src="./v-gantt-chart.js"></script>
<script>
new Vue({
el: '#app',
})
</script>
</html>
```
## Use
### template code
```html
<template>
<v-gantt-chart :startTime="startTime"
:endTime="endTime"
:datas="datas">
<template v-slot:block="{data,item}">
<!-- 你的容器块组件 -->
<Test :data="data" :item="item"></Test>
</template>
<template v-slot:left="{data}">
<!-- 你的行名组件 -->
<TestLeft :data="data"></TestLeft>
</template>
<template v-slot:title>
<!-- 你的表头组件 -->
hola
</template>
</v-gantt-chart>
</template>
```
### script code
```js
import Test from "./test.vue"; //你自己的gantt条容器
import TestLeft from "./test-left.vue"; //你自己的行名称组件
import { mockDatas } from "@src/mock/index.js"; //伪造的数据
import dayjs from "dayjs" //时间库
export default {
name: "App",
components: { Test, TestLeft },
data() {
return {
startTime: dayjs().toString(),//时间轴开始时间
endTime: dayjs()
.add(2, "d")
.add(2, "h")
.add(5, "s").toString(), //时间结束时间
datas: mockDatas(100), // gantt数据
};
},
};
```
### data
在**默认情况**下(即`customGenerateBlocks`为`false`)的渲染的数据需要**特殊格式** ,目前要求数组中每一个值均为对象,且有`gtAarry`对象数组这个属性(默认取`gtArray`,也可以通过`arrayKeys`属性自定义需要渲染的数组)
数组中每一个对象需有两个属性,`start`和`end`(不提供的情况,偏移与宽度将为0),数值需为合法的时间字符串.例如
```js
[
{
id:'test', //非必须
gtArray:[ //默认的需要渲染的数组
{
name:'test', //非必须
start:'2019-01-11 18:18:18',
end:'2019-01-11 18:18:18'
}
],
customKey:[ //自定义的需要渲染的数组
{
id:'test', //非必须
start:'2019-01-11 18:18:18',
end:'2019-01-11 18:18:18'
}
]
}
]
```
## Slot
```js
// 假设你传入的数据为
[
{
id:'arrayOne',
name:'sala',
gtArray:[
{
name:'itemOne',
start:'2019-01-11 18:18:18',
end:'2019-01-11 18:18:18'
// ...其他属性
}
],
//...其他属性
}
//... 其他数组数据
]
```
### block 容器块slot 有 __`两种`__ 需要注意
#### ⭐️ `customGenerateBlocks` 为 `false`(默认值) 的情况
```html
<template v-slot:block="{data,item}">
<!-- 你的容器块组件 -->
<Test :data="data" :item="item"></Test>
</template>
```
`data` 为 gantt图表中每一行的所有数据
如下
```js
{
id:'arrayOne',
name:'sala',
gtArray:[{...}],
//...
}
```
`item` 为 gantt图表中一个小方块对数据
如下
```js
{
name:'itemOne',
start:'2019-01-11 18:18:18',
end:'2019-01-11 18:18:18'
//...
}
```
#### ⭐️ `customGenerateBlocks` 为 `true` 的情况
此时`arrayKeys`,`itemkey`将不再次生效,如何渲染,渲染什么,将由你自己决定,下方是一个例子
```html
<template v-slot:block="{data,
getPositonOffset,
getWidthAbout2Times,
isInRenderingTimeRange,
startTimeOfRenderArea,
isAcrossRenderingTimeRange,
endTimeOfRenderArea}">
<div class="myBlockContainer"
v-for="item in data.gtArray"
v-if="isInRenderingTimeRange(item.start)||isAcrossRenderingTimeRange(item.start,item.end)
||isInRenderingTimeRange(item.end)"
:key="item.id"
:style="{position:'absolute',
left:getPositonOffset(item.start)+'px',
width:getWidthAbout2Times(item.start,item.end)+'px'}">
<Test :data="data"
:item="item"></Test>
</div>
</template>
```
`data` 为gantt图表中每一行的所有数据
```js
{
id:'test',
name:'sala',
gtArray:[{...}],
//...
}
```
除了data,还会提供以下属性和函数供调用
`startTimeOfRenderArea`
为当前渲染范围的时间轴开始时间的毫秒数
`endTimeOfRenderArea`
为当前渲染范围的时间轴结束时间的毫秒数
`getPositonOffset(time:string):number `
定位函数,根据给定字符串形式的时间生成相对时间轴起点的的偏移值
`getWidthAbout2Times(start:string,end:string):number`
为宽度计算函数,根据给定字符串形式的时间计算两个时间差的宽度值
`isInRenderingTimeRange(time:string):boolean`
判定给定的时间是否在屏幕显示的时间轴范围之内
`isAcrossRenderingTimeRange(timeStart,timeEnd):boolean`
判定给定的时间是否跨越了屏幕显示的时间轴范围之内
### left 行名slot
```html
<template v-slot:left="{data}">
<!-- 你的行名组件 -->
<TestLeft :data="data"></TestLeft>
</template>
```
`data` 为 gantt图表中每一行的所有数据
```js
{
id:'test',
name:'sala',
gtArray:[{...}],
//...
}
```
### timeline 时间轴slot
```html
<template v-slot:timeline="{day , getTimeScales}">
<!-- 你的时间刻度组件 -->
<
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
vue-gantt-chart 基于 Vue 实现的 gantt-like 图表 ,用于排班展示 Catalog template code script code data Slot block 容器块slot 有 两种 需要注意 :star: customGenerateBlocks 为 false(默认值) 的情况 :star: customGenerateBlocks 为 true 的情况 left 行名slot markline 时间标记线slot timeline 行名slot title 标题slot API Param Method Event Run Demo Caution Update License Feature 虚拟列表,快速渲染可视区域,支持大量数据渲染 可变时间轴,1 分钟,2 分钟,3 分钟,4 分钟~~~到一天 可变单元格 标记线 支持自定义描述和容器块 Screen
资源推荐
资源详情
资源评论






















收起资源包目录















































































共 58 条
- 1
资源评论


易行健
- 粉丝: 40
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 大数据视角下的语文课堂提问方法探究.docx
- 云计算市场与技术发展趋势.doc
- 通信工程施工管理概述.doc
- 关于强电线路对通信线路的影响及其防护.doc
- 集团大数据平台安全方案规划.docx
- Matlab基于腐蚀和膨胀的边缘检测.doc
- 网络监控系统解决方案酒店.doc
- 电动机智能软起动控制系统的研究与方案设计书(PLC).doc
- jAVA2程序设计基础第十三章.ppt
- 基于PLC的机械手控制设计.doc
- 医院his计算机信息管理系统故障应急预案.doc
- 企业运用移动互联网进行青年职工思想政治教育路径.docx
- 数据挖掘的六大主要功能.doc
- 大数据行政尚在跑道入口.docx
- 用Proteus和Keil建立单片机仿真工程的步骤.doc
- Internet技术与应用网络——资源管理与开发.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
