Markdown的Diagrams
2021-06-01 09:42 书书书书君 阅读(637) 评论(0) 编辑 收藏 举报尝试了sequence、flowcharts、mermaid之后,再加上博客园博客貌似不支持sequence和flowcharts,还是推荐使用mermaid。
我用markdown过程中涉及不到CLI,Configuration,API等等,就只是简单的记录一下这些语句的使用,方便自己查找。
详细文档可以去看:mermaid官方文档
原编辑文档网盘地址:
链接:https://pan.baidu.com/s/1rAt1CM8KXg-Oxj-cZSFAJQ
提取码:XL11
sequence
Alice->Bob:Hello Bob!
Note right of Bob:Bob thinks
Bob->Alice:Hi, Alice!
Andrew->China:Says Hello
Note right of China:CHina thinks \nabout it
China-->Andrew:How are you?
Andrew->China:I am good, thanks!
Title:Here is a title
A->B:Normal line
B-->C:Dashed line
C->>D:Open arrow
D-->>A:Dashed open arrow
# Example of a comment
Note left of A:Note to the \n left of A
Note right of A:Note to the \n right of A
Note over A:Note over A
Note over A,B:Note over both A and B
participant C
FlowCharts
st=>start: Start
op=>operation: Your Operation
cond=>condition: Yes or No?
e=>end
st->op->cond
cond(yes)->e
cond(no)->op
st=>start: 开始
communicate=>operation: 启动内外网通信检测线程
card=>operation: 启动密码卡状态检测线程
interface=>operation: 启动对外通信接口状态检测线程
check=>operation: 内外CPU定期向外网CPU发送心跳检测指令
cond_heart=>condition: 连续3次无法收到外部CPU心跳检测响应
res=>operation: 重启故障设备
e=>end
st->communicate->check->cond_heart(yes)->res->e
cond_heart(no)->check
Mermaid
1. Sequence Diagrams
箭头
[Actor][Arrow][Actor]:Message text
Type | Description |
---|---|
-> | Solid line without arrow |
--> | Dotted line without arrow |
->> | Solid line with arrowhead |
-->> | Dotted line with arrowhead |
-x | Solid line with a cross at the end |
--x | Dotted line with a cross at the end. |
-) | Solid line with an open arrow at the end (async) |
--) | Dotted line with a open arrow at the end (async) |
分支
loop
loop loopname
statements
end
alt
相当于if…else…end
alt condition1
statements
else condition2
statements
end
opt
相当于if没有else
opt condition
statements
end
parallel
par [Action 1]
statements
and [Action 2]
statements
and [Action 3]
statements
end
Background Highlighting
颜色采用rgb或rgba的形式
rect rgb(0,255,0)
content
end
rect rgba(0,255,0,.1)
content
end
添加编号
sequenceDiagram
%% 只需要添加就可以了
autonumber
2. Journey Diagram
journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
section Go home
Go downstairs: 5: Me
Sit down: 5: Me
3. Flowcharts
Flowcharts包含nodes, shapes, edges, arrows / lines.
end, END, End等不可以作为中间node, 会终止流程
graph LR
id1[Text in the box to display] --> id2[from Left to Right graph LR]
方向:
- TB - top to bottom
- TD - top-bottom / same as top to bottom
- BT - bottom to top
- RL - right to left
- LR - left to right
节点形状:
node[your text] - 直角矩形
node(your text) - 圆角矩形
node([your text]) - 倒圆角矩形
node[[your text]] - 子程序形状
node[(your text)] - 圆柱
node((your text)) - 正圆
node>your text] - 非对称形状
node{your text} - 菱形
node{{your text}} - 六边形
node[/your text/] - 平行四边形
node[\your text\ ] - 反平行四边形
node[/your text\ ] - 等腰梯形
node[\your text/ ] - 倒等腰梯形
连接箭头:
原版箭头样式
A --> B 普通箭头
A --- B 两端无箭头
A -- Text -- B 两端无箭头,中间有字
A --- |TEXT|B 两端无箭头,中间有字
A -->|TEXT|B 普通箭头,中间有字
A -- TEXT --> B 普通箭头,中间有字
A -.-> B 虚线箭头
A -.TEXT.-> B 虚线箭头,中间有字
A ==> B 粗箭头
A == TEXT ==> B 粗箭头,中间有字
新增箭头
以下我的版本(0.10.11)皆不支持
A --o B
A -- x C
A o--o B B <--> C C x--x D
Length | 1 | 2 | 3 |
---|---|---|---|
Normal | --- |
---- |
----- |
Normal with arrow | --> |
---> |
----> |
Thick | === |
==== |
===== |
Thick with arrow | ==> |
===> |
====> |
Dotted | -.- |
-..- |
-...- |
Dotted with arrow | -.-> |
-..-> |
-...-> |
节点连接:
A --TEXT--> B --TEXT--> C
a --> b & c--> d
子图及颜色
graph LR; A-->B; B-->C; C-->D; click A callback "Tooltip for a callback" click B "http://www.github.com" "This is a tooltip for a link" click A call callback() "Tooltip for a callback" click B href "http://www.github.com" "This is a tooltip for a link"
4. Gantt Charts
日期格式
dateFormat YYYY-MM-DD
Input Example Description:
YYYY 2014 4 digit year
YY 14 2 digit year
Q 1..4 Quarter of year. Sets month to first month in quarter.
M MM 1..12 Month number
MMM MMMM January..Dec Month name in locale set by moment.locale()
D DD 1..31 Day of month
Do 1st..31st Day of month with ordinal
DDD DDDD 1..365 Day of year
X 1410715640.579 Unix timestamp
x 1410715640579 Unix ms timestamp
H HH 0..23 24 hour time
h hh 1..12 12 hour time used with a A.
a A am pm Post or ante meridiem
m mm 0..59 Minutes
s ss 0..59 Seconds
S 0..9 Tenths of a second
SS 0..99 Hundreds of a second
SSS 0..999 Thousandths of a second
Z ZZ +12:00 Offset from UTC as +-HH:mm, +-HHmm, or Z
持续时间格式
axisFormat %Y-%m-%d
%a - abbreviated weekday name.
%A - full weekday name.
%b - abbreviated month name.
%B - full month name.
%c - date and time, as "%a %b %e %H:%M:%S %Y".
%d - zero-padded day of the month as a decimal number [01,31].
%e - space-padded day of the month as a decimal number [ 1,31]; equivalent to %_d.
%H - hour (24-hour clock) as a decimal number [00,23].
%I - hour (12-hour clock) as a decimal number [01,12].
%j - day of the year as a decimal number [001,366].
%m - month as a decimal number [01,12].
%M - minute as a decimal number [00,59].
%L - milliseconds as a decimal number [000, 999].
%p - either AM or PM.
%S - second as a decimal number [00,61].
%U - week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
%w - weekday as a decimal number [0(Sunday),6].
%W - week number of the year (Monday as the first day of the week) as a decimal number [00,53].
%x - date, as "%m/%d/%Y".
%X - time, as "%H:%M:%S".
%y - year without century as a decimal number [00,99].
%Y - year with century as a decimal number.
%Z - time zone offset, such as "-0700".
%% - a literal "%" character.
5. Class Diagrams
6. State Diagrams
7. Pie Charts
8. Requirement Diagrams
尝试过,我的版本(0.10.11)不支持