甘特图 Dhtmlx Gantt

介绍
在一些任务计划、日程进度等场景中我们会使用到甘特图,Dhtmlx Gantt 对于甘特图的实现支持很友好,文档API介绍全面,虽然增强版的收费,但免费版的足以够用。
官网:https://docs.dhtmlx.com/gantt/
安装dhtml gannt插件

npm install dhtmlx-gantt

引入插件

//页面引入,如果多个页面使用可以全局引入
import { gantt } from 'dhtmlx-gantt';
import 'dhtmlx-gantt/codebase/dhtmlxgantt.css';

页面代码

<template><div class="gantt-box" ref="ganttRef"></div>
</template><script setup>
import { gantt } from 'dhtmlx-gantt';
import 'dhtmlx-gantt/codebase/dhtmlxgantt.css';
import { onMounted, ref } from 'vue';
const ganttRef = ref(null);
const data = {data: [{id: 1,text: 'projectName',start_date: '01-04-2023',end_date: '05-12-2023',duration: 248,progress: 0.3,open: true,color: '#b38989'},{id: 2,text: '任务1',start_date: '02-04-2023',end_date: '11-07-2023',duration: 100,progress: 0.6,parent: 1},{id: 3,text: '任务2',start_date: '12-07-2023',end_date: '09-09-2023',duration: 59,progress: 0,parent: 1}],links: [{ id: 1, source: 1, target: 2, type: '1' },{ id: 2, source: 2, target: 3, type: '0' }]
};
const columns = [{ name: 'text', label: '项目名称', tree: true, min_width: 140 },{ name: 'start_date', label: '开始时间', min_width: 100 },{ name: 'end_date', label: '结束时间', min_width: 100 },{ name: 'duration', label: '计划工期' },{ name: 'add', label: '' }
];
const initGantt = () => {// 清空之前的配置gantt.clearAll();gantt.i18n.setLocale('cn'); // 设置中文gantt.config.readonly = true; // 设置为只读gantt.plugins({tooltip: true,quick_info: true // 快速信息框// multiselect: true,// 激活多任务选择});gantt.config.show_quick_info = true;gantt.config.tooltip_offset_x = 10;gantt.config.tooltip_offset_y = 30;// gantt.config.open_split_tasks = false;gantt.config.details_on_create = true; // 创建新事件通过点击“+”按钮打开灯箱gantt.config.autofit = true; // 甘特图图表宽度自适应// gantt.config.resize_rows = true; // 用户可以通过拖拽调整行高// 图表项目栏可以任意拖拽(任意节点下)gantt.config.order_branch = false;gantt.config.order_branch_free = false;gantt.config.placeholder_task = false; // 新增空白列后新增项目gantt.config.scale_height = 50;gantt.config.show_links = true; //是否显示依赖连线gantt.config.sort = false; // 点击表头可排序gantt.config.row_height = 40; //设置行高gantt.config.drag_project = true;gantt.config.scales = [// 设置时间刻度相关属性// 显示月日用这个// { unit: 'month', step: 1, format: '%Y-%m' },// { unit: 'day', step: 1, format: '%Y-%m-%d' }// 显示年月用这个{ unit: 'year', step: 1, format: '%Y' },{ unit: 'month', step: 1, format: '%M' }];// gantt.config.start_date = new Date(//     `${new Date().getFullYear() - 1},${new Date().getMonth()},${new Date().getDay()}`// );// gantt.config.end_date = new Date(`${new Date().getFullYear() + 1},${new Date().getMonth()},${new Date().getDay()}`);// gantt.config.show_tasks_outside_timescale = true;gantt.config.auto_scheduling = true;// 配置Gantt内置弹出框内容gantt.templates.lightbox_header = function (start_date, end_date, task) {return `<b>${task.text}</b>`;};gantt.config.lightbox.sections = [{name: 'description',height: 36,map_to: 'text',type: 'textarea',focus: true},{ name: 'time', type: 'duration', map_to: 'auto' },{name: 'Participants',height: 36,map_to: 'Participants',type: 'ParticipantsPlan',focus: true},{name: 'BgColor',height: 36,map_to: 'color',type: 'ParticipantsPlanColor',focus: true}];gantt.templates.tooltip_text = function (start, end, task) {return (task.text +'<br/><span>开始:</span> ' +gantt.templates.tooltip_date_format(start) +'<br/><span>结束:</span> ' +gantt.templates.tooltip_date_format(end) +'<br/><span>进度:</span> ' +Math.round(task.progress * 100) +'%');};gantt.config.bar_height = 30;// 自定义信息弹窗classgantt.templates.quick_info_class = function () {return 'default-quick-info';};// 自定义信息弹窗头部classgantt.templates.grid_header_class = function () {return 'progress-header';};gantt.templates.quick_info_content = function (start, end, task) {return `<div>${task.text}<br/>计划开始 : ${gantt.templates.tooltip_date_format(start)}<br/>计划结束:${gantt.templates.tooltip_date_format(end)}<br/>进度 : ${Math.round(task.progress * 100) + '%'}<br/>状态 :</div>`;};// 设置树形列的父项图标gantt.templates.grid_folder = function () {return '';};// 设置树形列的子项图标gantt.templates.grid_file = function () {return '';};// 自定义进度条上的文本gantt.templates.task_text = function (start, end, task) {return `<span style="margin-left:10px;color:white;">${task.progress * 100}%</span>`;};// 自定义progress_text内容gantt.templates.progress_text = function () {// return "<span style='text-align:left;'>" + Math.round(task.progress * 100) + '% </span>';return '';};gantt.config.columns = columns;// 初始化甘特图gantt.init(ganttRef.value);// 渲染数据gantt.parse(data);
};onMounted(() => {initGantt();
});
</script><style lang="less" scoped>
.gantt-box {width: 1000px;height: 400px;
}
// /deep/.default-quick-info {
//     background-color: aqua;
// }
</style>

