当前位置: 首页 > news >正文

improve-gantt-elastic(vue2中甘特图实现与引入)

1.前言

        项目开发中需要使用甘特图展示项目实施进度,左侧为表格计划,右侧为图表进度展示。wl-gantt-mater,dhtmlx尝试使用过可拓展性受到限制。gantt-elastic相对简单,可操作性强,基础版本免费。

        甘特图(Gantt chart)又称为横道图、条状图(Bar chart),通过条状图来显示项目、进度和其他时间相关的系统进展的内在关系随着时间进展的情况。以提出者亨利·劳伦斯·甘特(Henry Laurence Gantt)先生的名字命名。

2. gantt-elastic(vue2中甘特图实现与引入)

2.1 gantt-elastic

官方demo

 gantt-elastic官网gantt-elastic | Gantt Chart [ javascript gantt chart, gantt component, vue gantt, vue gantt chart, responsive gantt, project manager , vue projects ]icon-default.png?t=O83Ahttps://neuronetio.github.io/gantt-elastic/

2.2 npm install引入

不受网络限制直接npm install在项目中

npm install --save gantt-elastic
npm install --save gantt-elastic-header # 可选,根据需求安装

将对应的demo组件引入对应的项目。 

2.3内网引入

(1)拉取github上的gantt-elastic项目

将对应需要的依赖进行复制到需要开发的项目依赖中node_module。

需要复制的依赖包,相关依赖包已上传到博客资源中,可自行下载使用。

dayjs  
gantt-elastic  
gantt-elastic-header  
resize-observe-polyfill  
vue-slider-component  
vue-switches

(2) package.json版本锁定

"dependencies": {"dayjs": "^1.8.14","gantt-elastic": "^1.0.12","gantt-elastic-header": "^0.1.11",
}

(3) demo引入

