collab/mermaid/docs/syntax/mindmap.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/mindmap.md](../../packages/mermaid/src/docs/syntax/mindmap.md).
6dd74de6
6dd74de7# Mindmap
6dd74de8
6dd74de9> Mindmap: This is an experimental diagram for now. The syntax and properties can change in future releases. The syntax is stable except for the icon integration which is the experimental part.
6dd74de10
6dd74de11"A mind map is a diagram used to visually organize information into a hierarchy, showing relationships among pieces of the whole. It is often created around a single concept, drawn as an image in the center of a blank page, to which associated representations of ideas such as images, words and parts of words are added. Major ideas are connected directly to the central concept, and other ideas branch out from those major ideas." Wikipedia
6dd74de12
6dd74de13### An example of a mindmap.
6dd74de14
6dd74de15```mermaid-example
6dd74de16mindmap
6dd74de17 root((mindmap))
6dd74de18 Origins
6dd74de19 Long history
6dd74de20 ::icon(fa fa-book)
6dd74de21 Popularisation
6dd74de22 British popular psychology author Tony Buzan
6dd74de23 Research
6dd74de24 On effectiveness<br/>and features
6dd74de25 On Automatic creation
6dd74de26 Uses
6dd74de27 Creative techniques
6dd74de28 Strategic planning
6dd74de29 Argument mapping
6dd74de30 Tools
6dd74de31 Pen and paper
6dd74de32 Mermaid
6dd74de33
6dd74de34```
6dd74de35
6dd74de36```mermaid
6dd74de37mindmap
6dd74de38 root((mindmap))
6dd74de39 Origins
6dd74de40 Long history
6dd74de41 ::icon(fa fa-book)
6dd74de42 Popularisation
6dd74de43 British popular psychology author Tony Buzan
6dd74de44 Research
6dd74de45 On effectiveness<br/>and features
6dd74de46 On Automatic creation
6dd74de47 Uses
6dd74de48 Creative techniques
6dd74de49 Strategic planning
6dd74de50 Argument mapping
6dd74de51 Tools
6dd74de52 Pen and paper
6dd74de53 Mermaid
6dd74de54
6dd74de55```
6dd74de56
6dd74de57## Syntax
6dd74de58
6dd74de59The syntax for creating Mindmaps is simple and relies on indentation for setting the levels in the hierarchy.
6dd74de60
6dd74de61In the following example you can see how there are 3 different levels. One with starting at the left of the text and another level with two rows starting at the same column, defining the node A. At the end there is one more level where the text is indented further than the previous lines defining the nodes B and C.
6dd74de62
6dd74de63```
6dd74de64mindmap
6dd74de65 Root
6dd74de66 A
6dd74de67 B
6dd74de68 C
6dd74de69```
6dd74de70
6dd74de71In summary is a simple text outline where there is one node at the root level called `Root` which has one child `A`. `A` in turn has two children `B`and `C`. In the diagram below we can see this rendered as a mindmap.
6dd74de72
6dd74de73```mermaid-example
6dd74de74mindmap
6dd74de75Root
6dd74de76 A
6dd74de77 B
6dd74de78 C
6dd74de79```
6dd74de80
6dd74de81```mermaid
6dd74de82mindmap
6dd74de83Root
6dd74de84 A
6dd74de85 B
6dd74de86 C
6dd74de87```
6dd74de88
6dd74de89In this way we can use a text outline to generate a hierarchical mindmap.
6dd74de90
6dd74de91## Different shapes
6dd74de92
6dd74de93Mermaid mindmaps can show nodes using different shapes. When specifying a shape for a node the syntax is similar to flowchart nodes, with an id followed by the shape definition and with the text within the shape delimiters. Where possible we try/will try to keep the same shapes as for flowcharts, even though they are not all supported from the start.
6dd74de94
6dd74de95Mindmap can show the following shapes:
6dd74de96
6dd74de97### Square
6dd74de98
6dd74de99```mermaid-example
6dd74de100mindmap
6dd74de101 id[I am a square]
6dd74de102```
6dd74de103
6dd74de104```mermaid
6dd74de105mindmap
6dd74de106 id[I am a square]
6dd74de107```
6dd74de108
6dd74de109### Rounded square
6dd74de110
6dd74de111```mermaid-example
6dd74de112mindmap
6dd74de113 id(I am a rounded square)
6dd74de114```
6dd74de115
6dd74de116```mermaid
6dd74de117mindmap
6dd74de118 id(I am a rounded square)
6dd74de119```
6dd74de120
6dd74de121### Circle
6dd74de122
6dd74de123```mermaid-example
6dd74de124mindmap
6dd74de125 id((I am a circle))
6dd74de126```
6dd74de127
6dd74de128```mermaid
6dd74de129mindmap
6dd74de130 id((I am a circle))
6dd74de131```
6dd74de132
6dd74de133### Bang
6dd74de134
6dd74de135```mermaid-example
6dd74de136mindmap
6dd74de137 id))I am a bang((
6dd74de138```
6dd74de139
6dd74de140```mermaid
6dd74de141mindmap
6dd74de142 id))I am a bang((
6dd74de143```
6dd74de144
6dd74de145### Cloud
6dd74de146
6dd74de147```mermaid-example
6dd74de148mindmap
6dd74de149 id)I am a cloud(
6dd74de150```
6dd74de151
6dd74de152```mermaid
6dd74de153mindmap
6dd74de154 id)I am a cloud(
6dd74de155```
6dd74de156
6dd74de157### Hexagon
6dd74de158
6dd74de159```mermaid-example
6dd74de160mindmap
6dd74de161 id{{I am a hexagon}}
6dd74de162```
6dd74de163
6dd74de164```mermaid
6dd74de165mindmap
6dd74de166 id{{I am a hexagon}}
6dd74de167```
6dd74de168
6dd74de169### Default
6dd74de170
6dd74de171```mermaid-example
6dd74de172mindmap
6dd74de173 I am the default shape
6dd74de174```
6dd74de175
6dd74de176```mermaid
6dd74de177mindmap
6dd74de178 I am the default shape
6dd74de179```
6dd74de180
6dd74de181More shapes will be added, beginning with the shapes available in flowcharts.
6dd74de182
6dd74de183# Icons and classes
6dd74de184
6dd74de185## Icons
6dd74de186
6dd74de187As with flowcharts you can add icons to your nodes but with an updated syntax. The styling for the font based icons are added during the integration so that they are available for the web page. _This is not something a diagram author can do but has to be done with the site administrator or the integrator_. Once the icon fonts are in place you add them to the mind map nodes using the `::icon()` syntax. You place the classes for the icon within the parenthesis like in the following example where icons for material design and [Font Awesome 5](https://fontawesome.com/v5/search?o=r&m=free) are displayed. The intention is that this approach should be used for all diagrams supporting icons. **Experimental feature:** This wider scope is also the reason Mindmaps are experimental as this syntax and approach could change.
6dd74de188
6dd74de189```mermaid-example
6dd74de190mindmap
6dd74de191 Root
6dd74de192 A
6dd74de193 ::icon(fa fa-book)
6dd74de194 B(B)
6dd74de195 ::icon(mdi mdi-skull-outline)
6dd74de196```
6dd74de197
6dd74de198```mermaid
6dd74de199mindmap
6dd74de200 Root
6dd74de201 A
6dd74de202 ::icon(fa fa-book)
6dd74de203 B(B)
6dd74de204 ::icon(mdi mdi-skull-outline)
6dd74de205```
6dd74de206
6dd74de207## Classes
6dd74de208
6dd74de209Again the syntax for adding classes is similar to flowcharts. You can add classes using a triple colon following a number of css classes separated by space. In the following example one of the nodes has two custom classes attached urgent turning the background red and the text white and large increasing the font size:
6dd74de210
6dd74de211```mermaid-example
6dd74de212mindmap
6dd74de213 Root
6dd74de214 A[A]
6dd74de215 :::urgent large
6dd74de216 B(B)
6dd74de217 C
6dd74de218```
6dd74de219
6dd74de220```mermaid
6dd74de221mindmap
6dd74de222 Root
6dd74de223 A[A]
6dd74de224 :::urgent large
6dd74de225 B(B)
6dd74de226 C
6dd74de227```
6dd74de228
6dd74de229_These classes need to be supplied by the site administrator._
6dd74de230
6dd74de231## Unclear indentation
6dd74de232
6dd74de233The actual indentation does not really matter only compared with the previous rows. If we take the previous example and disrupt it a little we can see how the calculations are performed. Let us start with placing C with a smaller indentation than `B` but larger then `A`.
6dd74de234
6dd74de235```
6dd74de236mindmap
6dd74de237 Root
6dd74de238 A
6dd74de239 B
6dd74de240 C
6dd74de241```
6dd74de242
6dd74de243This outline is unclear as `B` clearly is a child of `A` but when we move on to `C` the clarity is lost. `C` is neither a child of `B` with a higher indentation nor does it have the same indentation as `B`. The only thing that is clear is that the first node with smaller indentation, indicating a parent, is A. Then Mermaid relies on this known truth and compensates for the unclear indentation and selects `A` as a parent of `C` leading till the same diagram with `B` and `C` as siblings.
6dd74de244
6dd74de245```mermaid-example
6dd74de246mindmap
6dd74de247Root
6dd74de248 A
6dd74de249 B
6dd74de250 C
6dd74de251```
6dd74de252
6dd74de253```mermaid
6dd74de254mindmap
6dd74de255Root
6dd74de256 A
6dd74de257 B
6dd74de258 C
6dd74de259```
6dd74de260
6dd74de261## Markdown Strings
6dd74de262
6dd74de263The "Markdown Strings" feature enhances mind maps by offering a more versatile string type, which supports text formatting options such as bold and italics, and automatically wraps text within labels.
6dd74de264
6dd74de265```mermaid-example
6dd74de266mindmap
6dd74de267 id1["`**Root** with
6dd74de268a second line
6dd74de269Unicode works too: 🤓`"]
6dd74de270 id2["`The dog in **the** hog... a *very long text* that wraps to a new line`"]
6dd74de271 id3[Regular labels still works]
6dd74de272```
6dd74de273
6dd74de274```mermaid
6dd74de275mindmap
6dd74de276 id1["`**Root** with
6dd74de277a second line
6dd74de278Unicode works too: 🤓`"]
6dd74de279 id2["`The dog in **the** hog... a *very long text* that wraps to a new line`"]
6dd74de280 id3[Regular labels still works]
6dd74de281```
6dd74de282
6dd74de283Formatting:
6dd74de284
6dd74de285- For bold text, use double asterisks \*\* before and after the text.
6dd74de286- For italics, use single asterisks \* before and after the text.
6dd74de287- With traditional strings, you needed to add <br> tags for text to wrap in nodes. However, markdown strings automatically wrap text when it becomes too long and allows you to start a new line by simply using a newline character instead of a <br> tag.
6dd74de288
6dd74de289## Integrating with your library/website.
6dd74de290
6dd74de291Mindmap uses the experimental lazy loading & async rendering features which could change in the future. From version 9.4.0 this diagram is included in mermaid but use lazy loading in order to keep the size of mermaid down. This is important in order to be able to add additional diagrams going forward.
6dd74de292
6dd74de293You can still use the pre 9.4.0 method to add mermaid with mindmaps to a web page:
6dd74de294
6dd74de295```html
6dd74de296<script type="module">
6dd74de297 import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9.3.0/dist/mermaid.esm.min.mjs';
6dd74de298 import mindmap from 'https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-mindmap@9.3.0/dist/mermaid-mindmap.esm.min.mjs';
6dd74de299 await mermaid.registerExternalDiagrams([mindmap]);
6dd74de300</script>
6dd74de301```
6dd74de302
6dd74de303From version 9.4.0 you can simplify this code to:
6dd74de304
6dd74de305```html
6dd74de306<script type="module">
6dd74de307 import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
6dd74de308</script>
6dd74de309```
6dd74de310
6dd74de311You can also refer the [implementation in the live editor](https://github.com/mermaid-js/mermaid-live-editor/blob/develop/src/lib/util/mermaid.ts) to see how the async loading is done.
6dd74de312
6dd74de313<!---
6dd74de314cspell:locale en,en-gb
6dd74de315cspell:ignore Buzan
6dd74de316--->
6dd74de317
6dd74de318## Layouts
6dd74de319
6dd74de320Mermaid also supports a Tidy Tree layout for mindmaps.
6dd74de321
6dd74de322```
6dd74de323---
6dd74de324config:
6dd74de325 layout: tidy-tree
6dd74de326---
6dd74de327mindmap
6dd74de328root((mindmap is a long thing))
6dd74de329 A
6dd74de330 B
6dd74de331 C
6dd74de332 D
6dd74de333```
6dd74de334
6dd74de335Instructions to add and register tidy-tree layout are present in [Tidy Tree Configuration](/config/tidy-tree)