效果
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/10796.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Android:ImageView xml方式配置selector 图片切换

1、在res/drawable目录下创建一个新的XML文件&#xff0c;比如selector_image.xml <?xml version"1.0" encoding"utf-8"?> <selector xmlns:android"http://schemas.android.com/apk/res/android"> <!-- 背景选择器 state_pre…

Linux6.16 Docker consul的容器服务更新与发现

文章目录 计算机系统5G云计算第四章 LINUX Docker consul的容器服务更新与发现一、consul 概述1.什么是服务注册与发现2.什么是consul 二、consul 部署1.consul服务器2.registrator服务器3.consul-template4.consul 多节点 计算机系统 5G云计算 第四章 LINUX Docker consul的…

react状态管理工具reduxjs/toolkit用法

安装 npm install reduxjs/toolkit 1.创建一个名为counterSlice.js的文件&#xff0c;用于处理计数器模块的状态&#xff1a; import { createSlice } from reduxjs/toolkit;const counterSlice createSlice({name: counter,initialState: {value: 0,},reducers: {increment…

PHP数组转对象和对象转数组

PHP数组转对象和对象转数组 <?php function array_to_object($arr){$obj new stdClass();foreach ($arr as $key > $val) {if (is_array($val) || is_object($val)) {$obj->$key array_to_object($val);} else {$obj->$key $val;}}return $obj; } function o…

MySQL - 1、数据库和表操作

CREATE DATABASE 创建一个名为"example_db"的数据库&#xff1a; CREATE DATABASE example_db;CREATE TABLE 创建一个名为"employees"的表&#xff0c;用于存储员工信息&#xff1a; CREATE TABLE employees (id INT PRIMARY KEY,name VARCHAR(50),age…

项目文档管理的基本指南

项目文档是一种关键的项目管理资源&#xff0c;它可以提供清晰度&#xff0c;保证参与项目的每个人都在同一页面上&#xff0c;从而确保项目按时、按预算完成。 本文将讨论项目文档的重要性、如何在项目中使用项目文档以及选择好合适的项目文档管理软件的技巧。 什么是项目文…

分布式微服务架构下网络通信的底层实现原理

在分布式架构中&#xff0c;网络通信是底层基础&#xff0c;没有网络&#xff0c;也就没有所谓的分布式架构。只有通过网络才能使得一大片机器互相协作&#xff0c;共同完成一件事情。 同样&#xff0c;在大规模的系统架构中&#xff0c;应用吞吐量上不去、网络存在通信延迟、我…

IDEA常用插件与配置

目录 常用插件 1.RestfulToolkit 2.MyBatisX (dao,xml层对应) 3.GitToolBox(git对应信息) 4.CodeGlance(代码滚动轮) 5.MyBatis Log Plugin(SQL log) 6.Any-Rule(正则表达式)

DevOps-Git