<template><gantt-elastic:options="options":tasks="tasks"@tasks-changed="tasksUpdate"@options-changed="optionsUpdate"@dynamic-style-changed="styleUpdate"><gantt-header slot="header"></gantt-header></gantt-elastic>
</template><script>
import GanttElastic from "gantt-elastic";
import GanttHeader from "gantt-elastic-header";
import dayjs from "dayjs";// just helper to get current dates
function getDate(hours) {const currentDate = new Date();const currentYear = currentDate.getFullYear();const currentMonth = currentDate.getMonth();const currentDay = currentDate.getDate();const timeStamp = new Date(currentYear,currentMonth,currentDay,0,0,0).getTime();return new Date(timeStamp + hours * 60 * 60 * 1000).getTime();
}let tasks = [{id: 1,label: "Make some noise",user:'<a href="https://www.google.com/search?q=John+Doe" target="_blank" style="color:#0077c0;">John Doe</a>',start: getDate(-24 * 5),duration: 15 * 24 * 60 * 60 * 1000,percent: 85,type: "project",collapsed: true,},{id: 2,label: "With great power comes great responsibility",user:'<a href="https://www.google.com/search?q=Peter+Parker" target="_blank" style="color:#0077c0;">Peter Parker</a>',parentId: 1,start: getDate(-24 * 4),duration: 4 * 24 * 60 * 60 * 1000,percent: 50,type: "milestone",collapsed: true,style: {base: {fill: "#1EBC61",stroke: "#0EAC51"}}},{id: 3,label: "Courage is being scared to death, but saddling up anyway.",user:'<a href="https://www.google.com/search?q=John+Wayne" target="_blank" style="color:#0077c0;">John Wayne</a>',parentId: 2,start: getDate(-24 * 3),duration: 2 * 24 * 60 * 60 * 1000,percent: 100,type: "task"},{id: 4,label: "Put that toy AWAY!",user:'<a href="https://www.google.com/search?q=Clark+Kent" target="_blank" style="color:#0077c0;">Clark Kent</a>',start: getDate(-24 * 2),duration: 2 * 24 * 60 * 60 * 1000,percent: 50,type: "task",dependentOn: [3]},{id: 5,label:"One billion, gajillion, fafillion... shabadylu...mil...shabady......uh, Yen.",user:'<a href="https://www.google.com/search?q=Austin+Powers" target="_blank" style="color:#0077c0;">Austin Powers</a>',parentId: 4,start: getDate(0),duration: 2 * 24 * 60 * 60 * 1000,percent: 10,type: "milestone",style: {base: {fill: "#0287D0",stroke: "#0077C0"}}},{id: 6,label: "Butch Mario and the Luigi Kid",user:'<a href="https://www.google.com/search?q=Mario+Bros" target="_blank" style="color:#0077c0;">Mario Bros</a>',parentId: 5,start: getDate(24),duration: 1 * 24 * 60 * 60 * 1000,percent: 50,type: "task",collapsed: true,style: {base: {fill: "#8E44AD",stroke: "#7E349D"}}},{id: 7,label: "Devon, the old man wanted me, it was his dying request",user:'<a href="https://www.google.com/search?q=Knight+Rider" target="_blank" style="color:#0077c0;">Knight Rider</a>',parentId: 2,dependentOn: [6],start: getDate(24 * 2),duration: 4 * 60 * 60 * 1000,percent: 20,type: "task",collapsed: true},{id: 8,label: "Hey, Baby! Anybody ever tell you I have beautiful eyes?",user:'<a href="https://www.google.com/search?q=Johhny+Bravo" target="_blank" style="color:#0077c0;">Johhny Bravo</a>',parentId: 7,dependentOn: [7],start: getDate(24 * 3),duration: 1 * 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 9,label:"This better be important, woman. You are interrupting my very delicate calculations.",user:'<a href="https://www.google.com/search?q=Dexter\'s+Laboratory" target="_blank" style="color:#0077c0;">Dexter\'s Laboratory</a>',parentId: 8,dependentOn: [8, 7],start: getDate(24 * 4),duration: 4 * 60 * 60 * 1000,percent: 20,type: "task",style: {base: {fill: "#8E44AD",stroke: "#7E349D"}}},{id: 10,label: "current task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 5),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 11,label:"test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 6),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 12,label: "test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 7),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task",parentId: 11},{id: 13,label:"test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 8),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 14,label: "test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 9),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"},{id: 15,label: "test task",user:'<a href="https://www.google.com/search?q=Johnattan+Owens" target="_blank" style="color:#0077c0;">Johnattan Owens</a>',start: getDate(24 * 16),duration: 24 * 60 * 60 * 1000,percent: 0,type: "task"}];let options = {taskMapping: {progress: "percent"},maxRows: 100,maxHeight: 500,title: {label: "Your project title as html (link or whatever...)",html: false},row: {height: 24},calendar: {hour: {display: true}},chart: {progress: {bar: false},expander: {display: true}},taskList: {expander: {straight: false},columns: [{id: 1,label: "ID",value: "id",width: 40},{id: 2,label: "Description",value: "label",width: 200,expander: true,html: true,events: {click({ data, column }) {alert("description clicked!\n" + data.label);}}},{id: 3,label: "Assigned to",value: "user",width: 130,html: true},{id: 3,label: "Start",value: task => dayjs(task.start).format("YYYY-MM-DD"),width: 78}, {id: 4,label: "Type",value: "type",width: 68},{id: 5,label: "%",value: "progress",width: 35,style: {"task-list-header-label": {"text-align": "center",width: "100%"},"task-list-item-value-container": {"text-align": "center",width: "100%"}}}]},locale: {name: "en",Now: "Now","X-Scale": "Zoom-X","Y-Scale": "Zoom-Y","Task list width": "Task list","Before/After": "Expand","Display task list": "Task list"}};export default {name: "Gantt",components: {GanttElastic,GanttHeader},data() {return {tasks,options,dynamicStyle: {},lastId: 16};},methods: {tasksUpdate(tasks) {this.tasks = tasks;},optionsUpdate(options) {this.options = options;},styleUpdate(style) {this.dynamicStyle = style;}}
};
</script><style>
</style>

3.gantt-elastic-h

基于 gantt-elastic的拓展封装,基本功能相较gantt-elastic完善。在使用gantt-elastic可参考gantt-elastic-h的Api文档。也可选择使用gantt-elastic-h来实现参考使用文档自行完成。

使用文档 | gantt-elastic-h | 使用文档icon-default.png?t=O83Ahttps://jianguoht.github.io/gantt-elastic-h/doc.html#options-tasklist-columns

4.参考博客

