UNPKG

12.8 kBMarkdownView Raw
1<!-- <Remove this in the future> -->
2| :mega: :mega: :mega: |
3| :----: |
4| * If you're upgrading from a version __< v8.2.0__, there are [non-backward-compatible changes](http://mermaid-js.github.io/mermaid/#/usage?id=to-enable-click-event-and-tags-in-nodes) related to security issues. Default behaviour of the library might have changed for your implementation.|
5<!-- </Remove this in the future> -->
6
7# mermaid [![Build Status](https://travis-ci.org/mermaid-js/mermaid.svg?branch=master)](https://travis-ci.org/mermaid-js/mermaid) [![NPM](https://img.shields.io/npm/v/mermaid)](https://www.npmjs.com/package/mermaid) [![Coverage Status](https://coveralls.io/repos/github/mermaid-js/mermaid/badge.svg?branch=master)](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [![Join our Slack!](https://img.shields.io/static/v1?message=join%20chat&color=9cf&logo=slack&label=slack)](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) [![This project is using Percy.io for visual regression testing.](https://percy.io/static/images/percy-badge.svg)](https://percy.io/Mermaid/mermaid)
8
9<!-- <Main description> -->
10__mermaid is a Javascript based diagramming and charting tool. It generates diagrams flowcharts and more, using markdown-inspired text for ease and speed.__
11
12Check out the list of [Integrations and Usages of Mermaid](https://github.com/mermaid-js/mermaid/blob/develop/docs/integrations.md)
13
14For more information and help in getting started, please view our [documentation](http://mermaid-js.github.io/mermaid/) and start simplifying yours. Alternatively, you can also play with our [live editor](https://mermaidjs.github.io/mermaid-live-editor/).
15<!-- </Main description> -->
16
17:trophy: **Mermaid was nominated and won the [JS Open Source Awards (2019)](https://osawards.com/javascript/#nominees) in the category "The most exciting use of technology"!!! Thanks to all involved, people committing pull requests, people answering questions and special thanks to Tyler Long who is helping me maintain the project.**
18
19## New diagram
20
21This version comes with a new diagram type, user journey diagrams.
22
23## New diagrams in 8.4
24
25With version 8.4 class diagrams have got some new features, bug fixes and documentation. Another new feature in 8.4 is the new diagram type, state diagrams.
26
27![Image show the two new diagram types](./docs/img/new-diagrams.png)
28
29## Special note regarding version 8.2
30
31In version 8.2 a security improvement was introduced. A securityLevel configuration was introduced which sets the level of trust to be used on the parsed diagrams.
32
33- **true**: (default) tags in text are encoded, click functionality is disabled
34- false: tags in text are allowed, click functionality is enabled
35
36Closed issues:
37
38⚠️ **Note** : This changes the default behaviour of mermaid so that after upgrade to 8.2, if the securityLevel is not configured, tags in flowcharts are encoded as tags and clicking is prohibited.
39
40If your application is taking resposibility for the diagram source security you can set the securityLevel accordingly. By doing this clicks and tags are again allowed.
41
42```javascript
43mermaidAPI.initialize({
44 securityLevel: 'loose'
45});
46```
47
48For more information and help in getting started, please view our [documentation](http://mermaid-js.github.io/mermaid/) and start simplifying yours. Play with our [live editor](https://mermaidjs.github.io/mermaid-live-editor/) or jump straight to the [installation and usage](http://mermaid-js.github.io/mermaid/#/usage).
49<!-- </Main description> -->
50
51__The following are some examples of the diagrams, charts and graphs that can be made using mermaid and the Markdown-inspired text specific to it. Click here jump into the [text syntax](https://mermaid-js.github.io/mermaid/#/n00b-syntaxReference).__
52<table>
53<!-- <Flowchart> -->
54<tr><td colspan=2 align="center">
55 <b>Flow</b></br>
56 [<a href="http://mermaid-js.github.io/mermaid/#/flowchart">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggVERcbiAgICBBW0hhcmRdIC0tPnxUZXh0fCBCKFJvdW5kKVxuICAgIEIgLS0-IEN7RGVjaXNpb259XG4gICAgQyAtLT58T25lfCBEW1Jlc3VsdCAxXVxuICAgIEMgLS0-fFR3b3wgRVtSZXN1bHQgMl0iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
57</td></tr>
58<tr>
59 <td><pre>
60graph TD
61A[Hard] -->|Text| B(Round)
62B --> C{Decision}
63C -->|One| D[Result 1]
64C -->|Two| E[Result 2]
65 </pre></td>
66 <td align="center">
67 <img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-flow.png" />
68 </td>
69</tr>
70<!-- </Flowchart> -->
71<!-- <Sequence> -->
72<tr><td colspan=2 align="center">
73 <b>Sequence</b><br />
74 [<a href="http://mermaid-js.github.io/mermaid/#/sequenceDiagram">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic2VxdWVuY2VEaWFncmFtXG5BbGljZS0-PkpvaG46IEhlbGxvIEpvaG4sIGhvdyBhcmUgeW91P1xubG9vcCBIZWFsdGhjaGVja1xuICAgIEpvaG4tPj5Kb2huOiBGaWdodCBhZ2FpbnN0IGh5cG9jaG9uZHJpYVxuZW5kXG5Ob3RlIHJpZ2h0IG9mIEpvaG46IFJhdGlvbmFsIHRob3VnaHRzIVxuSm9obi0tPj5BbGljZTogR3JlYXQhXG5Kb2huLT4-Qm9iOiBIb3cgYWJvdXQgeW91P1xuQm9iLS0-PkpvaG46IEpvbGx5IGdvb2QhIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
75</td></tr>
76<tr>
77 <td><pre>
78sequenceDiagram
79Alice->>John: Hello John, how are you?
80loop Healthcheck
81 John->>John: Fight against hypochondria
82end
83Note right of John: Rational thoughts!
84John-->>Alice: Great!
85John->>Bob: How about you?
86Bob-->>John: Jolly good!
87 </pre></td>
88 <td align="center">
89 <img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-sequence.png" />
90 </td>
91</tr>
92<!-- </Sequence> -->
93<!-- <Gantt> -->
94<tr><td colspan=2 align="center">
95 <b>Gantt</b><br />
96 [<a href="http://mermaid-js.github.io/mermaid/#/gantt">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ2FudHRcbnNlY3Rpb24gU2VjdGlvblxuQ29tcGxldGVkIDpkb25lLCAgICBkZXMxLCAyMDE0LTAxLTA2LDIwMTQtMDEtMDhcbkFjdGl2ZSAgICAgICAgOmFjdGl2ZSwgIGRlczIsIDIwMTQtMDEtMDcsIDNkXG5QYXJhbGxlbCAxICAgOiAgICAgICAgIGRlczMsIGFmdGVyIGRlczEsIDFkXG5QYXJhbGxlbCAyICAgOiAgICAgICAgIGRlczQsIGFmdGVyIGRlczEsIDFkXG5QYXJhbGxlbCAzICAgOiAgICAgICAgIGRlczUsIGFmdGVyIGRlczMsIDFkXG5QYXJhbGxlbCA0ICAgOiAgICAgICAgIGRlczYsIGFmdGVyIGRlczQsIDFkIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
97</td></tr>
98<tr>
99 <td><pre>
100gantt
101section Section
102Completed :done, des1, 2014-01-06,2014-01-08
103Active :active, des2, 2014-01-07, 3d
104Parallel 1 : des3, after des1, 1d
105Parallel 2 : des4, after des1, 1d
106Parallel 3 : des5, after des3, 1d
107Parallel 4 : des6, after des4, 1d
108 </pre></td>
109 <td align="center">
110 <img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-gantt.png" />
111 </td>
112</tr>
113<!-- </Gantt> -->
114<!-- <Class> -->
115<tr><td colspan=2 align="center">
116 <b>Class</b><br />
117 [<a href="http://mermaid-js.github.io/mermaid/#/classDiagram">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiY2xhc3NEaWFncmFtXG5DbGFzczAxIDx8LS0gQXZlcnlMb25nQ2xhc3MgOiBDb29sXG48PGludGVyZmFjZT4-IENsYXNzMDFcbkNsYXNzMDkgLS0-IEMyIDogV2hlcmUgYW0gaT9cbkNsYXNzMDkgLS0qIEMzXG5DbGFzczA5IC0tfD4gQ2xhc3MwN1xuQ2xhc3MwNyA6IGVxdWFscygpXG5DbGFzczA3IDogT2JqZWN0W10gZWxlbWVudERhdGFcbkNsYXNzMDEgOiBzaXplKClcbkNsYXNzMDEgOiBpbnQgY2hpbXBcbkNsYXNzMDEgOiBpbnQgZ29yaWxsYVxuY2xhc3MgQ2xhc3MxMCB7XG4gID4-c2VydmljZT4-XG4gIGludCBpZFxuICBzaXplKClcbn0iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
118</td></tr>
119<tr>
120 <td><pre>
121classDiagram
122Class01 &lt;|-- AveryLongClass : Cool
123&lt;&lt;interface>> Class01
124Class09 --> C2 : Where am i?
125Class09 --* C3
126Class09 --|> Class07
127Class07 : equals()
128Class07 : Object[] elementData
129Class01 : size()
130Class01 : int chimp
131Class01 : int gorilla
132class Class10 {
133 &lt;&lt;service>>
134 int id
135 size()
136}
137</pre></td>
138 <td align="center">
139 <img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-class.png" />
140 </td>
141</tr>
142<!-- </Class> -->
143<!-- <State> -->
144<tr><td colspan=2 align="center">
145 <b>State</b><br />
146 [<a href="http://mermaid-js.github.io/mermaid/#/stateDiagram">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic3RhdGVEaWFncmFtXG4gICAgWypdIC0tPiBTdGlsbFxuICAgIFN0aWxsIC0tPiBbKl1cbiAgICBTdGlsbCAtLT4gTW92aW5nXG4gICAgTW92aW5nIC0tPiBTdGlsbFxuICAgIE1vdmluZyAtLT4gQ3Jhc2hcbiAgICBDcmFzaCAtLT4gWypdIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
147</td></tr>
148<tr>
149 <td><pre>
150stateDiagram
151[*] --> Still
152Still --> [*]
153Still --> Moving
154Moving --> Still
155Moving --> Crash
156Crash --> [*]
157</pre></td>
158 <td align="center">
159 <img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-state.png" />
160 </td>
161</tr>
162<!-- </State> -->
163<!-- <Pie> -->
164<tr><td colspan=2 align="center">
165 <b>Pie</b><br />
166 [<a href="http://mermaid-js.github.io/mermaid/#/pie">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoicGllXG5cIkRvZ3NcIiA6IDQyLjk2XG5cIkNhdHNcIiA6IDUwLjA1XG5cIlJhdHNcIiA6IDEwLjAxIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
167</td></tr>
168<tr>
169 <td><pre>
170pie
171"Dogs" : 386
172"Cats" : 85
173"Rats" : 15
174</pre></td>
175 <td align="center">
176 <img src="https://raw.githubusercontent.com/mermaid-js/mermaid/master/img/gray-pie.png" />
177 </td>
178</tr>
179<!-- </Pie> -->
180<!-- <Git> -->
181<tr><td colspan=2 align="center">
182 <b>Git</b><br />
183 [experimental - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ2l0R3JhcGg6XG5vcHRpb25zXG57XG4gICAgXCJub2RlU3BhY2luZ1wiOiAxNTAsXG4gICAgXCJub2RlUmFkaXVzXCI6IDEwXG59XG5lbmRcbmNvbW1pdFxuYnJhbmNoIG5ld2JyYW5jaFxuY2hlY2tvdXQgbmV3YnJhbmNoXG5jb21taXRcbmNvbW1pdFxuY2hlY2tvdXQgbWFzdGVyXG5jb21taXRcbmNvbW1pdFxubWVyZ2UgbmV3YnJhbmNoXG4iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ">live editor</a>]
184</td></tr>
185<tr>
186 <td colspan="2" align="center"><i>Coming soon!</i></td>
187</tr>
188<!-- </Git> -->
189<!-- <Journey> -->
190<tr><td colspan=2 align="center">
191 <b>User Journey</b><br />
192 [<a href="http://mermaid-js.github.io/mermaid/#/user-journey">docs</a> - <a href="https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoic3RhdGVEaWFncmFtXG4gICAgWypdIC0tPiBTdGlsbFxuICAgIFN0aWxsIC0tPiBbKl1cbiAgICBTdGlsbCAtLT4gTW92aW5nXG4gICAgTW92aW5nIC0tPiBTdGlsbFxuICAgIE1vdmluZyAtLT4gQ3Jhc2hcbiAgICBDcmFzaCAtLT4gWypdIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifX0">live editor</a>]
193</td></tr>
194<tr>
195 <td>
196 <pre>
197 journey
198 title My working day
199 section Go to work
200 Make tea: 5: Me
201 Go upstairs: 3: Me
202 Do work: 1: Me, Cat
203 section Go home
204 Go downstairs: 5: Me
205 Sit down: 3: Me
206</pre></td>
207 <td align="center">
208 <img alt="User Journey Diagram" src="img/gray-user-journey.png" />
209 </td>
210</tr>
211<!-- </Journey> -->
212
213</table>
214
215## Related projects
216
217- [Command Line Interface](https://github.com/mermaid-js/mermaid.cli)
218- [Live Editor](https://github.com/mermaid-js/mermaid-live-editor)
219- [HTTP Server](https://github.com/TomWright/mermaid-server)
220
221# Contributors [![Help wanted](https://img.shields.io/github/labels/mermaid-js/mermaid/Help%20wanted!)](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Help+wanted%21%22) [![Contributors](https://img.shields.io/github/contributors/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors) [![Commits](https://img.shields.io/github/commit-activity/m/mermaid-js/mermaid)](https://github.com/mermaid-js/mermaid/graphs/contributors)
222
223Mermaid is a growing community and is always accepting new contributors. There's a lot of different ways to help out and we're always looking for extra hands! Look at [this issue](https://github.com/mermaid-js/mermaid/issues/866) if you want to know where to start helping out.
224
225Detailed information about how to contribute can be found in the [contribution guide](CONTRIBUTING.md)
226
227# Appreciation
228A quick note from Knut Sveidqvist:
229>*Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing the graphical layout and drawing libraries!*
230>*Thanks also to the [js-sequence-diagram](http://bramp.github.io/js-sequence-diagrams) project for usage of the grammar for the sequence diagrams. Thanks to Jessica Peter for inspiration and starting point for gantt rendering.*
231>*Thank you to [Tyler Long](https://github.com/tylerlong) who has been a collaborator since April 2017.*
232>
233>*Thank you to the ever-growing list of [contributors](https://github.com/knsv/mermaid/graphs/contributors) that brought the project this far!*
234
235---
236
237*Mermaid was created by Knut Sveidqvist for easier documentation.*