DevOps-Git 版本控制软件提供完备的版本管理功能&#xff0c;用于存储&#xff0c;追踪目录&#xff08;文件夹&#xff09;和文件的修改历史。版本控制软件的最高目标是支持公司的配置管理活动&#xff0c;最终多个版本的开发和维护活动&#xff0c;即使发布软件。 git安装 h…

K8S初级入门系列之十二-计算资源管理

一、前言 K8S集群中着这各类资源&#xff0c;比如计算资源&#xff0c;API资源等&#xff0c;其中最重要的是计算资源&#xff0c;包括CPU&#xff0c;缓存&#xff0c;存储等。管理这些资源就是要在资源创建时进行约束和限制&#xff0c;在运行时监控这些资源的指标&#xff0…

回归预测 | MATLAB实现POA-CNN-BiLSTM鹈鹕算法优化卷积双向长短期记忆神经网络多输入单输出回归预测

回归预测 | MATLAB实现POA-CNN-BiLSTM鹈鹕算法优化卷积双向长短期记忆神经网络多输入单输出回归预测 目录 回归预测 | MATLAB实现POA-CNN-BiLSTM鹈鹕算法优化卷积双向长短期记忆神经网络多输入单输出回归预测预测效果基本介绍模型描述程序设计参考资料 预测效果 基本介绍 MATLA…

[SQL挖掘机] - 左连接: left join

介绍: 左连接是一种多表连接方式&#xff0c;它以左侧的表为基础&#xff0c;并返回满足连接条件的匹配行以及左侧表中的所有行&#xff0c;即使右侧的表中没有匹配的行。左连接将左表的每一行与右表进行比较&#xff0c;并根据连接条件返回结果集。 左连接的工作原理如下&am…

qt root start faild

深入解析chown -r root:root命令_笔记大全_设计学院 ffmpeg第五弹&#xff1a;QtSDLffmpeg视频播放演示_txp玩Linux的博客-CSDN博客

idea中创建请求基本操作

文章目录 说明效果创建GET请求没有参数带有参数带有环境变量带有动态参数 说明 首先通过###三个井号键来分开每个请求体&#xff0c;然后请求url和header参数是紧紧挨着的&#xff0c;请求参数不管是POST的body传参还是GET的parameter传参&#xff0c;都是要换行的&#xff0c;…

OSI模型简介及socket,tcp,http三者之间的区别和原理

1.OSI模型简介&#xff08;七层网络模型&#xff09; OSI 模型(Open System Interconnection model)&#xff1a;一个由国际标准化组织提出的概念模型&#xff0c;试图提供一个使各种不同的计算机和网络在世界范围内实现互联的标准框架。 它将计算机网络体系结构划分为七层,每…

Java设计模式之策略(Strategy)模式

策略&#xff08;Strategy&#xff09;设计模式定义了一系列算法&#xff0c;将它们封装起来&#xff0c;并且可以相互替换使用&#xff0c;从而使得算法可以独立于使用它的客户而变化。 什么是策略模式 策略&#xff08;Strategy&#xff09;设计模式是一种行为型设计模式&a…

苹果safari浏览器播放不了video标签视频

今天遇到了个神奇的问题&#xff0c;视频文件在pc端和安卓手机上播放都没问题&#xff0c;但是在ios上就是播放不了&#xff0c;大概代码如下&#xff1a; 前端代码&#xff1a; <video id"video" width"350" height"500" controls><s…

面试题-TS(八):什么是装饰器(decorators)?如何在 TypeScript 中使用它们?

面试题-TS(八)&#xff1a;什么是装饰器&#xff08;decorators&#xff09;&#xff1f;如何在 TypeScript 中使用它们&#xff1f; 在TypeScript中&#xff0c;装饰器&#xff08;Decorators&#xff09;是一种用于增强代码功能的特殊类型声明。装饰器提供了一种在类、方法、…

每日一道面试题之如何实现数组和 List 之间的转换?

要实现数组和List之间的转换&#xff0c;可以使用Java中的Arrays类和Collections类提供的方法。 数组转换为List&#xff1a; 使用Arrays类的asList()方法可以将数组转换为List。这个方法接受一个数组作为参数&#xff0c;并返回一个包含数组元素固定大小的List。 举例&…

EMP-SSL: TOWARDS SELF-SUPERVISED LEARNING IN ONETRAINING EPOCH

Recently, self-supervised learning (SSL) has achieved tremendous success in learning image representation. Despite the empirical success, most self-supervised learning methods are rather “inefficient” learners, typically taking hundreds of training epoch…