1. note [right of | left of][Actor]:Text 2. # 给多个模块做标签, 通过逗号分割 3. note over [Actor1, Actor2...]:Text
循环
1. loop Loop_text 2. ... statements... 3. end
选择
1. alt Describing_text 2. ...statements... 3. else 4. ...statements... 5. end
7. # 推荐在没有else的情况下使用 opt(option,选择)
9. opt Describing_text 10. ...statements... 11. end
实例:
1. sequenceDiagram 2. Alice->>Bob: Hello Bob, how are you? 3. alt is sick 4. Bob->>Alice:not so good :( 5. else is well 6. Bob->>Alice:good 7. end 8. opt Extra response 9. Bob->>Alice:Thanks for asking 10. end
连线
无箭头实线 ->
有箭头实线 ->>
无箭头虚线 –>
有箭头虚线 –>>
带x实线 -x
带x虚线 –x
如
1. sequenceDiagram 2. Note right of A: 倒霉, 碰到B了 3. A->B: Hello B, how are you ? 4. note left of B: 倒霉,碰到A了 5. B-->A: Fine, thx, and you? 6. note over A,B: 快点溜,太麻烦了 7. A->>B: I'm fine too. 8. note left of B: 快点打发了A 9. B-->>A: Great! 10. note right of A: 溜之大吉 11. A-xB: Wait a moment 12. loop Look B every minute 13. A->>B: look B, go? 14. B->>A: let me go? 15. end 16. B--xA: I'm off, byte 17. note right of A: 太好了, 他走了
想改变AB的顺序怎么办呢?
1. sequenceDiagram 2. # 通过设定参与者(participant)的顺序控制展示顺序 3. participant B 4. participant A 5. Note right of A: 倒霉, 碰到B了 6. A->B: Hello B, how are you ? 7. note left of B: 倒霉,碰到A了 8. B-->A: Fine, thx, and you? 9. note over A,B:快点溜,太麻烦了。。。 10. A->>B: I'm fine too. 11. note left of B: 快点打发了A 12. B-->>A: Great! 13. note right of A: 溜之大吉 14. A-xB: Wait a moment 15. loop Look B every minute 16. A->>B: look B, go? 17. B->>A: let me go? 18. end 19. B--xA: I'm off, byte 20. note right of A: 太好了, 他走了
1. sequenceDiagram 2. # 通过设定参与者(participants)的顺序控制展示模块顺序 3. participant Alice 4. participant Bob 5. participant John 6. Alice->John:Hello John, how are you? 7. loop Healthcheck 8. John->John:Fight against hypochondria 9. end 10. Note right of John:Rational thoughts <br/>prevail... 11. John-->Alice:Great! 12. John->Bob: How about you? 13. Bob-->John: good!
1. gantt 2. dateFormat YYYY-MM-DD 3. title Adding GANTT diagram functionality to mermaid
5. section A section 6. Completed task :done, des1, 2014-01-06,2014-01-08 7. Active task :active, des2, 2014-01-09, 3d 8. Future task : des3, after des2, 5d 9. Future task2 : des4, after des3, 5d
11. section Critical tasks 12. Completed task in the critical line :crit, done, 2014-01-06,24h 13. Implement parser and jison :crit, done, after des1, 2d 14. Create tests for parser :crit, active, 3d 15. Future task in critical line :crit, 5d 16. Create tests for renderer :2d 17. Add to mermaid :1d
19. section Documentation 20. Describe gantt syntax :active, a1, after des1, 3d 21. Add gantt diagram to demo page :after a1 , 20h 22. Add another diagram to demo page :doc1, after a1 , 48h
24. section Last section 25. Describe gantt syntax :after doc1, 3d 26. Add gantt diagram to demo page : 20h 27. Add another diagram to demo page : 48h