Giter Site home page Giter Site logo

sqlichao / vue-gantt-chart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xihaoshangdi/vue-gantt-chart

0.0 0.0 0.0 10.47 MB

基于Vue的轻量化甘特图插件

Home Page: https://xihaoshangdi.github.io/vue-gantt-chart/

Shell 1.56% JavaScript 32.80% HTML 1.98% Vue 63.66%

vue-gantt-chart's Introduction

Gantt Chart -Javascript - Vue

一个特殊的业务轮子

Demo

预览

Feature

  • 宽高可变自适应
  • 拖拽功能
  • 右击自定义事件
  • 首行粘性

Screenshot

Demo Demo2

Install

npm

npm i vue-gantt-chart --save

yarn

yarn add vue-gantt-chart

Include plugin in your main.js file.

import GanttChart from 'vue-gantt-chart'
import 'vue-gantt-chart/lib/vue-gantt-chart.css';
Vue.use(GanttChart)

Use

Template

<template>
    <GanttChart
        :gantt-data="GanttData"
        :gantt-current-time="GanttCurrentTime"
        :first-line-stick="firstLineStick"
        :time-section="GanttTime"
        :chart-max-height="ChartHeight"
        :float-view-render-fn="floatRender"
        @rightClick.native="handleRightClick"
    >
        <template #side-box="{item}">
          <!--侧边栏组件-->
          <SideComponent :side-info="item" />
        </template>
        <template #container-box="{item}">
          <!--内容栏组件-->
          <ContentComponent :content-info="item" />
        </template>
    </GanttChart>
</template>

API

Attributes

param required type default describe
timeSection Array 甘特图的时间区间 ['2021/02/21', '2021/02/24']
gantt-data Array 甘特图的数据来源 []
gantt-current-time X Number new Date().getTime() 甘特图时间轴渲染的当前时间
first-line-stick X Boolean true 首行是否粘性
chartMaxHeight X Number 500 甘特图内容最大高度
show-header X Boolean true 是否渲染表头
header-data X Array ['日期', '时间'] 表头标题
floatViewRenderFn X Function () => { return (info) => info } Tip渲染函数
gantt-data

gantt-data需要满足特殊的数据格式才能被正常的渲染,外层对象渲染为甘特条需要childArray属性用于承载甘特块,内层对象渲染为甘特块,需要startend用于计算偏移的像素

[
  {
    //整行的甘特块具有的属性
    "childArray":[// 渲染在甘特块上的甘特条
                    {
                      // 甘特条具有的属性
                      "start":"2021/02/26 07:08",// 甘特条渲染的起始时间
                      "end":"2021/02/26 08:44"// 甘特条渲染的结束时间
                    }
                  ]
  }
]
floatViewRenderFn

floatViewRenderFn作为渲染函数用于渲染甘特块的部分数据到甘特块的Tip上.

(info) => `<div>${info.start}</div><div>${info.end}</div>`

Event

param describe
rightClick 甘特块右击会触发事件,抛出自定义事件对象,甘特块的数据被包含在event.detail

Scoped Slot

<template #side-box="{item}">
  <SideComponent :side-info="item" />
</template>
<template #container-box="{item}">
  <ContentComponent :content-info="item" />
</template>
name describe
#side-box 具名插槽,传递自定义数据项的内容,参数为 { item }
#container-box 具名插槽,传递自定义数据项的内容,参数为 { item }

反馈缺陷 Bug

- **Version**: 
- **Mini Showcase Repository**:
- **Error Message**:

提交新需求 Feature Request

背景

  • 描述你希望解决的问题的现状
  • 你希望获得的功能的设计和实现

开源协议

MIT

vue-gantt-chart's People

Contributors

xihaoshangdi avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.