« Mermaid - graph » : différence entre les versions

De Semantic MediaWiki - Sandbox

(add)
(chg)
 
(19 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
== example 1 - graph ==
<big>→ Back to [[Mermaid|Mermaid overview]]</big>
<div style="float: right">__TOC__</div>
== Graph example ==
; Syntax
<pre>
{{#mermaid:graph TD;
{{#mermaid:graph TD;
    A-->B;
A-->B;
    A-->C;
A-->C;
    B-->D;
B-->D;
    C-->D;
C-->D;
}}
}}
</pre>


== example 2 - sequence diagram ==
; Result
{{#mermaid:sequenceDiagram
{{#mermaid:graph TD;
participant Alice
A-->B;
participant Bob
A-->C;
   Alice->John: Hello John, how are you?
B-->D;
   loop Healthcheck
C-->D;
      John->John: Fight against hypochondria
}}
   end
 
   Note right of John: Rational thoughts <br/>prevail...
== Wide top-down graph example ==
    John-->Alice: Great!
 
    John->Bob: How about you?
''Note that, <abbr title="15 September 2021">as of this writing</abbr>, an issue exists where the leftmost unlabelled edge is sometimes cut off in the rendered diagram.''
    Bob-->John: Jolly good!
 
See also:
* https://github.com/SemanticMediaWiki/Mermaid/issues/73
* [https://github.com/mermaid-js/mermaid/issues/1288 this mermaid.js issue] and [https://github.com/mermaid-js/mermaid/pull/1333 the assocated PR] on GitHub
 
; Syntax
 
<pre>
{{#mermaid:graph TD
  A[input files] --> B[pipeline]
  B --> C[output 1]
  B --> D[output 2]
  C --> E[post-process 1]
   C --> F[post-process 2]
  C --> G[post-process 2]
   D --> G[post-process 2]
  C --> H[display]
   D --> H[dipslay]
   B --> I[summary]
  E --> I[summary]
  F --> I[summary]
  G --> I[summary]
  H --> I[summary]
}}
}}
</pre>


== example 3 - gantt chart ==
; Result
{{#mermaid:gantt
{{#mermaid:graph TD
        dateFormat YYYY-MM-DD
  A[input files] --> B[pipeline]
        title Adding GANTT diagram functionality to mermaid
B --> C[output 1]
        section A section
B --> D[output 2]
        Completed task            :done,    des1, 2014-01-06,2014-01-08
C --> E[post-process 1]
        Active task              :active, des2, 2014-01-09, 3d
C --> F[post-process 2]
        Future task              :        des3, after des2, 5d
  C --> G[post-process 2]
        Future task2              :        des4, after des3, 5d
D --> G[post-process 2]
        section Critical tasks
C --> H[display]
        Completed task in the critical line :crit, done, 2014-01-06,24h
D --> H[dipslay]
        Implement parser and jison          :crit, done, after des1, 2d
B --> I[summary]
        Create tests for parser            :crit, active, 3d
E --> I[summary]
        Future task in critical line        :crit, 5d
F --> I[summary]
        Create tests for renderer          :2d
G --> I[summary]
        Add to mermaid                      :1d
H --> I[summary]
}}
}}
===Workaround using a subgraph===
''Not optimal, because the subgraph gets styled with a solid color background, but theoretically this could be overridden with CSS or [https://mermaid-js.github.io/mermaid/#/theming?id=flowchart theme variables].''
; Syntax
<pre>
{{#mermaid: config.flowchart.useMaxWidth=true | graph TD
subgraph &nbsp;
A[input files] --> B[pipeline]
B --> C[output 1]
B --> D[output 2]
C --> E[post-process 1]
C --> F[post-process 2]
C --> G[post-process 2]
D --> G[post-process 2]
C --> H[display]
D --> H[dipslay]
B --> I[summary]
E --> I[summary]
F --> I[summary]
G --> I[summary]
H --> I[summary]
end
}}
</pre>
; Result
{{#mermaid: config.flowchart.useMaxWidth=true <!-- https://mermaid-js.github.io/mermaid/#/Setup --> | graph TD
%%{init: {'theme': 'base'{{<nowiki>))</nowiki>}}%%
subgraph &nbsp;
  A[input files] --> B[pipeline]
  B --> C[output 1]
  B --> D[output 2]
  C --> E[post-process 1]
  C --> F[post-process 2]
  C --> G[post-process 2]
  D --> G[post-process 2]
  C --> H[display]
  D --> H[dipslay]
  B --> I[summary]
  E --> I[summary]
  F --> I[summary]
  G --> I[summary]
  H --> I[summary]
end
}}
{{Keywords|Keywords=mermaid;graph}}


[[Category:Mermaid examples]]
[[Category:Mermaid examples]]

Dernière version du 25 septembre 2021 à 19:29

→ Back to Mermaid overview

Graph example

Syntax
{{#mermaid:graph TD;
 A-->B;
 A-->C;
 B-->D;
 C-->D;
}}
Result

Wide top-down graph example

Note that, as of this writing, an issue exists where the leftmost unlabelled edge is sometimes cut off in the rendered diagram.

See also:

Syntax
{{#mermaid:graph TD
  A[input files] --> B[pipeline]
  B --> C[output 1]
  B --> D[output 2]
  C --> E[post-process 1]
  C --> F[post-process 2]
  C --> G[post-process 2]
  D --> G[post-process 2]
  C --> H[display]
  D --> H[dipslay]
  B --> I[summary]
  E --> I[summary]
  F --> I[summary]
  G --> I[summary]
  H --> I[summary]
}}
Result

Workaround using a subgraph

Not optimal, because the subgraph gets styled with a solid color background, but theoretically this could be overridden with CSS or theme variables.

Syntax
{{#mermaid: config.flowchart.useMaxWidth=true | graph TD
 subgraph  
 A[input files] --> B[pipeline]
 B --> C[output 1]
 B --> D[output 2]
 C --> E[post-process 1]
 C --> F[post-process 2]
 C --> G[post-process 2]
 D --> G[post-process 2]
 C --> H[display]
 D --> H[dipslay]
 B --> I[summary]
 E --> I[summary]
 F --> I[summary]
 G --> I[summary]
 H --> I[summary]
 end
}}
Result
Les cookies nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de cookies.