Différences entre les versions de « Mermaid - graph »

De Semantic MediaWiki - Sandbox

(chg)
(chg)
 
(13 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
This page holds examples for the [[mw:Extension:Mermaid|Mermaid]] extension. See also [https://mermaidjs.github.io/ mermaidjs.github.io] for further documentation.
+
<big>→ Back to [[Mermaid|Mermaid overview]]</big>
 
+
<div style="float: right">__TOC__</div>
== example 1 - graph ==
+
== Graph example ==
 
; Syntax
 
; Syntax
 
<pre>
 
<pre>
Ligne 11 : Ligne 11 :
 
}}
 
}}
 
</pre>
 
</pre>
 +
 
; Result
 
; Result
 
{{#mermaid:graph TD;
 
{{#mermaid:graph TD;
Ligne 19 : Ligne 20 :
 
}}
 
}}
  
== example 2 - graph with links ==
+
== Wide top-down graph example ==
 +
 
 +
''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.''
 +
 
 +
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
 
; Syntax
 +
 
<pre>
 
<pre>
{{#mermaid:graph TD;
+
{{#mermaid:graph TD
A-->B;
+
  A[input files] --> B[pipeline]
A-->C;
+
  B --> C[output 1]
B-->D;
+
  B --> D[output 2]
C-->D;
+
  C --> E[post-process 1]
click A "https://sandbox.semantic-mediawiki.org/wiki/A"
+
  C --> F[post-process 2]
click B "https://sandbox.semantic-mediawiki.org/wiki/B"
+
  C --> G[post-process 2]
click C "https://sandbox.semantic-mediawiki.org/wiki/C"
+
  D --> G[post-process 2]
click D "https://sandbox.semantic-mediawiki.org/wiki/D"
+
  C --> H[display]
 +
  D --> H[dipslay]
 +
  B --> I[summary]
 +
  E --> I[summary]
 +
  F --> I[summary]
 +
  G --> I[summary]
 +
  H --> I[summary]
 
}}
 
}}
 
</pre>
 
</pre>
 +
 
; Result
 
; Result
{{#mermaid:graph TD;
+
{{#mermaid:graph TD
  A-->B;
+
  A[input files] --> B[pipeline]
  A-->C;
+
  B --> C[output 1]
  B-->D;
+
  B --> D[output 2]
  C-->D;
+
C --> E[post-process 1]
  click A "https://sandbox.semantic-mediawiki.org/wiki/A"
+
C --> F[post-process 2]
  click B "https://sandbox.semantic-mediawiki.org/wiki/B"
+
  C --> G[post-process 2]
  click C "https://sandbox.semantic-mediawiki.org/wiki/C"
+
D --> G[post-process 2]
  click D "https://sandbox.semantic-mediawiki.org/wiki/D"
+
  C --> H[display]
 +
D --> H[dipslay]
 +
  B --> I[summary]
 +
E --> I[summary]
 +
F --> I[summary]
 +
  G --> I[summary]
 +
  H --> I[summary]
 
}}
 
}}
  
== example 3 - graph with tooltips and links ==
+
===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
 
; Syntax
 
<pre>
 
