当前位置: 首页 > news >正文

Mermaid流程图

所有流程图都由节点,几何形状和边缘,箭头或线条组成。mermaid代码定义了这些节点和边缘的制作和交互方式。
它还可以容纳不同的箭头类型、多方向箭头以及与子图之间的链接。

1、流程图的方向

  • TB - 从上到下
  • TD - 自上而下/与上到下相同
  • BT - 从下到上
  • RL - 从右到左
  • LR - 从左到右
flowchart TDStart --> Stop
Start
Stop
flowchart LRStart --> Stop
Start
Stop

2、节点形状

  • 具有圆边的节点
flowchart LRid1(This is the text in the box)
This is the text in the box
  • 体育场形节点
flowchart LRid1([This is the text in the box])
This is the text in the box
  • 子例程形状中的节点
flowchart LRid1[[This is the text in the box]]
This is the text in the box
  • 圆柱形节点
flowchart LRid1[(Database)]
Database
  • 圆形节点
flowchart LRid1((This is the text in the circle))
This is the text in the circle
  • 不对称形状的节点
flowchart LRid1>This is the text in the box]
This is the text in the box
  • 菱形
flowchart LRid1{This is the text in the box}
This is the text in the box
  • 六边形节点
flowchart LRid1{{This is the text in the box}}
This is the text in the box
  • 平行四边形
flowchart TDid1[/This is the text in the box/]
This is the text in the box
  • 平行四边形替代
flowchart TDid1[\This is the text in the box\]
This is the text in the box
  • 梯形
flowchart TDA[/Christmas\]
Christmas
  • 梯形替代
flowchart TDB[\Go shopping/]
Go shopping

3、节点之间的链接

节点可以使用链接/边连接。可以具有不同类型的链接或将文本字符串附加到链接。

  • 带箭头的链接
flowchart LRA-->B
A
B
  • 打开的链接
flowchart LRA --- B
A
B
  • 链接上的文字
flowchart LRA-- This is the text! ---B
This is the text!
A
B

flowchart LRA---|This is the text|B
This is the text
A
B
  • 带有箭头和文本的链接
flowchart LRA-->|text|B
text
A
B

flowchart LRA-- text -->B
text
A
B
  • 虚线链接
flowchart LRA-.->B;
A
B
  • 带文本的虚线链接
flowchart LRA-. text .-> B
text
A
B
  • 粗链接
flowchart LRA ==> B
A
B
  • 包含文本的粗链接
flowchart LRA == text ==> B
text
A
B
  • 链式链接
    可以在同一行中声明许多链接,如下所示:
flowchart LRA -- text --> B -- text2 --> C
text
text2
A
B
C

也可以在同一行中声明多个节点链接,如下所示:

flowchart LRa --> b & c--> d
a
b
c
d

以一种非常富有表现力的方式描述依赖项。就像下面的一行:

flowchart TBA & B--> C & D
A
B
C
D

使用基本语法描述相同的关系图,则需要四行

flowchart TBA --> CA --> DB --> CB --> D
A
C
D
B
  • 新的箭头类型
flowchart LRA --o BB --x C
A
B
C
  • 多方向箭头
flowchart LRA o--o BB <--> CC x--x D
A
B
C
D
  • 链接的最小长度
    流程图中的每个节点最终被分配给渲染图中的等级,即根据其链接到的节点分配给垂直或水平级别(取决于流程图方向)。默认情况下,链接可以跨越任意数量的排名,但您可以通过在链接定义中添加额外的短划线来要求任何链接比其他链接长。
    在以下示例中,在从节点 B 到节点 E 的链接中添加了两个额外的短划线,以便它比常规链接跨越两个等级:
flowchart TDA[Start] --> B{Is it?}B -->|Yes| C[OK]C --> D[Rethink]D --> BB ---->|No| E[End]
Yes
No
Start
Is it?
OK
Rethink
End

当链接标签写入链接中间时,必须在链接的右侧添加额外的破折号。以下示例等效于上一个示例:

flowchart TDA[Start] --> B{Is it?}B -- Yes --> C[OK]C --> D[Rethink]D --> BB -- No ----> E[End]
Yes
No
Start
Is it?
OK
Rethink
End
长度123
正常---------
正常箭头–>—>---->
============
粗箭头==>===>====>
-.--. .--…-
带点的箭头-.->-…->-…->

