markdown 流程图js_通过 mermaid js 绘制流程图

简介

作为程序员经常需要写文档画流程图,写文档有 markdown 了,流程图还纠结在 vivo 中不能自拨么,今天就来了解一个更好的选择 mermaid,它的官方描述是这样的: Generation of diagrams and flowcharts from text in a similar manner as markdown.

一个和 markdown 一样方便的用文本绘制流程图的工具。

入门 graph TD

Start --> Stop graph TD

Start --> Stop

一些可选的画图方向: TB - top 到 bottom,从上到下

BT - bottom 到 top,从下到上

RL - right 到 left,从右到左

LR - left 到 right,从左到右

TD - 和 TB 一样

进阶

下面就是一个相对完善的例子了,展示了一些可用的结点形状和连线样式 graph LR

A[Square Rect] -- Link text --> B((Circle))

A --> C(Round Rect)

B .-> D{Rhombus}

C ==> D graph LR

A[Square Rect] -- Link text --> B((Circle))

A --> C(Round Rect)

B .-> D{Rhombus}

C ==> D

字符逃逸

在某些情况下,结点文本里可能会出现语法字符,这种时候就需要逃逸设置了,最简单的方式可以这样: graph LR

id1["This is the (text) in the box"] graph LR

id1["This is the (text) in the box"]

也可以这样: graph LR

A["A double quote:#quot;"] -->B["A dec char:#9829;"] graph LR

A["A double quote:#quot;"] -->B["A dec char:#9829;"]

嵌套图 graph TB

c1-->a2

subgraph one

a1-->a2

end

subgraph two

b1-->b2

end

subgraph three

c1-->c2

end graph TB

c1-->a2

subgraph one

a1-->a2

end

subgraph two

b1-->b2

end

subgraph three

c1-->c2

end

CSS 样式定制 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 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

All Done !

实际它不光能画流程图,常用的序列图甘特图也可以,更多信息参考官方文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值