<pre>
{{#mermaid:graph TD;
+
{{#mermaid: config.flowchart.useMaxWidth=true | graph TD
  A-->B;
+
subgraph &nbsp;
  A-->C;
+
  A[input files] --> B[pipeline]
  B-->D;
+
  B --> C[output 1]
  C-->D;
+
  B --> D[output 2]
  click A callback "https://sandbox.semantic-mediawiki.org/wiki/A" "This is a tooltip for the link to page A."
+
C --> E[post-process 1]
  click B callback "https://sandbox.semantic-mediawiki.org/wiki/B" "This is a tooltip for the link to page B."
+
C --> F[post-process 2]
  click C callback "https://sandbox.semantic-mediawiki.org/wiki/C" "This is a tooltip for the link to page C."
+
  C --> G[post-process 2]
  click D callback "https://sandbox.semantic-mediawiki.org/wiki/D" "This is a tooltip for the link to page D."
+
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>
 
</pre>
 +
 
; Result
 
; Result
{{#mermaid:graph TD;
 
A-->B;
 
A-->C;
 
B-->D;
 
C-->D;
 
click A callback "https://sandbox.semantic-mediawiki.org/wiki/A" "This is a tooltip for the link to page A."
 
click B callback "https://sandbox.semantic-mediawiki.org/wiki/B" "This is a tooltip for the link to page B."
 
click C callback "https://sandbox.semantic-mediawiki.org/wiki/C" "This is a tooltip for the link to page C."
 
click D callback "https://sandbox.semantic-mediawiki.org/wiki/D" "This is a tooltip for the link to page D."
 
}}
 
  
== example 4 - sequence diagram ==
+
{{#mermaid: config.flowchart.useMaxWidth=true <!-- https://mermaid-js.github.io/mermaid/#/Setup --> | graph TD
; Syntax
+
%%{init: {'theme': 'base'{{<nowiki>))</nowiki>}}%%
<pre>
+
  subgraph &nbsp;
{{#mermaid:sequenceDiagram
+
   A[input files] --> B[pipeline]
  participant Alice
+
   B --> C[output 1]
participant Bob
+
   B --> D[output 2]
   Alice->John: Hello John, how are you?
+
   C --> E[post-process 1]
   loop Healthcheck
+
  C --> F[post-process 2]
  John->John: Fight against hypochondria
+
  C --> G[post-process 2]
   end
+
  D --> G[post-process 2]
   Note right of John: Rational thoughts <br/>prevail...
+
  C --> H[display]
  John-->Alice: Great!
+
   D --> H[dipslay]
  John->Bob: How about you?
+
   B --> I[summary]
  Bob-->John: Jolly good!
+
   E --> I[summary]
}}
+
   F --> I[summary]
</pre>
+
  G --> I[summary]
; Result
+
  H --> I[summary]
{{#mermaid:sequenceDiagram
+
end
participant Alice
 
participant Bob
 
   Alice->John: Hello John, how are you?
 
   loop Healthcheck
 
  John->John: Fight against hypochondria
 
   end
 
   Note right of John: Rational thoughts <br/>prevail...
 
  John-->Alice: Great!
 
  John->Bob: How about you?
 
  Bob-->John: Jolly good!
 
 
}}
 
}}
  
== example 5 - gantt chart ==
+
{{Keywords|Keywords=mermaid;graph}}
; Syntax
 
<pre>
 
{{#mermaid:gantt
 
dateFormat  YYYY-MM-DD
 
title Adding GANTT diagram functionality to mermaid
 
section A section
 
Completed task            :done,    des1, 2014-01-06,2014-01-08
 
Active task              :active,  des2, 2014-01-09, 3d
 
Future task              :        des3, after des2, 5d
 
Future task2              :        des4, after des3, 5d
 
section Critical tasks
 
Completed task in the critical line :crit, done, 2014-01-06,24h
 
Implement parser and jison          :crit, done, after des1, 2d
 
Create tests for parser            :crit, active, 3d
 
Future task in critical line        :crit, 5d
 
Create tests for renderer          :2d
 
Add to mermaid                      :1d
 
}}
 
</pre>
 
; Result
 
{{#mermaid:gantt
 
dateFormat  YYYY-MM-DD
 
title Adding GANTT diagram functionality to mermaid
 
section A section
 
Completed task            :done,    des1, 2014-01-06,2014-01-08
 
Active task              :active,  des2, 2014-01-09, 3d
 
Future task              :        des3, after des2, 5d
 
Future task2              :        des4, after des3, 5d
 
section Critical tasks
 
Completed task in the critical line :crit, done, 2014-01-06,24h
 
Implement parser and jison          :crit, done, after des1, 2d
 
Create tests for parser            :crit, active, 3d
 
Future task in critical line        :crit, 5d
 
Create tests for renderer          :2d
 
Add to mermaid                      :1d
 
}}
 
  
 
[[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.