• 使用Code Chart绘制流程图


    Code Chart介绍

    Code Chart是一个基于 Javascript 的图表和图表工具,它基于 markdown 语法来简化和加速生成流程图的过程,也不止于生成流程图。

    工具地址:https://www.iodraw.com/codechart

     

    图形

    头部用graph
    flowchart
    关键字来声明流程图。两者用法基本一致,使用graph
    声明时,链接线上的文字会附带白底;使用flowchart
    声明时,连接线更平滑,并且似乎可以支持更新的语法。更多区别详见源码,以下内容不加区分地使用两种声明方式。

    1. graph TD
    2. A[Christmas] -->|Get money| B(Go shopping)
    3. B --> C{Let me think}
    4. C -->|One| D[Laptop]
    5. C -->|Two| E[iPhone]
    6. C -->|Three| F[fa:fa-car Car]
    1. graph TD
    2. A[Christmas] -->|Get money| B(Go shopping)
    3. B --> C{Let me think}
    4. C -->|One| D[Laptop]
    5. C -->|Two| E[iPhone]
    6. C -->|Three| F[fa:fa-car Car]

    一个节点(默认)

    1. graph LR
    2. id

    带有文字的节点

    1. graph LR
    2. id[文字]

    流程图方向

    方向代码
    从上到下TB/TD
    从下到上BT
    从左到右LR
    从右到左RL
    1. graph TB
    2. start --> stop

    1. graph LR
    2. start --> stop

    节点样式

    矩形

    id[text]
    
    

    圆角矩形

    id(text)
    
    

    体育场形

    id([text])
    
    

    子程序形

    id[[text]]
    
    

    圆柱形

    id[(text)]
    
    

    圆形

    id((text))
    
    

    不对称矩形

    id>text]
    
    

    菱形

    id{text}
    
    

    六边形

    1. id{{text}}

    平行四边形

    1. id1[/text/]
    2. id2[\text\]

    梯形

    id[/text\]
    
    

    含特殊字符

    含有()
    []
    {}
    等特殊字符时,可用双引号""
    包裹处理。

    id["[特殊字符]"]
    
    

    小结

    节点之间的连接

    连接线样式

    连接线样式命令
    实线---
    虚线-.-
    加粗实线===
    1. a---b
    2. a-.-b
    3. a===b

    箭头样式

    箭头样式命令
    右键头-->
    圆形箭头--o
    叉形箭头--x
    双向箭头<-->
    o--o
    x--x
    1. a --> b
    2. a --ob
    3. a --x b
    4. a <--> b
    5. a o--o b

    连接上的文本

    a-->|text|b
    
    

    连接长度

    1. a1---a2
    2. b1----b2
    3. a---->b

    小结

    长度123
    Normal------------
    Normal with arrow-->--->---->
    Thick==========
    Thick with arrow==>===>====>
    Dotted-.--..--...-
    Dotted with arrow-.--..->-...->

    链式连接

    a --- b1 & b2--- c
    
    

    a1 & a2 --- b1 & b2 & b3
    
    

    示例

    1. graph TD
    2. A[Start] --> B{Is it?} -->|Yes| C[OK];
    3. C --> D[Rethink];
    4. D --> B;
    5. B ---->|No| E[End];

    节点上的超链接

    可以将单击事件绑定到节点,单击可以使 javascript 回调或将在新浏览器选项卡中打开链接。

    1. graph LR;
    2. A-->B;
    3. B-->C;
    4. click A "http://www.github.com" _blank
    5. click B "http://www.github.com" "Open this in a new tab" _blank

    子图

    1. graph TB
    2. subgraph one
    3. a1-->a2
    4. subgraph subone
    5. a11-->a21
    6. end
    7. end
    8. subgraph two
    9. b1-->b2
    10. end
    11. subgraph three
    12. c1-->c2
    13. end
    14. c1-->a2
    15. one-->two

    测试功能:子图连接

    当图像类型选择flowchart
    时,可以设置子图之间的边的连接。

    1. %% Bata:With the graphtype flowcharts it is also possible to set edges to and from subgraphs as in the flowchart below.
    2. flowchart TB
    3. c1-->a2
    4. subgraph one
    5. a1-->a2
    6. end
    7. subgraph two
    8. b1-->b2
    9. end
    10. subgraph three
    11. c1-->c2
    12. end
    13. one --> two
    14. three --> two
    15. two --> c2

    子图的方向

    1. flowchart LR
    2. subgraph TOP
    3. direction TB
    4. subgraph B1
    5. direction RL
    6. i1 -->f1
    7. end
    8. subgraph B2
    9. direction BT
    10. i2 -->f2
    11. end
    12. end
    13. A --> TOP --> B
    14. B1 --> B2

    注释

    注释以%%
    开头并且独占一行

    1. graph LR
    2. %% this is a comment A -- text --> B{node}
    3. A -- text --> B -- text2 --> C

    节点样式

    可以对节点应用特定样式,例如较粗的边框或不同的背景颜色。

    1. graph LR
    2. id1(Start)-->id2(Stop)
    3. style id1 fill:#f9f,stroke:#333,stroke-width:4px
    4. style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5

    更多样式参考可以Code Chart官方文档。

    附录:相关链接

  • 相关阅读:
    基于Windows 的 VS Code C/C++ 编译环境搭建
    经典网络学习-ResNet代码实现
    机器学习笔记之指数族分布——充分统计量与模型参数的关系
    alibaba.fastjson的使用(五)-- Json数组字符串 ==》 JSONArray
    Django——数据库
    设计模式 煎饼果子和装饰者模式
    1、Elasticsearch 8.X 概述与安装
    六、回归与聚类算法 - K-means算法
    【附源码】计算机毕业设计JAVA宠物医院管理
    应用层如何感知传输层链路故障
  • 原文地址:https://blog.csdn.net/ixiaoyang/article/details/127436554