mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 07:19:41 +02:00
Grammatical touch-ups
This commit is contained in:
@@ -31,28 +31,28 @@ The three levels of are Configuration, Global, Site and Current.
|
||||
|
||||
The modifiable parts of the Configuration are limited by the secure array, which is an array of immutable parameters, this array can be expanded by site owners.
|
||||
|
||||
**Notes**: secure arrays work like nesting dolls, with the Global Configurations’ secure array being the default and immutable list of immutable parameters, or the smallest doll, to which site owners may add to, but implementors may not modify it.
|
||||
**Notes**: secure arrays work like nesting dolls, with the Global Configurations’ secure array holding the default and immutable list of immutable parameters, or the smallest doll, to which site owners may add to, but implementors may not modify it.
|
||||
|
||||
# Secure Arrays
|
||||
|
||||
Site owners can add to the **secure** array using this command:
|
||||
mermaidAPI.initialize( { startOnLoad: true, secure: ['parameter1', 'parameter2'] } );
|
||||
|
||||
default values for the `secure array` consists of: ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize']. These default values are immutable.
|
||||
Default values for the `secure array` consists of: ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize']. These default values are immutable.
|
||||
|
||||
Implementors can only modify configurations using directives, but cannot change the `secure` array.
|
||||
Implementors can only modify configurations using directives, and cannot change the `secure` array.
|
||||
|
||||
# Modifying Configurations and directives:
|
||||
The Two types of directives: are `init` or `initialize` and `wrap`.
|
||||
The Two types of directives: are `init` (or `initialize`) and `wrap`.
|
||||
|
||||
```note
|
||||
All directives are enclosed in `%%{ }%%`
|
||||
```
|
||||
|
||||
Older versions of mermaid will not parse directives because `%%` will comment out the directive. This makes the update backward compatible.
|
||||
Older versions of mermaid will not parse directives because `%%` will comment out the directive. This makes the update backwards-compatible.
|
||||
|
||||
# Init
|
||||
`init`, or `initialize`: the init or initialize directive gives the user the ability to overwrite and change the values for configuration parameters, with respect to the secure array that is in effect.
|
||||
`init`, or `initialize`: this directive gives the user the ability to overwrite and change the values for any configuration parameters not set in the secure array.
|
||||
|
||||
| Parameter | Description |Type | Required | Values|
|
||||
| --- | --- | --- | --- | --- |
|
||||
@@ -67,7 +67,7 @@ The json object that is passed as {**argument** } must be valid, quoted json or
|
||||
|
||||
`%%{init: {"theme": "default", "logLevel": 1 }}%%`
|
||||
|
||||
Configurations that are passed through init cannot change the parameters in secure arrays of higher levels. In the event of a conflict, mermaid will give priority to secure arrays and parse the request, without changing the values of the parameters in conflict.
|
||||
Configurations that are passed through init cannot change the parameters in a secure array at a higher level. In the event of a collision, mermaid will give priority to secure arrays and parse the request without changing the values of those parameters in conflict.
|
||||
|
||||
When deployed within code, init is called before the graph/diagram description.
|
||||
```
|
||||
@@ -93,14 +93,14 @@ When deployed within code, init is called before the graph/diagram description.
|
||||
```note
|
||||
Wrap is a function that is currently only deployable for sequence diagrams.
|
||||
|
||||
wrap respects manually added <br\> so if the user wants to break up their text, they have full control over those breaks by adding their own <br\> tags.
|
||||
Wrap respects a manually added <br\>, so if the user wants to break up their text, they have full control over line breaks by adding <br\> tags.
|
||||
|
||||
It is a non-argument directive and can be executed thusly:
|
||||
|
||||
`%%{wrap}%%` .
|
||||
```
|
||||
|
||||
**an example of text wrapping in a sequence diagram**:
|
||||
**An example of text wrapping in a sequence diagram**:
|
||||
|
||||

|
||||
|
||||
@@ -108,16 +108,16 @@ It is a non-argument directive and can be executed thusly:
|
||||
# Resetting Configurations:
|
||||
There are two more functions in the mermaidAPI that can be called by site owners: **reset** and **globalReset**.
|
||||
|
||||
**reset**: resets the configuration to whatever the last configuration was. This can be done to undo more recent changes to the last mermaidAPI.initialize({...}) configuration.
|
||||
**reset**: resets the configuration to whatever the last configuration was. This can be done to undo more recent changes set from the last mermaidAPI.initialize({...}) configuration.
|
||||
|
||||
**globalReset** will reset both the current configuration AND the site configuration back to the global defaults.
|
||||
|
||||
**Notes**: both reset and globalReset are only available to site owners, as such implementors would have to edit their configs with init.
|
||||
**Notes**: Both `reset` and `globalReset` are only available to site owners, and as such implementors have to edit their configs using `init`.
|
||||
|
||||
# Additional Utils to mermaid
|
||||
• **memoize**: simple caching for computationally expensive functions. It reduces the rendering time for computationally intensive diagrams by about 90%.
|
||||
• **memoize**: simple caching for computationally expensive functions, reducing rendering time by about 90%.
|
||||
|
||||
• **assignWithDepth** - this is an improvement on previous functions with config.js and Object.assign. The purpose of this function is to provide a sane mechanism for merging objects, similar to object.assign, but with depth.
|
||||
• **assignWithDepth** - an improvement on previous functions with config.js and `Object.assign`. The purpose of this function is to provide a sane mechanism for merging objects, similar to `object.assign`, but with depth.
|
||||
|
||||
Example of **assignWithDepth**:
|
||||
|
||||
@@ -128,9 +128,9 @@ Example of **object.Assign**:
|
||||
|
||||

|
||||
|
||||
• **calculateTextDimensions, calculateTextWidth,** and **calculateTextHeight** - for measuring text dimensions, width and height.
|
||||
• **calculateTextDimensions**, **calculateTextWidth**, and **calculateTextHeight** - for measuring text dimensions, width and height.
|
||||
|
||||
**Notes**:For more information on usage, parameters, and return info for these new functions take a look at the jsdocs for them in the utils package.
|
||||
**Notes**: For more information on usage, parameters, and return info for these new functions take a look at the jsdocs for them in the utils package.
|
||||
|
||||
|
||||
# New API Requests Introduced in Version 8.6.0
|
||||
@@ -139,21 +139,21 @@ Example of **object.Assign**:
|
||||
|
||||
| Function | Description | Type | Values |Parameters|Returns|
|
||||
| --------- | ------------------- | ------- | ------------------ | ------------------ | ------------------ |
|
||||
| setSiteConfig|Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array|conf|siteConfig|
|
||||
| `setSiteConfig`|Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array|conf|siteConfig|
|
||||
|
||||
```note
|
||||
Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls to reset() will reset
|
||||
the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig) will reset siteConfig and currentConfig
|
||||
to the defaultConfig
|
||||
Note: currentConfig is set in this function
|
||||
Default value: At default, will mirror Global Config
|
||||
Note: currentConfig is set in this function。
|
||||
Default value: will mirror Global Config
|
||||
```
|
||||
|
||||
## getSiteConfig
|
||||
|
||||
| Function | Description | Type | Values |
|
||||
| --------- | ------------------- | ------- | ------------------ |
|
||||
| setSiteConfig|Returns the current siteConfig base configuration | Get Request | Returns Any Values in siteConfig|
|
||||
| `getSiteConfig`|Returns the current `siteConfig` base configuration | Get Request | Returns Any Values in `siteConfig`|
|
||||
|
||||
```note
|
||||
Returns any values in siteConfig.
|
||||
@@ -163,7 +163,7 @@ Returns any values in siteConfig.
|
||||
|
||||
| Function | Description | Type | Values |Parameters|Returns|
|
||||
| --------- | ------------------- | ------- | ------------------ |----------|-------|
|
||||
| setSiteConfig|Sets the siteConfig to desired values | Put Request| Any Values, those in secure array|conf|currentConfig merged with the sanitized conf|
|
||||
| `setConfig`|Sets the `currentConfig` to desired values | Put Request| Any Values, those in secure array|conf|`currentConfig` merged with the sanitized conf|
|
||||
|
||||
```note
|
||||
Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure keys. Any
|
||||
@@ -175,7 +175,7 @@ siteConfig value.
|
||||
|
||||
| Function | Description | Type | Return Values |
|
||||
| --------- | ------------------- | ------- | ------------------ |
|
||||
| getConfig |Obtains the currentConfig | Get Request | Any Values from currentConfig|
|
||||
| `getConfig` |Obtains the `currentConfig` | Get Request | Any Values from `currentConfig`|
|
||||
|
||||
|
||||
```note
|
||||
@@ -186,7 +186,7 @@ Returns any values in currentConfig.
|
||||
|
||||
| Function | Description | Type | Values |
|
||||
| --------- | ------------------- | ------- | ------------------ |
|
||||
| sanitize |Sets the siteConfig to desired values. | Put Request(?) |None|
|
||||
| `sanitize` |Sets the `siteConfig` to desired values. | Put Request(?) |None|
|
||||
|
||||
```note
|
||||
modifies options in-place
|
||||
@@ -197,13 +197,13 @@ Ensures options parameter does not attempt to override siteConfig secure keys.
|
||||
|
||||
| Function | Description | Type | Required | Values |Parameter|
|
||||
| --------- | -------------------| ------- | -------- | ------------------ |---------|
|
||||
| reset|Resets currentConfig to conf| Put Request | Required | None| conf|
|
||||
| `reset`|Resets `currentConfig` to conf| Put Request | Required | None| conf|
|
||||
|
||||
## conf
|
||||
|
||||
| Parameter | Description |Type | Required | Values|
|
||||
| --- | --- | --- | --- | --- |
|
||||
| conf| base set of values, which currentConfig could be reset to.| Dictionary | Required | Any Values, with respect to the secure Array|
|
||||
| `conf`| base set of values, which `currentConfig` could be reset to.| Dictionary | Required | Any Values, with respect to the secure Array|
|
||||
|
||||
```note
|
||||
default: current siteConfig (optional, default `getSiteConfig()`)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Change Log
|
||||
|
||||
Here is the list of the newest versions in Descending Order, beginning from the latest version.
|
||||
All changes are in descending order, beginning with the newest (latest) version.
|
||||
|
||||
## Unreleased
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
- 📊 Diagram Syntax
|
||||
- [Flowchart](flowchart.md)
|
||||
- [Sequence diagram](sequenceDiagram.md)
|
||||
- [Sequence Diagram](sequenceDiagram.md)
|
||||
- [Class Diagram](classDiagram.md)
|
||||
- [State Diagram](stateDiagram.md)
|
||||
- [Entity Relationship Diagram](entityRelationshipDiagram.md)
|
||||
|
@@ -24,7 +24,7 @@ mermaid.initialize({
|
||||
|
||||
## #2
|
||||
|
||||
In old versions you need to add CSS file to your HTML:
|
||||
In old versions you needed to reference a CSS file in your HTML:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="mermaid.min.css">
|
||||
@@ -36,9 +36,9 @@ or
|
||||
<link rel="stylesheet" href="mermaid.forest.min.css">
|
||||
```
|
||||
|
||||
Now it is not needed to do so. And there are no more CSS files in distribution files.
|
||||
Now it is not needed, and there are no more CSS files in the distribution files.
|
||||
|
||||
You just
|
||||
You just:
|
||||
|
||||
```javascript
|
||||
mermaid.initialize({
|
||||
@@ -46,6 +46,4 @@ mermaid.initialize({
|
||||
})
|
||||
```
|
||||
|
||||
and it works like a charm.
|
||||
|
||||
This is because now the CSS is inline with SVG for portability.
|
||||
and it works like a charm because now the CSS is inline with the SVG to allow simpler portability.
|
||||
|
@@ -3,7 +3,7 @@
|
||||
> "In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among objects."
|
||||
> Wikipedia
|
||||
|
||||
The class diagram is the main building block of object-oriented modeling. It is used for general conceptual modeling of the structure of the application, and for detailed modeling translating the models into programming code. Class diagrams can also be used for data modeling. The classes in a class diagram represent both the main elements, interactions in the application, and the classes to be programmed.
|
||||
The class diagram is the main building block of object-oriented modeling. It is used for general conceptual modeling of the structure of the application, and for detailed modeling to translate the models into programming code. Class diagrams can also be used for data modeling. The classes in a class diagram represent both the main elements, interactions in the application, and the classes to be programmed.
|
||||
|
||||
Mermaid can render class diagrams.
|
||||
|
||||
@@ -56,8 +56,8 @@ classDiagram
|
||||
|
||||
There are two ways to define a class:
|
||||
|
||||
- Explicitly defining a class using keyword **class** like `class Animal`. This defines the Animal class
|
||||
- Define two classes via a **relationship** between them `Vehicle <|-- Car`. This defines two classes Vehicle and Car along with their relationship.
|
||||
- Explicitly using keyword **class** like `class Animal` which would define the Animal class.
|
||||
- Via a **relationship** which defines two classes at a time along with their relationship. For instance, `Vehicle <|-- Car`.
|
||||
|
||||
```mermaid-example
|
||||
classDiagram
|
||||
@@ -65,13 +65,13 @@ classDiagram
|
||||
Vehicle <|-- Car
|
||||
```
|
||||
|
||||
Naming convention: a class name should be composed of alphanumeric (unicode allowed) and underscore characters.
|
||||
Naming convention: a class name should be composed only of alphanumeric characters (including unicode), and underscores.
|
||||
|
||||
## Defining Members of a class
|
||||
|
||||
UML provides mechanisms to represent class members, such as attributes and methods, and additional information about them.
|
||||
UML provides mechanisms to represent class members such as attributes and methods, as well as additional information about them.
|
||||
|
||||
Mermaid distinguishes between attributes and functions/methods based on if the **parenthesis** `()` are present or not. The ones with `()` are treated as functions/methods, and others as attributes.
|
||||
Mermaid distinguishes between attributes and functions/methods based on if the **parenthesis** `()` are present or not. The ones with `()` are treated as functions/methods, and all others as attributes.
|
||||
|
||||
There are two ways to define the members of a class, and regardless of whichever syntax is used to define the members, the output will still be same. The two different ways are :
|
||||
|
||||
@@ -100,8 +100,7 @@ class BankAccount{
|
||||
|
||||
#### Return Type
|
||||
|
||||
Optionally you can end the method/function definition with the data type that will be returned (note: there must be a space between the final `)` of the method definition and return type
|
||||
example:
|
||||
Optionally you can end a method/function definition with the data type that will be returned (note: there must be a space between the final `)` and the return type). An example:
|
||||
|
||||
```mermaid-example
|
||||
classDiagram
|
||||
@@ -115,9 +114,9 @@ class BankAccount{
|
||||
|
||||
#### Generic Types
|
||||
|
||||
Members can be defined using generic types, such as `List<int>`, for fields, parameters and return types by enclosing the type within `~` (**tilde**). Note: **nested** type declarations (such as `List<List<int>>`) are not currently supported
|
||||
Members can be defined using generic types, such as `List<int>`, for fields, parameters, and return types by enclosing the type within `~` (**tilde**). Note: **nested** type declarations such as `List<List<int>>` are not currently supported.
|
||||
|
||||
This can be done as part of either class definition method:
|
||||
Generics can be represented as part of a class definition and also in the parameters or the return value of a method/function:
|
||||
|
||||
```mermaid-example
|
||||
classDiagram
|
||||
@@ -135,26 +134,25 @@ Square : +getMessages() List~string~
|
||||
|
||||
#### Return Type
|
||||
|
||||
Optionally you can end the method/function definition with the data type that will be returned
|
||||
Optionally you can end the method/function definition with the data type that will be returned.
|
||||
|
||||
#### Visibility
|
||||
|
||||
To specify the visibility of a class member (i.e. any attribute or method), these notations may be placed before the member's name, but it is optional:
|
||||
To describe the visibility (or encapsulation) of an attribute or method/function that is a part of a class (i.e. a class member), optional notation may be placed before that members' name:
|
||||
|
||||
- `+` Public
|
||||
- `-` Private
|
||||
- `#` Protected
|
||||
- `~` Package/Internal
|
||||
|
||||
> _note_ you can also include additional _classifiers_ to a method definition by adding the following notations to the end of the method, i.e.: after the `()`:
|
||||
> _note_ you can also include additional _classifiers_ to a method definition by adding the following notation to the _end_ of the method, i.e.: after the `()`:
|
||||
> - `*` Abstract e.g.: `someAbstractMethod()*`
|
||||
> - `$` Static e.g.: `someStaticMethod()$`
|
||||
|
||||
> _note_ you can also include additional _classifiers_ to a field definition by adding the following notations to the end of the field name:
|
||||
> _note_ you can also include additional _classifiers_ to a field definition by adding the following notation to the end of its name:
|
||||
> - `$` Static e.g.: `String someField$`
|
||||
|
||||
|
||||
|
||||
## Defining Relationship
|
||||
|
||||
A relationship is a general term covering the specific types of logical connections found on class and object diagrams.
|
||||
@@ -163,7 +161,7 @@ A relationship is a general term covering the specific types of logical connecti
|
||||
[classA][Arrow][ClassB]
|
||||
```
|
||||
|
||||
There are different types of relations defined for classes under UML which are currently supported:
|
||||
There are eight different types of relations defined for classes under UML which are currently supported:
|
||||
|
||||
| Type | Description |
|
||||
| ----- | ------------- |
|
||||
@@ -189,7 +187,7 @@ classO .. classP
|
||||
|
||||
```
|
||||
|
||||
We can use the labels to describe nature of relation between two classes. Also, arrowheads can be used in opposite directions as well :
|
||||
We can use the labels to describe the nature of the relation between two classes. Also, arrowheads can be used in the opposite direction as well:
|
||||
|
||||
```mermaid-example
|
||||
classDiagram
|
||||
@@ -206,7 +204,7 @@ classO .. classP : Link(Dashed)
|
||||
|
||||
### Labels on Relations
|
||||
|
||||
It is possible to add a label text to a relation:
|
||||
It is possible to add label text to a relation:
|
||||
|
||||
```
|
||||
[classA][Arrow][ClassB]:LabelText
|
||||
@@ -221,7 +219,7 @@ classE o-- classF : aggregation
|
||||
|
||||
### Two-way relations
|
||||
|
||||
Relations can go in multiple ways:
|
||||
Relations can logically represent an N:M association:
|
||||
|
||||
```mmd
|
||||
classDiagram
|
||||
@@ -255,9 +253,9 @@ And `Link` can be one of:
|
||||
|
||||
## Cardinality / Multiplicity on relations
|
||||
|
||||
Multiplicity or cardinality in class diagrams indicates the number of instances of one class linked to one instance of the other class. For example, one company will have one or more employees, but each employee works for just one company.
|
||||
Multiplicity or cardinality in class diagrams indicates the number of instances of one class that can be linked to an instance of the other class. For example, each company will have one or more employees (not zero), and each employee currently works for zero or one companies.
|
||||
|
||||
Multiplicity notations are placed near the ends of an association.
|
||||
Multiplicity notations are placed near the end of an association.
|
||||
|
||||
The different cardinality options are :
|
||||
|
||||
@@ -269,7 +267,7 @@ The different cardinality options are :
|
||||
- `0..n` zero to n {where n>1}
|
||||
- `1..n` one to n {where n>1}
|
||||
|
||||
Cardinality can be easily defined by placing cardinality text within quotes `"` before(optional) and after(optional) a given arrow.
|
||||
Cardinality can be easily defined by placing the text option within quotes `"` before or after a given arrow. For example:
|
||||
|
||||
```
|
||||
[classA] "cardinality1" [Arrow] "cardinality2" [ClassB]:LabelText
|
||||
@@ -284,16 +282,16 @@ classDiagram
|
||||
|
||||
## Annotations on classes
|
||||
|
||||
It is possible to annotate classes with a specific marker text which is like meta-data for the class, giving a clear indication about its nature. Some common annotations examples could be:
|
||||
It is possible to annotate classes with markers to provide additional metadata about the class. This can give a clearer indication about its nature. Some common annotations include:
|
||||
|
||||
- `<<Interface>>` To represent an Interface class
|
||||
- `<<abstract>>` To represent an abstract class
|
||||
- `<<Abstract>>` To represent an abstract class
|
||||
- `<<Service>>` To represent a service class
|
||||
- `<<enumeration>>` To represent an enum
|
||||
- `<<Enumeration>>` To represent an enum
|
||||
|
||||
Annotations are defined within the opening `<<` and closing `>>`. There are two ways to add an annotation to a class and regardless of the syntax used output will be same. The two ways are :
|
||||
Annotations are defined within the opening `<<` and closing `>>`. There are two ways to add an annotation to a class, and either way the output will be same:
|
||||
|
||||
- In a **_separate line_** after a class is defined. For example:
|
||||
- In a **_separate line_** after a class is defined:
|
||||
|
||||
```mermaid-example
|
||||
classDiagram
|
||||
@@ -303,7 +301,7 @@ Shape : noOfVertices
|
||||
Shape : draw()
|
||||
```
|
||||
|
||||
- In a **_nested structure_** along with class definition. For example:
|
||||
- In a **_nested structure_** along with the class definition:
|
||||
|
||||
```mermaid-example
|
||||
classDiagram
|
||||
@@ -325,7 +323,7 @@ class Color{
|
||||
|
||||
## Comments
|
||||
|
||||
Comments can be entered within a class diagram, 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 class diagram syntax
|
||||
Comments can be entered within a class diagram, 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 until the next newline will be treated as a comment, including any class diagram syntax.
|
||||
|
||||
```mmd
|
||||
classDiagram
|
||||
@@ -335,12 +333,11 @@ class Shape{
|
||||
noOfVertices
|
||||
draw()
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## 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.
|
||||
With class diagrams you can use the direction statement to set the direction in which the diagram will render:
|
||||
|
||||
```mermaid-example
|
||||
classDiagram
|
||||
@@ -362,7 +359,7 @@ classDiagram
|
||||
|
||||
## 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'`.
|
||||
|
||||
You would define these actions on a separate line after all classes have been declared.
|
||||
|
||||
@@ -421,7 +418,7 @@ classDiagram
|
||||
|
||||
> **Success** The tooltip functionality and the ability to link to urls are available from version 0.5.2.
|
||||
|
||||
Beginners tip, a full example using interactive links in an html context:
|
||||
Beginner's tip—a full example using interactive links in an HTML page:
|
||||
|
||||
```html
|
||||
<body>
|
||||
@@ -469,8 +466,7 @@ Beginners tip, a full example using interactive links in an html context:
|
||||
|
||||
### Styling a node
|
||||
|
||||
It is possible to apply specific styles such as a thicker border or a different background color to individual nodes. This is done by predefining classes in css styles that can be applied from the graph definition as in the example
|
||||
below:
|
||||
It is possible to apply specific styles such as a thicker border or a different background color to individual nodes. This is done by predefining classes in css styles that can be applied from the graph definition:
|
||||
|
||||
```html
|
||||
<style>
|
||||
@@ -482,7 +478,7 @@ below:
|
||||
</style>
|
||||
```
|
||||
|
||||
Then attaching that class to a specific node as per below:
|
||||
Then attaching that class to a specific node:
|
||||
|
||||
```
|
||||
cssClass "nodeId1" cssClass;
|
||||
@@ -494,7 +490,7 @@ It is also possible to attach a class to a list of nodes in one statement:
|
||||
cssClass "nodeId1,nodeId2" cssClass;
|
||||
```
|
||||
|
||||
A shorter form of adding a class is to attach the classname to the node using the `:::` operator as per below:
|
||||
A shorter form of adding a class is to attach the classname to the node using the `:::` operator:
|
||||
|
||||
```mmd
|
||||
classDiagram
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# Configuration
|
||||
|
||||
When mermaid starts configuration is extracted to a configuration to be used for a diagram. There are 3 sources for configuration:
|
||||
When mermaid starts, configuration is extracted to determine a configuration to be used for a diagram. There are 3 sources for configuration:
|
||||
|
||||
* The default configuration
|
||||
* Overrides on the site level is set by the initialize call and will be applied to all diagrams in the site/app. The term for this is the **siteConfig**.
|
||||
* Directives - diagram authors can update select configuration parameters directly in the diagram code via directives and these are applied to the render config.
|
||||
* Overrides at the site level are set by the initialize call, and will be applied to all diagrams in the site/app. The term for this is the **siteConfig**.
|
||||
* Directives - diagram authors can update select configuration parameters directly in the diagram code via directives. These are applied to the render config.
|
||||
|
||||
**The render config** is configuration that is used when rendering by applying these configurations.
|
||||
|
||||
@@ -21,8 +21,8 @@ sequenceDiagram
|
||||
|
||||
## Initialize
|
||||
|
||||
Initialize call is called **only once**. It is called by the site integrator in order to override the default configuration on a site level.
|
||||
The initialize call is applied **only once**. It is called by the site integrator in order to override the default configuration at a site level.
|
||||
|
||||
## configApi.reset
|
||||
|
||||
This method resets the configuration for a diagram to the site configuration, the configuration provided by the site integrator. Before each rendering of a diagram reset is called in the very beginning of render.
|
||||
This method resets the configuration for a diagram to the overall site configuration, which is the configuration provided by the site integrator. Before each rendering of a diagram, reset is called at the very beginning.
|
||||
|
@@ -7,16 +7,14 @@ title: Flowchart
|
||||
|
||||
## Graph
|
||||
|
||||
This statement declares the direction of the Flowchart.
|
||||
|
||||
This declares the graph is oriented from top to bottom (`TD` or `TB`).
|
||||
This statement declares the direction of the flowchart, either from top to bottom (`TD` or `TB`):
|
||||
|
||||
```mermaid-example
|
||||
graph TD
|
||||
Start --> Stop
|
||||
```
|
||||
|
||||
This declares the graph is oriented from left to right (`LR`).
|
||||
or left to right (`LR`):
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -28,22 +26,21 @@ graph LR
|
||||
Possible FlowChart orientations are:
|
||||
|
||||
* TB - top to bottom
|
||||
* TD - top-down/ same as top to bottom
|
||||
* TD - top-down (same as top to bottom)
|
||||
* BT - bottom to top
|
||||
* RL - right to left
|
||||
* LR - left to right
|
||||
|
||||
|
||||
|
||||
## Flowcharts
|
||||
|
||||
This renders a flowchart that allows for features such as: more arrow types, multi directional arrows, and linking to and from subgraphs.
|
||||
|
||||
Apart from the graph type, the syntax is the same. This is currently experimental but when the beta period is over, both the graph and flowchart keywords will render in the new way. This means it is ok to start beta testing flowcharts.
|
||||
Apart from the graph type, the syntax is the same. This is currently experimental. When the beta period is over, both the graph and flowchart keywords will render in this new way. At this point it is OK to start beta testing flowcharts.
|
||||
|
||||
> **Important note** Do not type the word "end" as a Flowchart node. Capitalize all or any one the letters to keep the flowchart from breaking, i.e, "End" or "END". Or you can apply this [workaround](https://github.com/mermaid-js/mermaid/issues/1444#issuecomment-639528897).**
|
||||
|
||||
## Nodes & shapes
|
||||
## Nodes and shapes
|
||||
|
||||
### A node (default)
|
||||
|
||||
@@ -56,9 +53,9 @@ graph LR
|
||||
|
||||
### A node with text
|
||||
|
||||
It is also possible to set text in the box that differs from the id. If this is done several times, it is the last text
|
||||
found for the node that will be used. Also if you define edges for the node later on, you can omit text definitions. The
|
||||
one previously defined will be used when rendering the box.
|
||||
It is also possible to set text in the box that differs from the id. If this is done several times, only the last text
|
||||
found for the node will be rendered. Also if you define edges for the node later on, you can omit text definitions. The
|
||||
text previously defined will be used when rendering the box.
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -108,7 +105,7 @@ graph LR
|
||||
graph LR
|
||||
id1>This is the text in the box]
|
||||
```
|
||||
Currently only the shape above is possible and not its mirror. *This might change with future releases.*
|
||||
Currently it is only possible to render the shape above, and not its mirror. *This might change with future releases.*
|
||||
|
||||
### A node (rhombus)
|
||||
|
||||
@@ -117,7 +114,7 @@ graph LR
|
||||
id1{This is the text in the box}
|
||||
```
|
||||
|
||||
### A hexagon node
|
||||
### A hexagonal node
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -152,16 +149,16 @@ graph TD
|
||||
|
||||
## Links between nodes
|
||||
|
||||
Nodes can be connected with links/edges. It is possible to have different types of links or attach a text string to a link.
|
||||
Nodes can be connected with links/edges. It is possible to have different types of links, or attach a text string on a link.
|
||||
|
||||
### A link with arrow head
|
||||
### Link with arrow head
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
A-->B
|
||||
```
|
||||
|
||||
### An open link
|
||||
### Open link
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -182,7 +179,7 @@ graph LR
|
||||
A---|This is the text|B
|
||||
```
|
||||
|
||||
### A link with arrow head and text
|
||||
### Link with arrow head and text
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -226,7 +223,7 @@ graph LR
|
||||
|
||||
### Chaining of links
|
||||
|
||||
It is possible to declare many links in the same line as per below:
|
||||
It is possible to declare many links on the same line as per below:
|
||||
```mermaid-example
|
||||
graph LR
|
||||
A -- text --> B -- text2 --> C
|
||||
@@ -243,10 +240,7 @@ You can then describe dependencies in a very expressive way. Like the one-liner
|
||||
graph TB
|
||||
A & B--> C & D
|
||||
```
|
||||
If you describe the same diagram using the the basic syntax, it will take four lines. A
|
||||
word of warning, one could go overboard with this making the graph harder to read in
|
||||
markdown form. The Swedish word `lagom` comes to mind. It means, not too much and not too little.
|
||||
This goes for expressive syntaxes as well.
|
||||
If you describe the same diagram using the the basic syntax, it will take four lines:
|
||||
```mmd
|
||||
graph TB
|
||||
A --> C
|
||||
@@ -254,6 +248,9 @@ graph TB
|
||||
B --> C
|
||||
B --> D
|
||||
```
|
||||
A word of warning, one could go overboard with this, making the graph harder to read in
|
||||
markdown form. The Swedish word `lagom` comes to mind. It means, not too much and not too little.
|
||||
This goes for expressive syntaxes as well.
|
||||
|
||||
### New arrow types
|
||||
|
||||
@@ -265,7 +262,6 @@ flowchart LR
|
||||
B --x C
|
||||
```
|
||||
|
||||
|
||||
### Multi directional arrows
|
||||
|
||||
When using flowchart instead of graph there is the possibility to use multidirectional arrows.
|
||||
@@ -297,8 +293,8 @@ graph TD
|
||||
B ---->|No| E[End];
|
||||
```
|
||||
|
||||
> **Note** Links may still be made longer than the requested number of ranks
|
||||
> by the rendering engine to accommodate other requests.
|
||||
> **Note** The rendering engine may cause some links to be longer than
|
||||
> the number of ranks requested in order to accommodate the overall topology.
|
||||
|
||||
When the link label is written in the middle of the link, the extra dashes must
|
||||
be added on the right side of the link. The following example is equivalent to
|
||||
@@ -327,7 +323,7 @@ as summed up in the following table:
|
||||
|
||||
## Special characters that break syntax
|
||||
|
||||
It is possible to put text within quotes in order to render more troublesome characters. As in the example below:
|
||||
Use quotes around text in order to render more troublesome characters, as in the example below:
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -336,7 +332,7 @@ graph LR
|
||||
|
||||
### Entity codes to escape characters
|
||||
|
||||
It is possible to escape characters using the syntax exemplified here.
|
||||
Special characters (including Unicode) can be included by using HTML escaping syntax:
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -351,7 +347,7 @@ subgraph title
|
||||
end
|
||||
```
|
||||
|
||||
An example below:
|
||||
An example:
|
||||
|
||||
```mermaid-example
|
||||
graph TB
|
||||
@@ -367,7 +363,7 @@ graph TB
|
||||
end
|
||||
```
|
||||
|
||||
You can also set an explicit id for the subgraph.
|
||||
You can also set an explicit id for the subgraph:
|
||||
|
||||
```mermaid-example
|
||||
graph TB
|
||||
@@ -377,9 +373,9 @@ graph TB
|
||||
end
|
||||
```
|
||||
|
||||
## flowcharts
|
||||
## Flowcharts
|
||||
|
||||
With the graphtype flowchart it is also possible to set edges to and from subgraphs as in the graph below.
|
||||
With the graphtype `flowchart` it is also possible to set edges to and from subgraphs:
|
||||
|
||||
```mermaid-example
|
||||
flowchart TB
|
||||
@@ -400,7 +396,7 @@ flowchart TB
|
||||
|
||||
## 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'`.
|
||||
A node can have click events bound that lead to either a JavaScript callback or to open a new browser tab. **Note**: This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`.
|
||||
|
||||
```
|
||||
click nodeId callback
|
||||
@@ -408,18 +404,18 @@ click nodeId call callback()
|
||||
```
|
||||
|
||||
* nodeId is the id of the node
|
||||
* callback is the name of a JavaScript function defined on the page displaying the graph, the function will be called with the nodeId as parameter.
|
||||
|
||||
Examples of tooltip usage below:
|
||||
* `callback` is the name of a JavaScript function defined on the page displaying the graph. The function will be called with the nodeId as an incoming parameter.
|
||||
|
||||
```html
|
||||
<script>
|
||||
var callback = function () {
|
||||
alert('A callback was triggered');
|
||||
var callback = function (nodeId) {
|
||||
alert('A callback was triggered on ' + nodeId);
|
||||
};
|
||||
</script>
|
||||
```
|
||||
|
||||
Examples of tooltip usage:
|
||||
|
||||
The tooltip text is surrounded in double quotes. The styles of the tooltip are set by the class .mermaidTooltip.
|
||||
|
||||
```mermaid-example
|
||||
@@ -449,7 +445,7 @@ graph LR;
|
||||
click D href "https://www.github.com" "Open this in a new tab" _blank
|
||||
```
|
||||
|
||||
Beginners tip, a full example using interactive links in a html context:
|
||||
Beginner's tip—here's a full example of using interactive links in HTML:
|
||||
|
||||
```html
|
||||
<body>
|
||||
@@ -484,7 +480,7 @@ Beginners tip, a full example using interactive links in a html context:
|
||||
|
||||
### Comments
|
||||
|
||||
Comments can be entered within a flow diagram, 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 flow syntax
|
||||
Comments can be entered within a flow diagram, 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 until the next newline will be treated as a comment, including all punctuation and any flow syntax.
|
||||
|
||||
```mmd
|
||||
graph LR
|
||||
@@ -496,16 +492,15 @@ graph LR
|
||||
|
||||
### Styling links
|
||||
|
||||
It is possible to style links. For instance you might want to style a link that is going backwards in the flow. As links
|
||||
have no ids in the same way as nodes, some other way of deciding what style the links should be attached to is required.
|
||||
Instead of ids, the order number of when the link was defined in the graph is used. In the example below the style
|
||||
defined in the linkStyle statement will belong to the fourth link in the graph:
|
||||
It is possible to style links. For instance, you might want to style a link that is going backwards in the flow. As links
|
||||
have no ids in the same way as nodes, some other way of attaching style is required.
|
||||
So instead of ids, the order number of when the link was defined in the graph is used, starting with zero. Here's a linkStyle statement that would apply style to the fourth link in the graph:
|
||||
|
||||
```
|
||||
linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;
|
||||
```
|
||||
|
||||
You can specify default to apply to all links, or you can give a list of link order numbers separated by a comma.
|
||||
You can specify a `default` to apply to all links, or you can give a comma-separated list of link order numbers.
|
||||
|
||||
Instead of giving a styles option, you can also use custom d3 curve types with the following syntax:
|
||||
|
||||
@@ -513,14 +508,14 @@ Instead of giving a styles option, you can also use custom d3 curve types with t
|
||||
linkStyle default|numList|num interpolate curveType
|
||||
```
|
||||
|
||||
If you want to add style options too, instead of writing:
|
||||
If you want to add both D3 and style options, instead of writing:
|
||||
|
||||
```
|
||||
linkStyle default interpolate cardinal
|
||||
linkStyle default stroke:#ff3,stroke-width:4px,color:red;
|
||||
```
|
||||
|
||||
You can combine them into:
|
||||
You can combine them:
|
||||
|
||||
```
|
||||
linkStyle default interpolate cardinal stroke:#ff3,stroke-width:4px,color:red;
|
||||
@@ -540,29 +535,27 @@ graph LR
|
||||
|
||||
#### Classes
|
||||
|
||||
More convenient then defining the style every time is to define a class of styles and attach this class to the nodes that
|
||||
should have a different look.
|
||||
|
||||
a class definition looks like the example below:
|
||||
More convenient than defining the style every time is to define a class of styles and attach this class reference to multiple nodes.
|
||||
|
||||
here's a class definition:
|
||||
|
||||
```
|
||||
classDef className fill:#f9f,stroke:#333,stroke-width:4px;
|
||||
```
|
||||
|
||||
Attachment of a class to a node is done as per below:
|
||||
and then attaching this class to a node is simply:
|
||||
|
||||
```
|
||||
class nodeId1 className;
|
||||
```
|
||||
|
||||
It is also possible to attach a class to a list of nodes in one statement:
|
||||
It is also possible to attach a class to multiple nodes in one statement:
|
||||
|
||||
```
|
||||
class nodeId1,nodeId2 className;
|
||||
```
|
||||
|
||||
A shorter form of adding a class is to attach the classname to the node using the `:::`operator as per below:
|
||||
An even shorter form of adding a class is to attach the classname to the node using the `:::`operator:
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -573,8 +566,7 @@ graph LR
|
||||
|
||||
### Css classes
|
||||
|
||||
It is also possible to predefine classes in css styles that can be applied from the graph definition as in the example
|
||||
below:
|
||||
It is also possible to predefine classes in css styles that can be applied from the graph definition:
|
||||
|
||||
**Example style**
|
||||
|
||||
@@ -598,7 +590,7 @@ graph LR;
|
||||
|
||||
### Default class
|
||||
|
||||
If a class is named default it will be assigned to all classes without specific class definitions.
|
||||
If a class is named `default` it will be assigned to all nodes that do not have a specific class definition.
|
||||
|
||||
```
|
||||
classDef default fill:#f9f,stroke:#333,stroke-width:4px;
|
||||
@@ -607,9 +599,7 @@ If a class is named default it will be assigned to all classes without specific
|
||||
|
||||
## Basic support for fontawesome
|
||||
|
||||
It is possible to add icons from fontawesome.
|
||||
|
||||
The icons are accessed via the syntax fa:#icon class name#.
|
||||
It is possible to add icons from fontawesome. These are accessed via the syntax fa:#icon-class-name#.
|
||||
|
||||
```mermaid-example
|
||||
graph TD
|
||||
@@ -622,11 +612,11 @@ graph TD
|
||||
|
||||
## Graph declarations with spaces between vertices and link and without semicolon
|
||||
|
||||
* In graph declarations, the statements also can now end without a semicolon. After release 0.2.16, ending a graph statement with semicolon is just optional. So the below graph declaration is also valid along with the old declarations of the graph.
|
||||
* After release 0.2.16, graph declaration statements do not need to end with a semicolon. (And they can continue to have the ending semicolon—it has now just become optional.) So the below graph declaration is valid along with the old declarations.
|
||||
|
||||
* A single space is allowed between vertices and the link. However there should not be any space between a vertex and its text and a link and its text. The old syntax of graph declaration will also work and hence this new feature is optional and is introduce to improve readability.
|
||||
* A single space is allowed between vertices and the link, however there should not be any space between a vertex and its text, or a link and its text. The old syntax of graph declarations will also work, so this new feature is optional and is introduced to improve readability.
|
||||
|
||||
Below is the new declaration of the graph edges which is also valid along with the old declaration of the graph edges.
|
||||
Below is an example of the new way to declare graph edges. This is valid alongside any old-style declarations of graph edges.
|
||||
|
||||
```mermaid-example
|
||||
graph LR
|
||||
@@ -641,9 +631,8 @@ graph LR
|
||||
|
||||
Is it possible to adjust the width of the rendered flowchart.
|
||||
|
||||
This is done by defining **mermaid.flowchartConfig** or by the CLI to use a json file with the configuration. How to use
|
||||
the CLI is described in the mermaidCLI page.
|
||||
mermaid.flowchartConfig can be set to a JSON string with config parameters or the corresponding object.
|
||||
This is done by defining **mermaid.flowchartConfig**, or by the CLI to use a json file with the configuration (which is described in the mermaidCLI page).
|
||||
In Javascript config parameters can be set by using `mermaid.flowchartConfig`:
|
||||
|
||||
```javascript
|
||||
mermaid.flowchartConfig = {
|
||||
|
@@ -471,7 +471,7 @@ flowchart LR
|
||||
click D href "https://www.github.com" "Open this in a new tab" _blank
|
||||
```
|
||||
|
||||
Beginners tip, a full example using interactive links in a html context:
|
||||
Beginner's tip—a full example using interactive links in a html context:
|
||||
```html
|
||||
<body>
|
||||
<div class="mermaid">
|
||||
@@ -513,7 +513,7 @@ flowchart LR
|
||||
|
||||
### Styling links
|
||||
|
||||
It is possible to style links. For instance you might want to style a link that is going backwards in the flow. As links
|
||||
It is possible to style links. For instance, you might want to style a link that is going backwards in the flow. As links
|
||||
have no ids in the same way as nodes, some other way of deciding what style the links should be attached to is required.
|
||||
Instead of ids, the order number of when the link was defined in the graph is used, or use default to apply to all links.
|
||||
In the example below the style defined in the linkStyle statement will belong to the fourth link in the graph:
|
||||
|
@@ -313,7 +313,7 @@ click taskId href URL
|
||||
* taskId is the id of the task
|
||||
* callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the taskId as the parameter if no other arguments are specified.
|
||||
|
||||
Beginners tip, a full example using interactive links in an html context:
|
||||
Beginner's tip—a full example using interactive links in an html context:
|
||||
```html
|
||||
<body>
|
||||
<div class="mermaid">
|
||||
|
@@ -8,7 +8,7 @@ Diagram Examples can be found in the [Mermaid Live Editor](https://mermaid-js.gi
|
||||
## Syntax Structure
|
||||
One would notice that all **Diagrams definitions begin** with a declaration of the **diagram type**, followed by the definitions of the diagram and its contents. This declaration notifies the parser which kind of diagram the code is supposed to generate.
|
||||
|
||||
**Example** : The code below is for an Entity Relationship Diagram, specified by the `erDiagram` declaration. What follows is the definition of the different `Entities` represented in it.
|
||||
**Example** : The code below is for an Entity Relationship Diagram, specified by the `erDiagram` declaration. What follows is the definition of the different `Entities` represented in it.
|
||||
|
||||
```mermaid-example
|
||||
erDiagram
|
||||
|
@@ -64,7 +64,7 @@ Here is an example of how `%%init%%` can set the theme to 'base', this assumes t
|
||||
```
|
||||
# List of Themes
|
||||
|
||||
# Customizing Themes with `themeVariables`
|
||||
# Customizing Themes with `themeVariables`
|
||||
|
||||
The easiest way to make a custom theme is to start with the base theme, and just modify theme variables through `themeVariables`, via `%%init%%`.
|
||||
|
||||
|
Reference in New Issue
Block a user