news 2026/6/14 17:17:27

vue 甘特图 vxe-gantt 如何自定义依赖线的颜色

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
vue 甘特图 vxe-gantt 如何自定义依赖线的颜色

vue 甘特图 vxe-gantt 如何自定义依赖线的颜色,通过设置 links 定义连接线,from 对应源任务的行主键,tom 对应目标任务的行主键

查看官网:https://gantt.vxeui.com/
gitbub:https://github.com/x-extends/vxe-gantt
gitee:https://gitee.com/x-extends/vxe-gantt

自定义所有连接线的的颜色

通过设置 task-link-config.lineColor 自定义连接线的颜色

<template><vxe-ganttv-bind="ganttOptions"></vxe-gantt></template><scriptsetup>import{reactive}from'vue'import{VxeGanttDependencyType}from'vxe-gantt'constganttOptions=reactive({border:true,height:500,rowConfig:{keyField:'id'// 行主键},taskBarConfig:{showProgress:true,// 是否显示进度条showContent:true,// 是否在任务条显示内容move:true,// 是否允许拖拽任务移动日期resize:true,// 是否允许拖拽任务调整日期barStyle:{round:true,// 圆角bgColor:'#fca60b',// 任务条的背景颜色completedBgColor:'#65c16f'// 已完成部分任务条的背景颜色}},taskViewConfig:{tableStyle:{width:480// 表格宽度}},taskLinkConfig:{lineColor:'#fad06c'// 给所有线自定义颜色},links:[{from:10001,to:10002,type:VxeGanttDependencyType.FinishToFinish},{from:10004,to:10005,type:VxeGanttDependencyType.StartToStart},{from:10005,to:10006,type:VxeGanttDependencyType.FinishToStart},{from:10013,to:10012,type:VxeGanttDependencyType.StartToFinish}],columns:[{type:'seq',width:70},{field:'title',title:'任务名称'},{field:'start',title:'开始时间',width:100},{field:'end',title:'结束时间',width:100},{field:'progress',title:'进度(%)',width:80}],data:[{id:10001,title:'任务1',start:'2024-03-01',end:'2024-03-04',progress:3},{id:10002,title:'任务2',start:'2024-03-03',end:'2024-03-08',progress:10},{id:10003,title:'任务3',start:'2024-03-03',end:'2024-03-11',progress:90},{id:10004,title:'任务4',start:'2024-03-05',end:'2024-03-11',progress:15},{id:10005,title:'任务5',start:'2024-03-08',end:'2024-03-15',progress:100},{id:10006,title:'任务6',start:'2024-03-10',end:'2024-03-21',progress:5},{id:10007,title:'任务7',start:'2024-03-15',end:'2024-03-24',progress:70},{id:10008,title:'任务8',start:'2024-03-05',end:'2024-03-15',progress:50},{id:10009,title:'任务9',start:'2024-03-19',end:'2024-03-20',progress:5},{id:10010,title:'任务10',start:'2024-03-12',end:'2024-03-20',progress:10},{id:10011,title:'任务11',start:'2024-03-01',end:'2024-03-08',progress:90},{id:10012,title:'任务12',start:'2024-03-03',end:'2024-03-06',progress:60},{id:10013,title:'任务13',start:'2024-03-02',end:'2024-03-05',progress:50},{id:10014,title:'任务14',start:'2024-03-04',end:'2024-03-15',progress:0},{id:10015,title:'任务15',start:'2024-03-01',end:'2024-03-05',progress:30}]})</script>

每条线单独自定义颜色

<template><vxe-ganttv-bind="ganttOptions"></vxe-gantt></template><scriptsetup>import{reactive}from'vue'import{VxeGanttDependencyType}from'vxe-gantt'constganttOptions=reactive({border:true,height:500,rowConfig:{keyField:'id'// 行主键},taskBarConfig:{showProgress:true,// 是否显示进度条showContent:true,// 是否在任务条显示内容move:true,// 是否允许拖拽任务移动日期resize:true,// 是否允许拖拽任务调整日期barStyle:{round:true,// 圆角bgColor:'#fca60b',// 任务条的背景颜色completedBgColor:'#65c16f'// 已完成部分任务条的背景颜色}},taskViewConfig:{tableStyle:{width:480// 表格宽度}},links:[{from:10001,to:10002,lineColor:'#fad06c',type:VxeGanttDependencyType.FinishToFinish},{from:10004,to:10005,lineColor:'#92c1f1',type:VxeGanttDependencyType.StartToStart},{from:10005,to:10006,lineColor:'#fd9393',type:VxeGanttDependencyType.FinishToStart},{from:10013,to:10012,lineColor:'#e78dd2',type:VxeGanttDependencyType.StartToFinish}],columns:[{type:'seq',width:70},{field:'title',title:'任务名称'},{field:'start',title:'开始时间',width:100},{field:'end',title:'结束时间',width:100},{field:'progress',title:'进度(%)',width:80}],data:[{id:10001,title:'任务1',start:'2024-03-01',end:'2024-03-04',progress:3},{id:10002,title:'任务2',start:'2024-03-03',end:'2024-03-08',progress:10},{id:10003,title:'任务3',start:'2024-03-03',end:'2024-03-11',progress:90},{id:10004,title:'任务4',start:'2024-03-05',end:'2024-03-11',progress:15},{id:10005,title:'任务5',start:'2024-03-08',end:'2024-03-15',progress:100},{id:10006,title:'任务6',start:'2024-03-10',end:'2024-03-21',progress:5},{id:10007,title:'任务7',start:'2024-03-15',end:'2024-03-24',progress:70},{id:10008,title:'任务8',start:'2024-03-05',end:'2024-03-15',progress:50},{id:10009,title:'任务9',start:'2024-03-19',end:'2024-03-20',progress:5},{id:10010,title:'任务10',start:'2024-03-12',end:'2024-03-20',progress:10},{id:10011,title:'任务11',start:'2024-03-01',end:'2024-03-08',progress:90},{id:10012,title:'任务12',start:'2024-03-03',end:'2024-03-06',progress:60},{id:10013,title:'任务13',start:'2024-03-02',end:'2024-03-05',progress:50},{id:10014,title:'任务14',start:'2024-03-04',end:'2024-03-15',progress:0},{id:10015,title:'任务15',start:'2024-03-01',end:'2024-03-05',progress:30}]})</script>

https://gitee.com/x-extends/vxe-gantt

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/15 11:02:23

【工业智能控制新纪元】:Open-AutoGLM赋能数字孪生的7大应用场景

第一章&#xff1a;Open-AutoGLM 数字孪生联动控制Open-AutoGLM 是一个面向工业自动化与人工智能融合的开源框架&#xff0c;专注于实现数字孪生系统与大语言模型&#xff08;LLM&#xff09;之间的实时联动控制。该架构通过构建物理设备的虚拟映射&#xff0c;结合自然语言指令…

作者头像 李华
网站建设 2026/6/15 11:04:44

【AI进化的下一个拐点】:Open-AutoGLM如何重塑自主学习技术边界?

第一章&#xff1a;Open-AutoGLM 自主学习进化机制Open-AutoGLM 是一种基于生成语言模型的自主学习系统&#xff0c;其核心在于构建一个能够持续优化自身推理与知识获取能力的闭环机制。该系统通过动态反馈、任务自我生成与多阶段验证&#xff0c;实现模型在无强监督环境下的渐…

作者头像 李华
网站建设 2026/6/14 17:32:49

基于springboot的图书进销存管理系统(11550)

有需要的同学&#xff0c;源代码和配套文档领取&#xff0c;加文章最下方的名片哦 一、项目演示 项目演示视频 二、资料介绍 完整源代码&#xff08;前后端源代码SQL脚本&#xff09;配套文档&#xff08;LWPPT开题报告&#xff09;远程调试控屏包运行 三、技术介绍 Java…

作者头像 李华
网站建设 2026/6/14 14:55:17

springboot基于Web的家政服务管理平台

SpringBoot基于Web的家政服务管理平台 一、平台开发背景与核心目标 随着城市化进程加速和居民生活水平提高&#xff0c;家政服务需求持续增长&#xff0c;涵盖保洁、月嫂、养老护理、家电维修等多个领域。然而&#xff0c;传统家政行业存在服务标准化程度低、供需匹配效率差、服…

作者头像 李华
网站建设 2026/6/15 12:01:33

基于SpringBoot的汽车配件仓储管理系统

基于SpringBoot的汽车配件仓储管理系统介绍 一、系统开发背景与意义 随着汽车保有量持续增长&#xff0c;汽车配件仓储管理面临以下挑战&#xff1a; 配件种类繁多&#xff1a;从小型螺丝到大型发动机部件&#xff0c;规格复杂&#xff0c;分类存储难度大。 需求波动性强&#…

作者头像 李华
网站建设 2026/6/14 19:38:51

448万台、近百亿元!前11个月我国3D打印机出口再创新高

资源库 / 12月19日消息&#xff0c;海关总署数据显示&#xff0c;2025年11月我国3D打印机出口量达到52万台&#xff0c;同比增长89.1%&#xff0c;出口总额为12.91亿元&#xff0c;同比增长135.7%。1至11月累计出口448万台&#xff0c;同比增长29.6%&#xff0c;累计出口总额为…

作者头像 李华