collab/mermaid/docs/syntax/examples.mdblame
View source
6dd74de1> **Warning**
6dd74de2>
6dd74de3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
6dd74de4>
6dd74de5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/syntax/examples.md](../../packages/mermaid/src/docs/syntax/examples.md).
6dd74de6
6dd74de7# Examples
6dd74de8
6dd74de9This page contains a collection of examples of diagrams and charts that can be created through mermaid and its myriad applications.
6dd74de10
6dd74de11**If you wish to learn how to support mermaid on your webpage, read the [Beginner's Guide](../config/usage.md?id=usage).**
6dd74de12
6dd74de13**If you wish to learn about mermaid's syntax, Read the [Diagram Syntax](../syntax/flowchart.md?id=flowcharts-basic-syntax) section.**
6dd74de14
6dd74de15## Basic Pie Chart
6dd74de16
6dd74de17```mermaid-example
6dd74de18pie title NETFLIX
6dd74de19 "Time spent looking for movie" : 90
6dd74de20 "Time spent watching it" : 10
6dd74de21```
6dd74de22
6dd74de23```mermaid
6dd74de24pie title NETFLIX
6dd74de25 "Time spent looking for movie" : 90
6dd74de26 "Time spent watching it" : 10
6dd74de27```
6dd74de28
6dd74de29```mermaid-example
6dd74de30pie title What Voldemort doesn't have?
6dd74de31 "FRIENDS" : 2
6dd74de32 "FAMILY" : 3
6dd74de33 "NOSE" : 45
6dd74de34```
6dd74de35
6dd74de36```mermaid
6dd74de37pie title What Voldemort doesn't have?
6dd74de38 "FRIENDS" : 2
6dd74de39 "FAMILY" : 3
6dd74de40 "NOSE" : 45
6dd74de41```
6dd74de42
6dd74de43## Basic sequence diagram
6dd74de44
6dd74de45```mermaid-example
6dd74de46sequenceDiagram
6dd74de47 Alice ->> Bob: Hello Bob, how are you?
6dd74de48 Bob-->>John: How about you John?
6dd74de49 Bob--x Alice: I am good thanks!
6dd74de50 Bob-x John: I am good thanks!
6dd74de51 Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.
6dd74de52
6dd74de53 Bob-->Alice: Checking with John...
6dd74de54 Alice->John: Yes... John, how are you?
6dd74de55```
6dd74de56
6dd74de57```mermaid
6dd74de58sequenceDiagram
6dd74de59 Alice ->> Bob: Hello Bob, how are you?
6dd74de60 Bob-->>John: How about you John?
6dd74de61 Bob--x Alice: I am good thanks!
6dd74de62 Bob-x John: I am good thanks!
6dd74de63 Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.
6dd74de64
6dd74de65 Bob-->Alice: Checking with John...
6dd74de66 Alice->John: Yes... John, how are you?
6dd74de67```
6dd74de68
6dd74de69## Basic flowchart
6dd74de70
6dd74de71```mermaid-example
6dd74de72graph LR
6dd74de73 A[Square Rect] -- Link text --> B((Circle))
6dd74de74 A --> C(Round Rect)
6dd74de75 B --> D{Rhombus}
6dd74de76 C --> D
6dd74de77```
6dd74de78
6dd74de79```mermaid
6dd74de80graph LR
6dd74de81 A[Square Rect] -- Link text --> B((Circle))
6dd74de82 A --> C(Round Rect)
6dd74de83 B --> D{Rhombus}
6dd74de84 C --> D
6dd74de85```
6dd74de86
6dd74de87## Larger flowchart with some styling
6dd74de88
6dd74de89```mermaid-example
6dd74de90graph TB
6dd74de91 sq[Square shape] --> ci((Circle shape))
6dd74de92
6dd74de93 subgraph A
6dd74de94 od>Odd shape]-- Two line<br/>edge comment --> ro
6dd74de95 di{Diamond with <br/> line break} -.-> ro(Rounded<br>square<br>shape)
6dd74de96 di==>ro2(Rounded square shape)
6dd74de97 end
6dd74de98
6dd74de99 %% Notice that no text in shape are added here instead that is appended further down
6dd74de100 e --> od3>Really long text with linebreak<br>in an Odd shape]
6dd74de101
6dd74de102 %% Comments after double percent signs
6dd74de103 e((Inner / circle<br>and some odd <br>special characters)) --> f(,.?!+-*ز)
6dd74de104
6dd74de105 cyr[Cyrillic]-->cyr2((Circle shape Начало));
6dd74de106
6dd74de107 classDef green fill:#9f6,stroke:#333,stroke-width:2px;
6dd74de108 classDef orange fill:#f96,stroke:#333,stroke-width:4px;
6dd74de109 class sq,e green
6dd74de110 class di orange
6dd74de111```
6dd74de112
6dd74de113```mermaid
6dd74de114graph TB
6dd74de115 sq[Square shape] --> ci((Circle shape))
6dd74de116
6dd74de117 subgraph A
6dd74de118 od>Odd shape]-- Two line<br/>edge comment --> ro
6dd74de119 di{Diamond with <br/> line break} -.-> ro(Rounded<br>square<br>shape)
6dd74de120 di==>ro2(Rounded square shape)
6dd74de121 end
6dd74de122
6dd74de123 %% Notice that no text in shape are added here instead that is appended further down
6dd74de124 e --> od3>Really long text with linebreak<br>in an Odd shape]
6dd74de125
6dd74de126 %% Comments after double percent signs
6dd74de127 e((Inner / circle<br>and some odd <br>special characters)) --> f(,.?!+-*ز)
6dd74de128
6dd74de129 cyr[Cyrillic]-->cyr2((Circle shape Начало));
6dd74de130
6dd74de131 classDef green fill:#9f6,stroke:#333,stroke-width:2px;
6dd74de132 classDef orange fill:#f96,stroke:#333,stroke-width:4px;
6dd74de133 class sq,e green
6dd74de134 class di orange
6dd74de135```
6dd74de136
6dd74de137## SequenceDiagram: Loops, alt and opt
6dd74de138
6dd74de139```mermaid-example
6dd74de140sequenceDiagram
6dd74de141 loop Daily query
6dd74de142 Alice->>Bob: Hello Bob, how are you?
6dd74de143 alt is sick
6dd74de144 Bob->>Alice: Not so good :(
6dd74de145 else is well
6dd74de146 Bob->>Alice: Feeling fresh like a daisy
6dd74de147 end
6dd74de148
6dd74de149 opt Extra response
6dd74de150 Bob->>Alice: Thanks for asking
6dd74de151 end
6dd74de152 end
6dd74de153```
6dd74de154
6dd74de155```mermaid
6dd74de156sequenceDiagram
6dd74de157 loop Daily query
6dd74de158 Alice->>Bob: Hello Bob, how are you?
6dd74de159 alt is sick
6dd74de160 Bob->>Alice: Not so good :(
6dd74de161 else is well
6dd74de162 Bob->>Alice: Feeling fresh like a daisy
6dd74de163 end
6dd74de164
6dd74de165 opt Extra response
6dd74de166 Bob->>Alice: Thanks for asking
6dd74de167 end
6dd74de168 end
6dd74de169```
6dd74de170
6dd74de171## SequenceDiagram: Message to self in loop
6dd74de172
6dd74de173```mermaid-example
6dd74de174sequenceDiagram
6dd74de175 participant Alice
6dd74de176 participant Bob
6dd74de177 Alice->>John: Hello John, how are you?
6dd74de178 loop HealthCheck
6dd74de179 John->>John: Fight against hypochondria
6dd74de180 end
6dd74de181 Note right of John: Rational thoughts<br/>prevail...
6dd74de182 John-->>Alice: Great!
6dd74de183 John->>Bob: How about you?
6dd74de184 Bob-->>John: Jolly good!
6dd74de185```
6dd74de186
6dd74de187```mermaid
6dd74de188sequenceDiagram
6dd74de189 participant Alice
6dd74de190 participant Bob
6dd74de191 Alice->>John: Hello John, how are you?
6dd74de192 loop HealthCheck
6dd74de193 John->>John: Fight against hypochondria
6dd74de194 end
6dd74de195 Note right of John: Rational thoughts<br/>prevail...
6dd74de196 John-->>Alice: Great!
6dd74de197 John->>Bob: How about you?
6dd74de198 Bob-->>John: Jolly good!
6dd74de199```
6dd74de200
6dd74de201## Sequence Diagram: Blogging app service communication
6dd74de202
6dd74de203```mermaid-example
6dd74de204sequenceDiagram
6dd74de205 participant web as Web Browser
6dd74de206 participant blog as Blog Service
6dd74de207 participant account as Account Service
6dd74de208 participant mail as Mail Service
6dd74de209 participant db as Storage
6dd74de210
6dd74de211 Note over web,db: The user must be logged in to submit blog posts
6dd74de212 web->>+account: Logs in using credentials
6dd74de213 account->>db: Query stored accounts
6dd74de214 db->>account: Respond with query result
6dd74de215
6dd74de216 alt Credentials not found
6dd74de217 account->>web: Invalid credentials
6dd74de218 else Credentials found
6dd74de219 account->>-web: Successfully logged in
6dd74de220
6dd74de221 Note over web,db: When the user is authenticated, they can now submit new posts
6dd74de222 web->>+blog: Submit new post
6dd74de223 blog->>db: Store post data
6dd74de224
6dd74de225 par Notifications
6dd74de226 blog--)mail: Send mail to blog subscribers
6dd74de227 blog--)db: Store in-site notifications
6dd74de228 and Response
6dd74de229 blog-->>-web: Successfully posted
6dd74de230 end
6dd74de231 end
6dd74de232
6dd74de233```
6dd74de234
6dd74de235```mermaid
6dd74de236sequenceDiagram
6dd74de237 participant web as Web Browser
6dd74de238 participant blog as Blog Service
6dd74de239 participant account as Account Service
6dd74de240 participant mail as Mail Service
6dd74de241 participant db as Storage
6dd74de242
6dd74de243 Note over web,db: The user must be logged in to submit blog posts
6dd74de244 web->>+account: Logs in using credentials
6dd74de245 account->>db: Query stored accounts
6dd74de246 db->>account: Respond with query result
6dd74de247
6dd74de248 alt Credentials not found
6dd74de249 account->>web: Invalid credentials
6dd74de250 else Credentials found
6dd74de251 account->>-web: Successfully logged in
6dd74de252
6dd74de253 Note over web,db: When the user is authenticated, they can now submit new posts
6dd74de254 web->>+blog: Submit new post
6dd74de255 blog->>db: Store post data
6dd74de256
6dd74de257 par Notifications
6dd74de258 blog--)mail: Send mail to blog subscribers
6dd74de259 blog--)db: Store in-site notifications
6dd74de260 and Response
6dd74de261 blog-->>-web: Successfully posted
6dd74de262 end
6dd74de263 end
6dd74de264
6dd74de265```
6dd74de266
6dd74de267## A commit flow diagram.
6dd74de268
6dd74de269```mermaid-example
6dd74de270gitGraph:
6dd74de271 commit "Ashish"
6dd74de272 branch newbranch
6dd74de273 checkout newbranch
6dd74de274 commit id:"1111"
6dd74de275 commit tag:"test"
6dd74de276 checkout main
6dd74de277 commit type: HIGHLIGHT
6dd74de278 commit
6dd74de279 merge newbranch
6dd74de280 commit
6dd74de281 branch b2
6dd74de282 commit
6dd74de283```
6dd74de284
6dd74de285```mermaid
6dd74de286gitGraph:
6dd74de287 commit "Ashish"
6dd74de288 branch newbranch
6dd74de289 checkout newbranch
6dd74de290 commit id:"1111"
6dd74de291 commit tag:"test"
6dd74de292 checkout main
6dd74de293 commit type: HIGHLIGHT
6dd74de294 commit
6dd74de295 merge newbranch
6dd74de296 commit
6dd74de297 branch b2
6dd74de298 commit
6dd74de299```
6dd74de300
6dd74de301<!--- cspell:ignore Ashish newbranch --->