4、 破坏语法的特殊字符

  • 可以将文本放在引号内,以便呈现更复杂的字符。如下例所示:
flowchart LRid1["This is the (text) in the box"]
This is the (text) in the box
  • 用于转义字符的实体代码
    flowchart LRA["A double quote:#quot;"] -->B["A dec char:#9829;"]
A double quote:"
A dec char:♥

5、子图

flowchart TBc1-->a2subgraph onea1-->a2endsubgraph twob1-->b2endsubgraph threec1-->c2end
three
one
c2
c1
two
b2
b1
a2
a1

还可以为子图设置显式 ID

flowchart TBc1-->a2subgraph ide1 [one]a1-->a2end
one
a2
a1
c1

使用graphtype流程图,还可以设置子图的边,如下图所示。

flowchart TBc1-->a2subgraph onea1-->a2endsubgraph twob1-->b2endsubgraph threec1-->c2endone --> twothree --> twotwo --> c2
three
one
c2
c1
two
b2
b1
a2
a1

使用 graphtype 流程图,您可以使用方向语句来设置子图将呈现的方向,如本例所示

flowchart LRsubgraph TOPdirection TBsubgraph B1direction RLi1 -->f1endsubgraph B2direction BTi2 -->f2endendA --> TOP --> BB1 --> B2
TOP
B1
f1
i1
B2
f2
i2
A
B

6、注释

注释可以在流程图中输入,解析器将忽略该流程图。注释需要位于自己的行中,并且必须以(双百分号)开头。注释开始到下一个换行符之后的任何文本都将被视为注释,包括任何流语法%%

flowchart LR
%% this is a comment A -- text --> B{node}A -- text --> B -- text2 --> C
text
text2
A
B
C

7、样式和类

7.1 设置节点样式

flowchart LRid1(Start)-->id2(Stop)style id1 fill:#f9f,stroke:#333,stroke-width:4pxstyle id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
Start
Stop

8、顶点和链接之间有空格且不带分号的图形声明

在图形声明中,语句现在也可以不带分号结尾。在 0.2.16 版本之后,用分号结束图形语句只是可选的。因此,下面的图形声明与图形的旧声明一起也是有效的。
顶点和链接之间允许使用单个空格。但是,顶点与其文本以及链接与其文本之间不应有任何空格。图形声明的旧语法也可以使用,因此这个新功能是可选的,引入以提高可读性。

flowchart LRA[Hard edge] -->|Link text| B(Round edge)B --> C{Decision}C -->|One| D[Result one]C -->|Two| E[Result two]
Link text
One
Two
Hard edge
Round edge
Decision
Result one
Result two

参考:流程图 - 基本语法

http://www.lryc.cn/news/64810.html

相关文章:

  • 国产!全志科技T507-H工业核心板( 4核ARM Cortex-A5)规格书
  • java小记 2023-05-05
  • CentOS安装Nginx
  • CSS布局基础(CSS书写顺序 导航栏写法 常见问题)
  • 打造卓越 QML 层级设计:从入门到精通
  • shell流程控制之条件判断练习
  • linux中TF启动卡制作:磁盘分区文件同步
  • 【操作系统OS】学习笔记:第一章 操作系统基础【哈工大李治军老师】
  • Linux C/C++ 网络编程中地址格式转换(inet_pton和inet_ntop函数)
  • 庖丁解牛函数知识---C语言《2》
  • Git 使用教程:最详细、最正宗手把手教学(万字长文)
  • 【华为OD机试 2023最新 】最优资源分配/芯片资源占用(C语言题解 100%)
  • markdown二元运算符
  • 【华为/华三】PPP
  • 【Java笔试强训 9】
  • 【C++】STL标准库之list
  • Nomogram | 盘点一下绘制列线图的几个R包!~(二)
  • Django之定时任务django-crontab
  • linux常见命令
  • 【14.HTML-移动端适配】
  • 平衡二叉树旋转机制
  • 深入浅出C++ ——C++11
  • 智能座舱3.0阶段,看全球巨头如何打造更具“价值”的第三空间
  • 【Linux】入门介绍
  • 【Python】序列类型②-元组
  • 循环的数字
  • MySQL查询之聚合函数查询
  • 普通2本,去过字节外包,到现在年薪25W+的测试开发,我的2年转行心酸经历...
  • util.callbackify
  • 解决使用CLIP模型时TypeError: Cannot handle this data type: (1, 1, 224, 224), |u1