mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-18 07:49:26 +02:00
Updating the docs with direction statements
This commit is contained in:
@@ -443,6 +443,46 @@ class Shape{
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Setting the direction of the diagram
|
||||||
|
|
||||||
|
With class diagrams you can use the direction statement to set the direction which the diagram will render like in this example.
|
||||||
|
|
||||||
|
```
|
||||||
|
classDiagram
|
||||||
|
direction RL
|
||||||
|
class Student {
|
||||||
|
-idCard : IdCard
|
||||||
|
}
|
||||||
|
class IdCard{
|
||||||
|
-id : int
|
||||||
|
-name : string
|
||||||
|
}
|
||||||
|
class Bike{
|
||||||
|
-id : int
|
||||||
|
-name : string
|
||||||
|
}
|
||||||
|
Student "1" --o "1" IdCard : carries
|
||||||
|
Student "1" --o "1" Bike : rides
|
||||||
|
```
|
||||||
|
This is how this renders
|
||||||
|
```mermaid
|
||||||
|
classDiagram
|
||||||
|
direction RL
|
||||||
|
class Student {
|
||||||
|
-idCard : IdCard
|
||||||
|
}
|
||||||
|
class IdCard{
|
||||||
|
-id : int
|
||||||
|
-name : string
|
||||||
|
}
|
||||||
|
class Bike{
|
||||||
|
-id : int
|
||||||
|
-name : string
|
||||||
|
}
|
||||||
|
Student "1" --o "1" IdCard : carries
|
||||||
|
Student "1" --o "1" Bike : rides
|
||||||
|
```
|
||||||
|
|
||||||
## Interaction
|
## Interaction
|
||||||
|
|
||||||
It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab. **Note**: This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`.
|
It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab. **Note**: This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`.
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<meta name="description" content="Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.">
|
<meta name="description" content="Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.">
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||||
<!-- <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css"> -->
|
<!-- <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css"> -->
|
||||||
<link rel="stylesheet" href="theme.css"> <script src="//cdn.jsdelivr.net/npm/mermaid@8.10.2/dist/mermaid.min.js"></script>
|
<link rel="stylesheet" href="theme.css"> <script src="//cdn.jsdelivr.net/npm/mermaid@8.11.4/dist/mermaid.min.js"></script>
|
||||||
<!-- <script src="http://localhost:9000/mermaid.js"></script> -->
|
<!-- <script src="http://localhost:9000/mermaid.js"></script> -->
|
||||||
<script>
|
<script>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
@@ -354,6 +354,37 @@ stateDiagram-v2
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Setting the direction of the diagram
|
||||||
|
|
||||||
|
With state diagrams you can use the direction statement to set the direction which the diagram will render like in this example.
|
||||||
|
|
||||||
|
```
|
||||||
|
stateDiagram
|
||||||
|
direction LR
|
||||||
|
[*] --> A
|
||||||
|
A --> B
|
||||||
|
B --> C
|
||||||
|
state B {
|
||||||
|
direction LR
|
||||||
|
a --> b
|
||||||
|
}
|
||||||
|
B --> D
|
||||||
|
```
|
||||||
|
This is how this renders
|
||||||
|
```mermaid
|
||||||
|
stateDiagram
|
||||||
|
direction LR
|
||||||
|
[*] --> A
|
||||||
|
A --> B
|
||||||
|
B --> C
|
||||||
|
state B {
|
||||||
|
direction LR
|
||||||
|
a --> b
|
||||||
|
}
|
||||||
|
B --> D
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Comments
|
## Comments
|
||||||
|
|
||||||
Comments can be entered within a state diagram chart, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any diagram syntax
|
Comments can be entered within a state diagram chart, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any diagram syntax
|
||||||
|
Reference in New Issue
Block a user