前言

甘特图这图很适合任务排期,在各种敏捷开发系统或者任务编排软件都能看到身影。

基础语法

字段解析

字段 解释
title 标题
dateFormat 日期格式
section 区域块
excludes 排除日期
axisFormat 图标 x轴日期格式调整,比如只显示月日%m-%d

任务修饰符

字段 解释
:done 完成
:active 任务激活
:crit 强调、关键任务
after 在某个日期之后, after des1 2d(任务 x des1日期之后两天)
:d 相对上个任务结束时间排期

- d
- h

- 天数
- 小时

基本姿势

  1. gantt
  2. dateFormat YYYY-MM-DD HH MM
  3. title 这是一个演示的甘特图
  4. section x35迭代
  5. 主题3.0 :active,2019-12-10,5d
  6. @h3/antd :crit,2019-12-15,7d
  7. 单元测试 :3d

Gantt(甘特图) - 图1

排除周六日及任务推后

  1. gantt
  2. dateFormat YYYY-MM-DD
  3. title 这是一个演示的甘特图
  4. excludes weekdays saturday,sunday
  5. section x35迭代
  6. 主题3.0 :active,des1,2019-12-10,5d
  7. @h3/antd :crit,after des1 3d,7d

Gantt(甘特图) - 图2

X轴日期显示调整

  1. gantt
  2. dateFormat YYYY-MM-DD HH MM
  3. title 这是一个演示的甘特图
  4. excludes weekdays saturday,sunday
  5. axisFormat %m-%d
  6. section x35迭代
  7. 主题3.0 :active ,a1 ,2019-12-10,5d
  8. @h3/antd :crit, after a1 3d,7d
  9. section x34迭代
  10. 报表批量编辑 :done,2019-11-10, 2019-12-01
  1. # axisFormat 可用的参数
  2. %a - abbreviated weekday name.
  3. %A - full weekday name.
  4. %b - abbreviated month name.
  5. %B - full month name.
  6. %c - date and time, as "%a %b %e %H:%M:%S %Y".
  7. %d - zero-padded day of the month as a decimal number [01,31].
  8. %e - space-padded day of the month as a decimal number [ 1,31]; equivalent to %_d.
  9. %H - hour (24-hour clock) as a decimal number [00,23].
  10. %I - hour (12-hour clock) as a decimal number [01,12].
  11. %j - day of the year as a decimal number [001,366].
  12. %m - month as a decimal number [01,12].
  13. %M - minute as a decimal number [00,59].
  14. %L - milliseconds as a decimal number [000, 999].
  15. %p - either AM or PM.
  16. %S - second as a decimal number [00,61].
  17. %U - week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
  18. %w - weekday as a decimal number [0(Sunday),6].
  19. %W - week number of the year (Monday as the first day of the week) as a decimal number [00,53].
  20. %x - date, as "%m/%d/%Y".
  21. %X - time, as "%H:%M:%S".
  22. %y - year without century as a decimal number [00,99].
  23. %Y - year with century as a decimal number.
  24. %Z - time zone offset, such as "-0700".
  25. %% - a literal "%" character.

Gantt(甘特图) - 图3

官方综合例子

  1. gantt
  2. dateFormat YYYY-MM-DD
  3. title Adding GANTT diagram functionality to mermaid
  4. section A section
  5. Completed task :done, des1, 2014-01-06,2014-01-08
  6. Active task :active, des2, 2014-01-09, 3d
  7. Future task : des3, after des2, 5d
  8. Future task2 : des4, after des3, 5d
  9. section Critical tasks
  10. Completed task in the critical line :crit, done, 2014-01-06,24h
  11. Implement parser and jison :crit, done, after des1, 2d
  12. Create tests for parser :crit, active, 3d
  13. Future task in critical line :crit, 5d
  14. Create tests for renderer :2d
  15. Add to mermaid :1d
  16. section Documentation
  17. Describe gantt syntax :active, a1, after des1, 3d
  18. Add gantt diagram to demo page :after a1 , 20h
  19. Add another diagram to demo page :doc1, after a1 , 48h
  20. section Last section
  21. Describe gantt syntax :after doc1, 3d
  22. Add gantt diagram to demo page :20h
  23. Add another diagram to demo page :48h

Gantt(甘特图) - 图4

总结

熟悉了这个,写任务排期就跟写 markdown列表一样,速度很快。

请不要和专业的任务排期软件对比,没有可比性!两个的出发点和量级都不是同等的。