vue甘特图(内网引入gantt-elastic以及源码扩展)_vue wl-gantt-CSDN博客文章浏览阅读3.2k次,点赞2次,收藏18次。前言:项目要求用甘特图展示计划的实施过程。之前用过dhtmlx,用着不是很舒服。又在网上看了jQueryGantt-master,wl-gantt-mater,gantt-elastic的大概源码,最后选定gantt-elastic(源码相对简单,易扩展开发,没选用他的进阶版本gantt-schedule-timeline-calendar-master的原因是这个要收费)1.外网开发,直接去github上npm install就好,我是内网开发,在github上install下来,然后把下下来的nod_vue wl-gantthttps://blog.csdn.net/qq_36566924/article/details/125293765?fromshare=blogdetail&sharetype=blogdetail&sharerId=125293765&sharerefer=PC&sharesource=2301_76671906&sharefrom=from_link

相关文章:

improve-gantt-elastic(vue2中甘特图实现与引入)

1.前言 项目开发中需要使用甘特图展示项目实施进度&#xff0c;左侧为表格计划&#xff0c;右侧为图表进度展示。wl-gantt-mater&#xff0c;dhtmlx尝试使用过可拓展性受到限制。gantt-elastic相对简单&#xff0c;可操作性强&#xff0c;基础版本免费。 甘特图&#xff08;Gan…...

【k8s面试题2025】1、练气期

主要通过呼吸吐纳等方法&#xff0c;将外界的天地灵气吸入体内&#xff0c;初步改造身体&#xff0c;使身体素质远超常人。 文章目录 docker 和虚拟机的不同Kubernetes 和 docker 的关系Kube-proxy IPVS 和 iptables 的异同蓝绿发布Kubernetes中常见的数据持久化方式关于 Docke…...

SpringBoot源码解析(七):应用上下文结构体系

SpringBoot源码系列文章 SpringBoot源码解析(一)&#xff1a;SpringApplication构造方法 SpringBoot源码解析(二)&#xff1a;引导上下文DefaultBootstrapContext SpringBoot源码解析(三)&#xff1a;启动开始阶段 SpringBoot源码解析(四)&#xff1a;解析应用参数args Sp…...

SpringSecurity-前后端分离

在前后端分离的架构中&#xff0c;Spring Security 的配置与传统的单体应用有所不同。为了确保安全性和灵活性&#xff0c;我们需要对 Spring Security 进行适当的调整以适应这种架构。下面将详细介绍如何在前后端分离的应用程序中实现 Spring Security。 1. 理解前后端分离的…...

sparkRDD教程之基本命令

作者&#xff1a;nchu可乐百香果 指导者&#xff1a;nchu-YoungDragon 1.前期准备 &#xff08;1&#xff09;从迅雷网盘上面下载这个项目&#xff0c;并且把scala&#xff0c;maven和java环境配置好 网盘链接&#xff1a; 分享文件&#xff1a;SparkRDD.zip 链接&#xf…...

Linux:SystemV通信

目录 一、System V通信 二、共享内存 代码板块 总结 三、信号量 信号量理论 信号量接口 一、System V通信 System V IPC&#xff08;inter-process communication&#xff09;&#xff0c;是一种进程间通信方式。其实现的方法有共享内存、消息队列、信号量这三种机制。 …...

C#上位机通过CAN总线发送bin文件

让gpt生成一段代码用来把bin文件通过can总线发出去 c#代码还是比较强大的&#xff0c;各种功能基本都是一两行代码就实现了&#xff0c;这里记录一下对这个代码的理解和解读 主要代码如下&#xff0c;传入bin文件的地址即可将其从指定的can通道发送出去&#xff1a; public …...

CV 图像处理基础笔记大全(超全版哦~)!!!

一、图像的数字化表示 像素 数字图像由众多像素组成&#xff0c;是图像的基本构成单位。在灰度图像中&#xff0c;一个像素用一个数值表示其亮度&#xff0c;通常 8 位存储&#xff0c;取值范围 0 - 255&#xff0c;0 为纯黑&#xff0c;255 为纯白。例如&#xff0c;一幅简单的…...

2-Kbengine+Unity3D多人在线游戏DEMO源码架构分析

2-Kbengine+Unity3D多人在线游戏DEMO源码架构分析 目录 一、服务器端 1、编写并生成我们的服务器端和客户端通用的游戏协议 2、 认识Entity实体 3、 官方DEMO-kbengine_demos_assets分析 二、 客户端...

