全功能施工项目管理甘特图 Demo:任务依赖箭头、当前日期标线、周末高亮、分组项目可视化
完整可运行 HTML 使用方式复制全部代码新建.html文件粘贴保存直接双击文件用浏览器打开无需本地服务、无跨域、正常预览完整甘特图支持所有主流浏览器Chrome/Edge/360/Firefox!DOCTYPE html html langzh-CN head meta charsetUTF-8 meta nameviewport contentwidthdevice-width, initial-scale1.0 title项目管理甘特图 - Highcharts Gantt 可预览修复版/title !-- 稳定CDN严格加载顺序基础内核→甘特模块 -- script srchttps://cdn.jsdelivr.net/npm/highcharts11.4.3/highcharts.min.js/script script srchttps://cdn.jsdelivr.net/npm/highcharts11.4.3/modules/gantt.min.js/script style * {margin: 0; padding: 0; box-sizing: border-box;} body {background: #fff; padding: 10px;} #container { width: 100%; height: 90vh; border: 1px solid #eee; } /style /head body div idcontainer/div script const day 24 * 36e5, today Math.floor(Date.now() / day) * day; const options { chart: { plotBorderColor: rgba(128,128,128,0.1), plotBorderWidth: 1, plotBorderRadius: 5 }, plotOptions: { series: { borderRadius: 50%, connectors: { lineWidth: 1, lineColor: #666, radius: 10, endMarker: { verticalAlign: bottom, align: center, yOffset: 5 }, startMarker: { symbol: arrow-half, lineWidth: 1, lineColor: #666, xOffset: -5 } }, groupPadding: 0, dataLabels: [{ enabled: true, align: left, format: {point.name}, padding: 10, style: { fontWeight: normal, textOutline: none } }, { enabled: true, align: right, format: {#if point.completed}{(multiply point.completed.amount 100):.0f}% {/if}, padding: 10, style: { fontWeight: normal, textOutline: none, opacity: 0.6 } }] } }, series: [{ name: 办公场地项目, data: [{ name: 新办公室筹备, id: new_offices, owner: Peter, pointWidth: 3, color: #666, dataLabels: { align: right, style: { color: #666 }, x: 72 } }, { name: 办公楼装修施工, id: prepare_building, parent: new_offices, start: today - (8 * day), end: today (6 * day), completed: { amount: 0.5 }, owner: Linda }, { name: 建筑竣工验收, id: inspect_building, dependency: prepare_building, parent: new_offices, start: today 6 * day, end: today 8 * day, owner: Ivy }, { name: 验收通过里程碑, id: passed_inspection, dependency: inspect_building, parent: new_offices, start: today 9.5 * day, milestone: true, owner: Peter }, { name: 搬迁工作, id: relocate, owner: Josh, pointWidth: 3, color: #666, dataLabels: { align: right, style: { color: #666 }, x: 57 } }, { name: 员工搬迁, id: relocate_staff, parent: relocate, start: today 10 * day, end: today 11 * day, owner: Mark }, { name: 实验室设备迁移, dependency: relocate_staff, parent: relocate, start: today 11 * day, end: today 13 * day, owner: Anne }, { name: 食堂搬迁, dependency: relocate_staff, parent: relocate, start: today 11 * day, end: today 14 * day }] }, { name: 产品项目, data: [{ name: 新品上线计划, id: new_product, owner: Peter, pointWidth: 3, color: #666, dataLabels: { align: right, style: { color: #666 }, format: 上线, x: 50 } }, { name: 产品研发, id: development, parent: new_product, start: today - day, end: today (11 * day), completed: { amount: 0.6 }, owner: Susan }, { name: Beta测试里程碑, id: beta, dependency: development, parent: new_product, start: today 12.5 * day, milestone: true, owner: Peter }, { name: 最终版本完善开发, id: finalize, dependency: beta, parent: new_product, start: today 13 * day, end: today 17 * day }, { name: 正式上线里程碑, dependency: finalize, parent: new_product, start: today 17.5 * day, milestone: true, owner: Peter }] }], tooltip: { pointFormat: span stylefont-weight: bold{point.name}/spanbr {point.start:%m月%d日} {#unless point.milestone} → {point.end:%m月%d日}{/unless} br {#if point.completed}完成进度: {multiply point.completed.amount 100}%br{/if} 负责人: {#if point.owner}{point.owner}{else}未分配{/if} }, title: { text: 项目管理甘特图, align: left }, xAxis: [{ currentDateIndicator: { color: #ef4444, dashStyle: ShortDot, width: 2, label: { format: } }, dateTimeLabelFormats: { day: %dbrspan styleopacity: 0.5; font-size: 0.7em%a/span }, grid: { borderWidth: 0, cellHeight: 46 }, gridLineWidth: 1, min: today - 3 * day, max: today 19 * day, custom: { weekendPlotBands: { color: #f2f2f2 } } }, { dateTimeLabelFormats: { month: %m月%Y年 }, labels: { align: left, x: 5, style: { fontSize: 0.7em, fontWeight: bold } }, grid: { borderWidth: 0, cellHeight: 24 }, tickInterval: 30 * 24 * 36e5 }], yAxis: { grid: { borderWidth: 0, enabled: true, columns: [{ title: { text: 任务名称, textAlign: left, x: 18 }, labels: { format: {value}, indentation: 0 } }, { title: { text: 工期, textAlign: left, x: 8 }, labels: { format: {#if point.x2}{(divide (subtract point.x2 point.x) 86400000)} 天{else} - {/if}, style: { opacity: 0.7 } } }] }, gridLineWidth: 0, staticScale: 30 } }; // 周末底色渲染插件 Highcharts.addEvent(Highcharts.Axis, foundExtremes, e { const weekendColor e.target.options.custom?.weekendPlotBands?.color; if (!weekendColor) return; const axis e.target, chart axis.chart, day 24 * 36e5; const isWeekend t /[06]/.test(chart.time.dateFormat(%w, t)); const plotBands []; let inWeekend false; for (let x Math.floor(axis.min / day) * day; x Math.ceil(axis.max / day) * day; x day) { const last plotBands.at(-1); if (isWeekend(x) !inWeekend) { plotBands.push({ from: x, color: weekendColor }); inWeekend true; } if (!isWeekend(x) inWeekend last) { last.to x; inWeekend false; } } axis.options.plotBands plotBands; }); // 延迟初始化保证模块全部加载完成 window.addEventListener(load, function(){ Highcharts.ganttChart(container, options); }) /script /body /html图表类型 示例解析1. 图表类型Highcharts Gantt 甘特图项目排期图支持树形分层任务、任务依赖箭头、里程碑标记、进度百分比、多列侧边栏、双层时间轴。2. 核心功能模块拆解分层树形任务分为两大项目分组办公场地、新品研发每组下存在父任务、子任务自动缩进分层展示区分项目大类与细分工作项。任务前置依赖联动通过dependency绑定任务 ID自动生成带箭头连接线直观展示任务先后顺序前序任务完成后方可执行后续工作。里程碑节点milestone: true生成菱形标记仅占单个时间点用于验收、上线、测试等关键节点。任务进度百分比completed.amount配置完成比例任务条内部填充进度右侧标签直接展示百分比数值。双层 X 时间轴上层按日展示星期与日期下层按月展示年月兼顾精细查看与全局周期预览。双列表 Y 轴侧边栏左侧第一列任务名称第二列自动计算任务工期天数无需额外表格搭配。辅助视觉增强红色虚线当前系统日期标线直观区分过去 / 未来任务周末自动灰色底色区分快速识别休息日悬浮 Tooltip展示起止日期、完成进度、任务负责人、前置依赖插件扩展能力内置 Axis 扩展事件自动计算并渲染周末底色无需手动批量配置时间区间色块。在这套全功能项目甘特图案例中Highcharts Gantt 提供开箱即用的专业排期可视化能力解决传统表格、简易图表无法直观展示任务时序、依赖关系、分层结构的痛点。完备的任务结构体系原生支持父子任务分层、ID 绑定前置依赖、里程碑标记、进度百分比填充完整覆盖项目管理核心要素多维度信息一体化展示双层 X 时间轴 双列表 Y 侧边栏任务名称、工期、起止时间、负责人、完成进度统一在图表内呈现无需搭配辅助表格高度自定义视觉与交互可自由配置任务条圆角、连接线箭头样式、周末高亮色块、当前日期标线悬浮提示可自定义多字段格式化插件化扩展机制基于 Highcharts 原生事件系统扩展周末底色自动渲染逻辑扩展性强可根据业务新增节假日、预警色块、延期标记等功能无障碍与适配优化内置完整无障碍朗读描述支持键盘导航布局自适应缩放兼容 PC 端管理后台与数据大屏场景轻量化集成单库引入即可运行无需复杂依赖配置代码结构清晰便于前后端对接动态渲染项目数据。

