Markdown 图表

流程图

mermaid

  • mermaid 是一个用于画流程图、时序图、类图、状态图、实体关系图、甘特图、饼状图的库,使用 JS 进行本地渲染,广泛集成于许多 Markdown 编辑器中。
  • API
  • 项目地址
  • 有道云指南
  • 示例一
graph LR A[方形] -->B(圆角) B --> C{条件a} C -->|a=1| D[结果1] C -->|a=2| E[结果2]
  • 示例二
gantt dateFormat YYYY-MM-DD title 软件开发甘特图 section 设计 需求 :done, des1, 2014-01-06,2014-01-08 原型 :active, des2, 2014-01-09, 3d UI设计 : des3, after des2, 5d 未来任务 : des4, after des3, 5d section 开发 学习准备理解需求 :crit, done, 2014-01-06,24h 设计框架 :crit, done, after des2, 2d 开发 :crit, active, 3d 未来任务 :crit, 5d 耍 :2d section 测试 功能测试 :active, a1, after des3, 3d 压力测试 :after a1, 20h 测试报告 :48h

有些 markdown 编辑器需要在代码块标记代码类型,才会正确渲染,如:Typora; 有些标记之后反而不能正确渲染,如有道云笔记。

flow 标准流程图

  • flow 用于绘制流程图,分为两部分:定义节点和控制走向。
  • 示例
st=>start: 开始框
op=>operation: 处理框
cond=>condition: 判断框(是或否?)
sub1=>subroutine: 子流程
io=>inputoutput: 输入输出框
e=>end: 结束框
st->op->cond
cond(yes)->io->e
cond(no)->sub1(right)->op
  • 横向示例
st=>start: 开始框
op=>operation: 处理框
cond=>condition: 判断框(是或否?)
sub1=>subroutine: 子流程
io=>inputoutput: 输入输出框
e=>end: 结束框
st(right)->op(right)->cond
cond(yes)->io(bottom)->e
cond(no)->sub1(right)->op

sequence 时序图

  • 示例
Title: 标题:复杂使用
对象A->对象B: 对象B你好吗?(请求)
Note right of 对象B: 对象B的描述
Note left of 对象A: 对象A的描述(提示)
对象B-->对象A: 我很好(响应)
对象B->小三: 你好吗
小三-->>对象A: 对象B找我了
对象A->对象B: 你真的好吗?
Note over 小三,对象B: 我们是朋友
participant C
Note right of C: 没人陪我玩
posted @ 2022-09-05 12:38  一粒花生  阅读(451)  评论(0)    收藏  举报