Mermaid语法2-流程图方向、节点以及连接

Graph

graph:绘制流程图
TD声明流程图的方向,声明了图是自上而下的(TD或TB)

graph TD
    Start --> Stop %%注释,由A到B,自上而下排
    %% graph ,声明绘制流程图,TD:top to down
    %% 第二行起建议缩进
    %% 首行不可注释
    %% --> 两个-,两边建议空格
A
B

类似,如下声明自左向右 (LR)

graph LR
    Start --> Stop
A
B

流程图方向

所有的方向:

TB - top to bottom
TD - top-down/ same as top to bottom
BT - bottom to top
RL - right to left
LR - left to right

节点

节点id是流程图的基本单元,除了end,其他字符都可以作为节点id,默认显示内容为节点id:

graph LR
	E %% E为节点id,不能是"end",但可以是“End”、“END”
E
  • 带内容的节点id
    可以给节点id内容,后续可以引用之前定义的节点内容
graph LR
id1[This is the textin the box] --> id1 
%% 节点id与内容之间没有空格
%% 可以引用之前定义的节点id
This is the textin the box

节点形状

节点可以有不同的形状,使用不同的符号,则产生不同box形状

graph TB
id1[矩形] -->
id2(圆角) -->
id3[[subroute process]] -->
id4[(圆柱形)] -->
id5([椭圆]) -->
id6((圆形)) -->
id7>不对称形状] -->
id8{菱形} -->
id9{{六边形}} -->
id10[/This is the text in the box/]  -->
id11[\This is the text in the box\]  -->
 A[/Christmas\] -->
 B[\Go shopping/]
矩形
圆角
subroute process
圆柱形
椭圆
圆形
不对称形状
菱形
六边形
This is the text in the box
This is the text in the box
Christmas
Go shopping

节点之间的连接

Nodes can be connected with links/edges. It is possible to have different types of links or attach a text string to a link.

graph LR
	A --> B  %% 箭头连接
A
B
graph LR
	C --- D %%直线连接 
C
D
graph LR
	A-- text link ---B %% 文本连接
text link
A
B
graph LR
	A-- text link -->B %% 文本箭头连接
text link
A
B
graph LR
	A-.->B %% 虚线箭头
A
B

Dotted link with text

graph LR
   A-. text .-> B %% 虚线箭头
text
A
B

Thick link

graph LR
   A ==> B %% 粗箭头
A
B
graph LR
   A == text ==> B %% 粗箭头文本
text
A
B

参考

Mermaid github

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
Mer流程图是一种用于绘制流程图、状态图、时序图和甘特图的语法和库。它使用JavaScript进行本地渲染,并广泛集成于许多Markdown编辑器中。 Mermaid的基本语法可以通过以下示例来进行说明: ``` graph LR A --> B A --> C B --> D C --> D ``` 上述示例中,`graph LR`表示创建一个方向从左到右的流程图。`A`, `B`, `C`, `D`表示节点,`-->`表示节点之间的连接关系。根据上述示例,A节点连接到B和C节点,B和C节点连接到D节点。 在使用Mermaid绘制流程图时,可以通过安装Vue组件`vue-mermaid`来方便地使用Mermaid库。首先,需要使用以下命令安装依赖: ``` npm install --save vue-mermaid ``` 然后,通过导入`vue-mermaid`组件并将其注册到Vue中,可以在组件中使用Mermaid流程图语法来绘制流程图。 总结起来,Mermaid流程图是一种使用特定语法和库来绘制流程图的方法,可以通过安装合适的工具和组件来使用。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [mermaid基本流程图](https://blog.csdn.net/fukangwei_lite/article/details/119191120)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Mermaid流程图](https://blog.csdn.net/weixin_38331049/article/details/119568081)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [vue-mermaid:Vue组件的美人鱼流程图](https://download.csdn.net/download/weixin_42109925/18271495)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值