Vue.js组件开发-如何实现表头搜索

在Vue.js组件开发中&#xff0c;实现表头搜索通常涉及在表格组件的表头添加输入框&#xff0c;并让用户能够输入搜索关键字来过滤表格数据。 以下是一个使用Element UI的el-table组件实现表头搜索的示例&#xff1a; 一、准备阶段 ‌确保Element UI已安装‌&#xff1a; 确保…...

lerna使用指南

lerna版本 以下所有配置命令都是基于v8.1.9&#xff0c;lerna v5 v7版本差别较大&#xff0c;在使用时&#xff0c;注意自身的lerna版本。 lerna开启缓存及缓存配置 nx缓存是v5版本以后才有的&#xff0c;小于该版本的无法使用该功能。 初始化配置 缓存配置文件nx.json&am…...

spark,读取和写入同一张表问题

读取a表&#xff0c;写入a表 1.写入的是分区表&#xff0c;不报错 2.读取上来之后&#xff0c;创建为临时视图temp&#xff0c;然后先写入a表&#xff0c;再使用temp&#xff0c;就会报错 解决办法&#xff1a;可以先使用temp&#xff0c;再写入a表 3.写入的不是分区表&…...

iOS - TLS(线程本地存储)

从源码中&#xff0c;详细总结 TLS (Thread Local Storage) 的实现&#xff1a; 1. TLS 基本结构 // TLS 的基本结构 struct tls_data {pthread_key_t key; // 线程本地存储的键void (*destructor)(void *); // 清理函数 };// 自动释放池的 TLS class Autorelease…...

node.js项目依赖关系分析工具 Depazer 的使用

node.js项目依赖关系分析工具 Depazer 的使用 Depazer 是一个用于 分析和可视化 Node.js 项目依赖关系 的工具。它可以帮助开发者快速了解项目的依赖结构、模块关系&#xff0c;以及可能存在的问题&#xff0c;从而优化代码架构和依赖管理。 功能特点 依赖关系分析&#xff1…...

QT 如何禁止QComboBox鼠标滚轮

一般情况下&#xff0c;QComboBox会相应鼠标的滚轮事件&#xff0c;即当鼠标停靠在QComboBox上方时&#xff0c;滚动鼠标滚轮&#xff0c;QComboBox的选项会发生切换。但这或许并不是我们希望所出现的&#xff0c;尤其是当QComboBox嵌入在QScrollArea中时&#xff0c;用户只是想…...

理解CPU负载与使用率

目录 CPU使用率 CPU负载 CPU使用率 定义&#xff1a;就像看一个工人干活的时间占他上班时间的比例。比如工人上班8小时&#xff0c;实际干活6小时&#xff0c;干活时间占比就是68100%75%。对于CPU&#xff0c;单核的看它被占用的时间占总时间的比例&#xff0c;多核的就把每个…...

浅谈计算机网络01 | SDN数据平面

浅谈基本云架构 一、计算机网络数据平面的基础理论1.1 数据平面与控制平面的区分1.1.1 两者功能差异1.1.2 协同工作机制 1.2 数据平面在网络架构中的位置与角色1.2.1 与各网络层次的关系1.2.2 对网络整体性能的影响 二、数据平面的关键技术原理2.1 转发技术2.1.1 基于目的地转发…...

《Java开发手册》核心内容

文章目录 引言I 编程规约II 异常日志III 单元测试 :IV 安全规约 :V MySQL数据库:VI 工程结构 :VII 设计规约 :引言 手册的愿景是提升代码质量和开发效率,通过规范化的编码实践来减少错误和提高系统的稳定性。 I 编程规约 命名风格:规定了命名的一致性和规范性,避免使…...

采用海豚调度器+Doris开发数仓保姆级教程(满满是踩坑干货细节,持续更新)

目录 一、采用海豚调度器+Doris开发平替CDH Hdfs + Yarn + Hive + Oozie的理由。 1. 架构复杂性 2. 数据处理性能 3. 数据同步与更新 4. 资源利用率与成本 6. 生态系统与兼容性 7. 符合信创或国产化要求 二、ODS层接入数据 接入kafka实时数据 踩坑的问题细节 三、海…...

通过将模型权重的矩阵表示为低秩矩阵,可以减少需要调整的参数数量,通俗易懂的解释,不懂你爬网线打我

