Markdown Mermaid
本文最后更新于:2024年3月18日 凌晨
Markdown Mermaid
Graph
1 |
|
- 这是申明一个由左到右,水平向右的图。
- 可能方向有:
- TB - top bottom
- BT - bottom top
- RL - right left
- LR - left right
- TD - same as TB
节点与形状
默认节点
graph LR
id
- 注意:
id
显示在节点内部。
文本节点
1 |
|
圆角节点
1 |
|
圆节点(The form of a circle)
1 |
|
非对称节点(asymetric shape)
1 |
|
菱形节点(rhombus)
1 |
|
连接线
节点间的连接线有多种形状,而且可以在连接线中加入标签:
箭头形连接
1 |
|
开放行连接
1 |
|
标签连接
1 |
|
箭头标签连接
A–>|text|B
或者
A– text –>B
1 |
|
虚线(dotted link,点连线)
-.->
1 |
|
-.-.
1 |
|
标签虚线
-.text.->
1 |
|
粗实线
==>
1 |
|
===
1 |
|
标签粗线
==text==>
1 |
|
==text===
1 |
|
特殊的语法
使用引号可以抑制一些特殊的字符的使用,可以避免一些不必要的麻烦
graph LR
d1["This is the (text) in the box”]
1 |
|
html字符的转义字符
转义字符的使用语法:流程图定义如下:
graph LR
A["A double quote:#quot;”] –> B["A dec char:#9829;”]
渲染后的图如下:
1 |
|
子图(Subgraphs)
subgraph title
graph definition
end
示例:
graph TB
subgraph one
a1 --> a2
en
subgraph two
b2 --> b2
end
subgraph three
c1 --> c2
end
c1 --> a2
结果:
基础fontawesome支持
如果想加入来自frontawesome的图表字体,需要像frontawesome网站上那样引用的那样,
详情请点击:fontawdsome
引用的语法为:fa:#icon class name#
graph TD
B["fa:fa-twitter for peace"]
B-->C[fa:fa-ban forbidden]
B-->D(fa:fa-spinner);
B-->E(A fa:fa-camerra-retro perhaps?);
渲染图如下:
1 |
|
以上reference:
1.mermaid docs
第二部分—图表(graph)
定义连接线的样式
graph LR
id1(Start)-->id2(Stop)
style id1 fill:#f9f,stroke:#333,stroke-width:4px;
style id2 fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray:5,5;
渲染结果:
1 |
|
备注:这些样式参考CSS样式。
样式类
为了方便样式的使用,可以定义类来使用样式。类的定义示例:
1 |
|
对节点使用样式类:
1 |
|
同时对多个节点使用相同的样式类:
1 |
|
可以在CSS中提前定义样式类,应用在图表的定义中。
graph LR
A-->B[AAABBB];
B-->D;
class A cssClass;
默认样式类:当没有指定样式的时候,默认采用。
1 |
|
示例:
graph LR
classDef default fill:#f90,stroke:#555,stroke-width:4px;
id1(Start)-->id2(Stop)
结果:
1 |
|
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!