相关新闻

PowerToys中文版:让Windows效率飞升的终极工具箱

PowerToys中文版:让Windows效率飞升的终极工具箱

PowerToys中文版:让Windows效率飞升的终极工具箱 【免费下载链接】PowerToys-CN PowerToys Simplified Chinese Translation 微软增强工具箱 自制汉化 项目地址: https://gitcode.com/gh_mirrors/po/PowerToys-CN 还在为Windows系统的操作效率而苦恼吗&#…

2026/6/18 14:20:19阅读更多 →
dnsmasq搭建简易DNS服务器--dnsmasq_windows版

dnsmasq搭建简易DNS服务器--dnsmasq_windows版

dnsmasq 不支持windows! dnsmasq 不支持windows! dnsmasq 不支持windows! 在个人电脑上组建 DNS 服务器通常是为了本地网络开发测试、屏蔽广告/恶意网站、加速域名解析或学习 DNS 原理 一、常见方案选择 修改 Hosts 文件(简易…

2026/6/18 14:20:19阅读更多 →
Gogs安全实战:从漏洞检测到全面加固的完整指南

Gogs安全实战:从漏洞检测到全面加固的完整指南

1. 项目概述:一次针对Gogs的深度安全体检最近在梳理内部代码仓库安全时,我重新审视了团队使用的Gogs服务。Gogs作为一款轻量级的Git自托管服务,因其部署简单、资源占用少,深受中小团队和开发者的喜爱。然而,正是这种“…

2026/6/18 14:20:19阅读更多 →
M68HC16系统保护机制:看门狗、总线监控与哨兵设计实战

M68HC16系统保护机制:看门狗、总线监控与哨兵设计实战

1. 项目概述:为什么嵌入式系统需要“看门狗”和“哨兵”?在工业控制、汽车电子这些对稳定性要求近乎苛刻的领域,一个微控制器(MCU)的“死机”或“跑飞”带来的后果可能是灾难性的。想象一下,一个控制刹车或…

2026/6/18 16:46:29阅读更多 →
嵌入式开发链接器配置深度解析:从内存分配到错误排查

嵌入式开发链接器配置深度解析:从内存分配到错误排查

1. 嵌入式开发中的“最后一公里”:链接器配置的深度解析干了十几年嵌入式开发,从8位机到32位MCU,从裸机到RTOS,我踩过最多的坑,往往不是算法逻辑,也不是驱动调试,而是编译链接这“最后一公里”。…

2026/6/18 16:46:29阅读更多 →
Qt 中使用 QtConcurrent::run + QFutureWatcher 实现异步处理

Qt 中使用 QtConcurrent::run + QFutureWatcher 实现异步处理

背景 在 Qt/QML 桌面应用中,C 后端经常需要执行耗时操作——音频处理、文件转换、数据分析等。如果这些操作直接在主线程(UI 线程)同步执行,界面会冻结、无法响应,Windows 甚至弹出"程序未响应"的提示。 本文…

2026/6/18 16:46:29阅读更多 →
05 | 一不小心就死锁了,怎么办?

05 | 一不小心就死锁了,怎么办?

第一部分:并发理论基础 05 | 一不小心就死锁了,怎么办? 文章目录 第一部分:并发理论基础 05 | 一不小心就死锁了,怎么办? 向现实世界要答案 没有免费的午餐 如何预防死锁 1.破坏占用且等待条件 2.破坏不可抢占条件 3.破坏循环等待条件 总结 课后思考 在上一篇文章中,我…

2026/6/18 16:46:29阅读更多 →
雅琪诺“礼服工艺”的技术体系解析:从裁剪到定型的全流程精工标准

雅琪诺“礼服工艺”的技术体系解析:从裁剪到定型的全流程精工标准

摘要:本文从工业工程角度,系统梳理雅琪诺“礼服工艺”窗帘的全流程技术标准,涵盖裁剪、缝制、定型、装配等关键工序。 正文: 1. 裁剪工序:立体裁剪与精密制版 采用电脑挂式吊裁,配合恒温恒湿生产环境-。…

2026/6/18 16:46:29阅读更多 →
PCL-Silane 硅烷改性PCL普通PCL与硅烷PCL性能对比

PCL-Silane 硅烷改性PCL普通PCL与硅烷PCL性能对比

一、分子结构差异1. 普通 PCL 基础骨架:仅由 ε- 己内酯开环聚合形成线性聚酯链,末端多为羟基或烷基封端,无额外活性功能基团 分子作用方式:分子间仅依靠酯基弱极性作用力结合,无法与无机基底形成化学键合 结构局限&am…

2026/6/18 16:41:28阅读更多 →
ZigBee HA智能家居开发实战:从集群模型到NXP JN516x代码实现

ZigBee HA智能家居开发实战:从集群模型到NXP JN516x代码实现

1. ZigBee HA:智能家居的“通用语言”与开发基石如果你正在或计划踏入智能家居设备开发领域,尤其是基于ZigBee协议,那么“ZigBee Home Automation”这个名词你一定不陌生。它不仅仅是ZigBee联盟定义的一套应用层规范,更是确保不同…

2026/6/18 0:00:24阅读更多 →
Java毕设选题推荐:基于 Spring Boot 的个人随笔博客运维管理系统的设计与实现 基于 Spring Boot 的用户原创博客分享社区【附源码、mysql、文档、调试+代码讲解+全bao等】

Java毕设选题推荐:基于 Spring Boot 的个人随笔博客运维管理系统的设计与实现 基于 Spring Boot 的用户原创博客分享社区【附源码、mysql、文档、调试+代码讲解+全bao等】

博主介绍:✌️码农一枚 ,专注于大学生项目实战开发、讲解和毕业🚢文撰写修改等。全栈领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java、小程序技术领域和毕业项目实战 ✌️技术范围:&am…

2026/6/18 0:00:24阅读更多 →
JN517x嵌入式开发实战:看门狗、脉冲计数器与I2C接口的深度解析与避坑指南

JN517x嵌入式开发实战:看门狗、脉冲计数器与I2C接口的深度解析与避坑指南

1. 项目概述在嵌入式开发领域,尤其是基于NXP JN517x这类无线微控制器的项目中,系统稳定性和与外设的可靠交互是两大核心挑战。前者关乎产品能否在无人值守的复杂环境中长期运行,后者则决定了设备能否准确感知世界并与其他芯片“对话”。JN517…

2026/6/18 0:00:24阅读更多 →