前言
甘特图这图很适合任务排期,在各种敏捷开发系统或者任务编排软件都能看到身影。
基础语法
字段解析
字段 | 解释 |
---|---|
title | 标题 |
dateFormat | 日期格式 |
section | 区域块 |
excludes | 排除日期 |
axisFormat | 图标 x轴日期格式调整,比如只显示月日%m-%d |
任务修饰符
字段 | 解释 |
---|---|
:done | 完成 |
:active | 任务激活 |
:crit | 强调、关键任务 |
after | 在某个日期之后, after des1 2d(任务 x des1日期之后两天) |
:d | 相对上个任务结束时间排期 |
- d - h |
- 天数 - 小时 |
基本姿势
gantt
dateFormat YYYY-MM-DD HH MM
title 这是一个演示的甘特图
section x云35迭代
主题3.0 :active,2019-12-10,5d
@h3/antd :crit,2019-12-15,7d
单元测试 :3d
排除周六日及任务推后
gantt
dateFormat YYYY-MM-DD
title 这是一个演示的甘特图
excludes weekdays saturday,sunday
section x云35迭代
主题3.0 :active,des1,2019-12-10,5d
@h3/antd :crit,after des1 3d,7d
X轴日期显示调整
gantt
dateFormat YYYY-MM-DD HH MM
title 这是一个演示的甘特图
excludes weekdays saturday,sunday
axisFormat %m-%d
section x云35迭代
主题3.0 :active ,a1 ,2019-12-10,5d
@h3/antd :crit, after a1 3d,7d
section x云34迭代
报表批量编辑 :done,2019-11-10, 2019-12-01
# axisFormat 可用的参数
%a - abbreviated weekday name.
%A - full weekday name.
%b - abbreviated month name.
%B - full month name.
%c - date and time, as "%a %b %e %H:%M:%S %Y".
%d - zero-padded day of the month as a decimal number [01,31].
%e - space-padded day of the month as a decimal number [ 1,31]; equivalent to %_d.
%H - hour (24-hour clock) as a decimal number [00,23].
%I - hour (12-hour clock) as a decimal number [01,12].
%j - day of the year as a decimal number [001,366].
%m - month as a decimal number [01,12].
%M - minute as a decimal number [00,59].
%L - milliseconds as a decimal number [000, 999].
%p - either AM or PM.
%S - second as a decimal number [00,61].
%U - week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
%w - weekday as a decimal number [0(Sunday),6].
%W - week number of the year (Monday as the first day of the week) as a decimal number [00,53].
%x - date, as "%m/%d/%Y".
%X - time, as "%H:%M:%S".
%y - year without century as a decimal number [00,99].
%Y - year with century as a decimal number.
%Z - time zone offset, such as "-0700".
%% - a literal "%" character.
官方综合例子
gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram functionality to mermaid
section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des3, 5d
section Critical tasks
Completed task in the critical line :crit, done, 2014-01-06,24h
Implement parser and jison :crit, done, after des1, 2d
Create tests for parser :crit, active, 3d
Future task in critical line :crit, 5d
Create tests for renderer :2d
Add to mermaid :1d
section Documentation
Describe gantt syntax :active, a1, after des1, 3d
Add gantt diagram to demo page :after a1 , 20h
Add another diagram to demo page :doc1, after a1 , 48h
section Last section
Describe gantt syntax :after doc1, 3d
Add gantt diagram to demo page :20h
Add another diagram to demo page :48h
总结
熟悉了这个,写任务排期就跟写 markdown列表一样,速度很快。
请不要和专业的任务排期软件对比,没有可比性!两个的出发点和量级都不是同等的。