```{mermaid}%%| label: fig-mermaid%%| fig-width: 6%%| fig-cap: |%%| How Quarto orchestrates rendering of documents: start with %%| a qmd file, use the Knitr or Jupyter engine to perform the %%| computations and convert it to an md file, then use Pandoc %%| to convert to various file formats including HTML, PDF, %%| and Word.flowchart LR A[qmd] --> B(Knitr) A[qmd] --> C(Jupyter) B(Knitr) --> D[md] C(Jupyter) --> D[md] D[md] --> E(pandoc) E(pandoc) --> F(HTML) E(pandoc) --> G(PDF) E(pandoc) --> H(Word) E(pandoc) --> I{and more}```
图 1: How Quarto orchestrates rendering of documents: start with a qmd file, use the Knitr or Jupyter engine to perform the computations and convert it to an md file, then use Pandoc to convert to various file formats including HTML, PDF, and Word.
```{mermaid}flowchart LR A --> B C --- D G -->|线段文本|H G1 --线段文本-->H1 E ---|线段文本|F J1 -.-> J2 J3 -.虚线文本.->J4 K1 ==> K2 k3 ==加粗文本==>K4 L1 ~~~ L2 A1--text-->B1--text2-->C1```
flowchart LR
A --> B
C --- D
G -->|线段文本|H
G1 --线段文本-->H1
E ---|线段文本|F
J1 -.-> J2
J3 -.虚线文本.->J4
K1 ==> K2
k3 ==加粗文本==>K4
L1 ~~~ L2
A1--text-->B1--text2-->C1
```{mermaid}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]
长度
1
2
3
正常
---
----
-----
正常带箭头
-->
--->
---->
加粗
===
===
====
加粗带箭头
==>
===>
====>
虚线
-.-
-..-
-…-
虚线带箭头
-.->
-..->
-…->
子流程图
Mermaid在绘制流程图时允许我们添一个或多个子流程图。具体方式如下:
subgraph title
graph definition
end
下面是一个包含三个子图的流程图
```{mermaid}flowchart TB c1-->b1 subgraph one a1-->a2 end subgraph two b1-->b2 end subgraph three c1-->c2 end```
flowchart TB
c1-->b1
subgraph one
a1-->a2
end
subgraph two
b1-->b2
end
subgraph three
c1-->c2
end
子流程图的方向
使用流程图类型的图形,您可以使用direction语句来设置子图呈现的方向,就像在这个示例中一样。
```{mermaid}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 --> B2```
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 --> B2
限制性:如果子图的任何节点与外部相连,子图的方向将被忽略。相反,子图将继承父图的方向:
```{mermaid}flowchart LR subgraph subgraph1 direction TB top1[top] --> bottom1[bottom] end subgraph subgraph2 direction TB top2[top] --> bottom2[bottom] end %% ^ These subgraphs are identical, except for the links to them: %% Link *to* subgraph1: subgraph1 direction is mantained outside --> subgraph1 %% Link *within* subgraph2: %% subgraph2 inherits the direction of the top-level graph (LR) outside ---> top2```
flowchart LR
subgraph subgraph1
direction TB
top1[top] --> bottom1[bottom]
end
subgraph subgraph2
direction TB
top2[top] --> bottom2[bottom]
end
%% ^ These subgraphs are identical, except for the links to them:
%% Link *to* subgraph1: subgraph1 direction is mantained
outside --> subgraph1
%% Link *within* subgraph2:
%% subgraph2 inherits the direction of the top-level graph (LR)
outside ---> top2
```{mermaid}flowchart LR A-->B B-->C C-->D click B "https://www.github.com" "This is a tooltip for a link" click D href "https://www.github.com" "This is a tooltip for a link"```
flowchart LR
A-->B
B-->C
C-->D
click B "https://www.github.com" "This is a tooltip for a link"
click D href "https://www.github.com" "This is a tooltip for a link"