通过将模型权重矩阵表示为低秩矩阵&#xff0c;可以减少需要调整的参数数量&#xff0c;原因在于低秩矩阵的结构本身就比高秩矩阵更“紧凑”&#xff0c;即它们需要的独立参数更少。具体来说&#xff0c;低秩矩阵的结构可以通过减少模型的自由度&#xff08;独立参数的数量&…...

深度学习在微纳光子学中的应用

深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向&#xff1a; 逆向设计 通过神经网络快速预测微纳结构的光学响应&#xff0c;替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…...

高频面试之3Zookeeper

高频面试之3Zookeeper 文章目录 高频面试之3Zookeeper3.1 常用命令3.2 选举机制3.3 Zookeeper符合法则中哪两个&#xff1f;3.4 Zookeeper脑裂3.5 Zookeeper用来干嘛了 3.1 常用命令 ls、get、create、delete、deleteall3.2 选举机制 半数机制&#xff08;过半机制&#xff0…...

JVM垃圾回收机制全解析

Java虚拟机&#xff08;JVM&#xff09;中的垃圾收集器&#xff08;Garbage Collector&#xff0c;简称GC&#xff09;是用于自动管理内存的机制。它负责识别和清除不再被程序使用的对象&#xff0c;从而释放内存空间&#xff0c;避免内存泄漏和内存溢出等问题。垃圾收集器在Ja…...

Golang dig框架与GraphQL的完美结合

将 Go 的 Dig 依赖注入框架与 GraphQL 结合使用&#xff0c;可以显著提升应用程序的可维护性、可测试性以及灵活性。 Dig 是一个强大的依赖注入容器&#xff0c;能够帮助开发者更好地管理复杂的依赖关系&#xff0c;而 GraphQL 则是一种用于 API 的查询语言&#xff0c;能够提…...

unix/linux,sudo,其发展历程详细时间线、由来、历史背景

sudo 的诞生和演化,本身就是一部 Unix/Linux 系统管理哲学变迁的微缩史。来,让我们拨开时间的迷雾,一同探寻 sudo 那波澜壮阔(也颇为实用主义)的发展历程。 历史背景:su的时代与困境 ( 20 世纪 70 年代 - 80 年代初) 在 sudo 出现之前,Unix 系统管理员和需要特权操作的…...

【python异步多线程】异步多线程爬虫代码示例

claude生成的python多线程、异步代码示例&#xff0c;模拟20个网页的爬取&#xff0c;每个网页假设要0.5-2秒完成。 代码 Python多线程爬虫教程 核心概念 多线程&#xff1a;允许程序同时执行多个任务&#xff0c;提高IO密集型任务&#xff08;如网络请求&#xff09;的效率…...

MySQL中【正则表达式】用法

MySQL 中正则表达式通过 REGEXP 或 RLIKE 操作符实现&#xff08;两者等价&#xff09;&#xff0c;用于在 WHERE 子句中进行复杂的字符串模式匹配。以下是核心用法和示例&#xff1a; 一、基础语法 SELECT column_name FROM table_name WHERE column_name REGEXP pattern; …...

多种风格导航菜单 HTML 实现(附源码)

下面我将为您展示 6 种不同风格的导航菜单实现&#xff0c;每种都包含完整 HTML、CSS 和 JavaScript 代码。 1. 简约水平导航栏 <!DOCTYPE html> <html lang"zh-CN"> <head><meta charset"UTF-8"><meta name"viewport&qu…...

Pinocchio 库详解及其在足式机器人上的应用

Pinocchio 库详解及其在足式机器人上的应用 Pinocchio (Pinocchio is not only a nose) 是一个开源的 C 库&#xff0c;专门用于快速计算机器人模型的正向运动学、逆向运动学、雅可比矩阵、动力学和动力学导数。它主要关注效率和准确性&#xff0c;并提供了一个通用的框架&…...

中医有效性探讨

文章目录 西医是如何发展到以生物化学为药理基础的现代医学&#xff1f;传统医学奠基期&#xff08;远古 - 17 世纪&#xff09;近代医学转型期&#xff08;17 世纪 - 19 世纪末&#xff09;​现代医学成熟期&#xff08;20世纪至今&#xff09; 中医的源远流长和一脉相承远古至…...