Appearance
Mermaid的样式
流程图
定义流程图方向
先定义图向的方向如下图所示:
| 用词 flowchart x; | 含义 |
|---|---|
TB | 从上到下 |
BT | 从下到上 |
LR | 从左到右 |
RL | 从右到左 |
1. 从上到下
js
flowchart TB
A --> Bflowchart TB
A --> Bnull
2. 从下到上
js
flowchart BT
A --> Bflowchart BT
A --> Bnull
3. 从左到右
js
flowchart LR
A --> Bflowchart LR
A --> Bnull
4. 从右到左
js
flowchart RL
A --> Bflowchart RL
A --> Bnull
定义节点的样式
节点之间的连线:
节点1
js
flowchart LR
id1(This is the text in the box)flowchart LR
id1(This is the text in the box)null
节点2
js
flowchart LR
id1([one])
id2(two)
id1-->id2flowchart LR
id1([one])
id2(two)
id1-->id2null
节点3
js
flowchart LR
id1[[This is the text in the box]]flowchart LR
id1[[This is the text in the box]]null
节点4
js
flowchart LR
id1[(Database)]flowchart LR
id1[(Database)]null
节点5
js
flowchart LR
id1((This is the text in the circle))flowchart LR
id1((This is the text in the circle))null
节点6
js
flowchart LR
id1>This is the text in the box]flowchart LR
id1>This is the text in the box]null
节点7
js
flowchart LR
id1{This is the text in the box}flowchart LR
id1{This is the text in the box}null
节点8
js
flowchart LR
id1{{This is the text in the box}}flowchart LR
id1{{This is the text in the box}}null
节点9
js
flowchart RL
id1[/This is the text in the box/]flowchart RL
id1[/This is the text in the box/]null
节点10
js
flowchart RL
id1[\This is the text in the box\]flowchart RL
id1[\This is the text in the box\]null
节点11
js
flowchart RL
A[/Christmas\]flowchart RL
A[/Christmas\]null
节点12
js
flowchart RL
A[/Christmas\]flowchart RL
A[/Christmas\]null
节点13
js
flowchart RL
B[\Go shopping/]flowchart RL
B[\Go shopping/]null
节点14
js
flowchart RL
id1(((This is the text in the circle)))flowchart RL
id1(((This is the text in the circle)))null
定义节点的连线样式
节点之间的连线:
| 箭头 | 含义 |
|---|---|
> | 添加尾部箭头 |
- | 不添加尾部箭头 |
-- | 单线 |
--text-- | 单线加文字 |
== | 粗线 |
==text== | 粗线加文字 |
-.- | 虚线 |
-.text.- | 虚线加文字 |
null
带箭头点与点连接样式
样式1
js
flowchart LR
A-->|text|Bflowchart LR
A-->|text|Bnull
样式2
js
flowchart LR
A-- text -->Bflowchart LR
A-- text -->Bnull
样式3
js
flowchart LR;
A-.->B;flowchart LR;
A-.->B;null
样式4
js
flowchart LR
A-. text .-> Bflowchart LR
A-. text .-> Bnull
样式5
js
flowchart LR
A ==> Bflowchart LR
A ==> Bnull
样式6
js
flowchart LR
A == text ==> Bflowchart LR
A == text ==> Bnull
样式7
js
flowchart LR
A -- text --> B -- text2 --> Cflowchart LR
A -- text --> B -- text2 --> Cnull
样式8
js
flowchart LR
a --> b & c--> dflowchart LR
a --> b & c--> dnull
样式9
js
flowchart TB
A & B--> C & Dflowchart TB
A & B--> C & Dnull
样式10
js
flowchart TB
A --> C
A --> D
B --> C
B --> Dflowchart TB
A --> C
A --> D
B --> C
B --> Dnull
样式11
js
flowchart LR
A --o B
B --x Cflowchart LR
A --o B
B --x Cnull
样式12
js
flowchart LR
A o--o B
B <--> C
C x--x Dflowchart LR
A o--o B
B <--> C
C x--x Dnull
样式13
js
flowchart TD
A[Start] --> B{Is it?}
B -->|Yes| C[OK]
C --> D[Rethink]
D --> B
B ---->|No| E[End]flowchart TD
A[Start] --> B{Is it?}
B -->|Yes| C[OK]
C --> D[Rethink]
D --> B
B ---->|No| E[End]null
样式14
js
flowchart TD
A[Start] --> B{Is it?}
B -- Yes --> C[OK]
C --> D[Rethink]
D --> B
B -- No ----> E[End]flowchart TD
A[Start] --> B{Is it?}
B -- Yes --> C[OK]
C --> D[Rethink]
D --> B
B -- No ----> E[End]null
子图样式
子图语法样式:
subgraph title
graph definition
endsubgraph title
graph definition
end子图样式1
js
flowchart TB
c1-->a2
subgraph one
a1-->a2
end
subgraph two
b1-->b2
end
subgraph three
c1-->c2
endflowchart TB
c1-->a2
subgraph one
a1-->a2
end
subgraph two
b1-->b2
end
subgraph three
c1-->c2
endnull
子图样式2
js
flowchart TB
c1-->a2
subgraph one
a1-->a2
end
subgraph two
b1-->b2
end
subgraph three
c1-->c2
end
one --> two
three --> two
two --> c2flowchart TB
c1-->a2
subgraph one
a1-->a2
end
subgraph two
b1-->b2
end
subgraph three
c1-->c2
end
one --> two
three --> two
two --> c2null
子图样式3
js
flowchart LR
subgraph TOP
direction TB
subgraph B1
direction RL
i1 -->f1
end
subgraph B2
direction BT
i2 -->f2
end
end
A --> TOP --> B
B1 --> B2flowchart LR
subgraph TOP
direction TB
subgraph B1
direction RL
i1 -->f1
end
subgraph B2
direction BT
i2 -->f2
end
end
A --> TOP --> B
B1 --> B2null