Help:Diagrams: Difference between revisions
Document composing one diagram from several pages, with a worked example and the rules (esp. unique node ids) |
Categorisation per 2026-09 category review |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 46: | Line 46: | ||
The older form <code><nowiki>{{#display_diagram:Mermaid:Meter capture chain}}</nowiki></code> still works and renders identically. Prefer the template: <code>#display_diagram</code> is a parser function, and the visual editor can edit a template's parameters but not a parser function's target, so bare calls can only be changed by editing the page source. | The older form <code><nowiki>{{#display_diagram:Mermaid:Meter capture chain}}</nowiki></code> still works and renders identically. Prefer the template: <code>#display_diagram</code> is a parser function, and the visual editor can edit a template's parameters but not a parser function's target, so bare calls can only be changed by editing the page source. | ||
'''Highlighting one node for one page:''' Mermaid diagrams take an optional <code>style</code> parameter that restyles part of the diagram on that page only — see [[#Highlighting part of a diagram on one page|Highlighting part of a diagram on one page]]. | |||
'''One limit to know about:''' a single page can contain '''at most one BPMN or Gantt''' diagram — the extension gives both of them the same internal element name, so a second one on the same page is refused with an error message. Mermaid, DOT and Drawio can be embedded as many times as you like. | '''One limit to know about:''' a single page can contain '''at most one BPMN or Gantt''' diagram — the extension gives both of them the same internal element name, so a second one on the same page is refused with an error message. Mermaid, DOT and Drawio can be embedded as many times as you like. | ||
| Line 174: | Line 176: | ||
so makes that diagram ignore the site-wide theme '''completely''', including any later change | so makes that diagram ignore the site-wide theme '''completely''', including any later change | ||
to it — so prefer leaving it alone unless one diagram genuinely needs to differ. | to it — so prefer leaving it alone unless one diagram genuinely needs to differ. | ||
=== Highlighting part of a diagram on one page === | |||
An article sometimes needs to point at '''one step''' of a shared diagram without changing the diagram itself. Add a <code>style</code> parameter to [[Template:Diagram]]: its contents are added to the end of the diagram '''for this embed only'''. The diagram page, and every other page that shows it, stay exactly as they are. | |||
<pre> | |||
{{Diagram|page=Mermaid:RE Microscope Workflow|style=style MW_Memory_File stroke-width:8px}} | |||
</pre> | |||
{{Diagram|page=Mermaid:RE Microscope Workflow|style=style MW_Memory_File stroke-width:8px}} | |||
Compare it with the unmodified [[Mermaid:RE Microscope Workflow]]: only the ''IC Data'' circle has changed. In the visual editor, the same thing is the '''Extra style (Mermaid only)''' field of the template. | |||
* '''Use the node's id, not its label.''' Above, the id is <code>MW_Memory_File</code>; its label is ''IC Data''. Open the diagram page to find the ids. | |||
* '''Several statements go on one line, separated by <code>;</code>''', e.g. <code>style=style MW_Memory_File stroke-width:8px; style MW_Sample-Preparation fill:#ffd</code> | |||
* Any Mermaid flowchart statement works, not only <code>style</code> — e.g. <code>classDef hot fill:#ffd; class MW_Memory_File,MW_Sample-Preparation hot</code> to highlight several nodes the same way. | |||
* '''A misspelled id is not reported.''' Mermaid does not complain — it draws an extra, empty node with that name. If a stray box appears, check the spelling. | |||
* '''Mermaid only.''' On a DOT, Drawio, BPMN or Gantt page the parameter shows an error instead of the diagram. | |||
* Editing the diagram page still updates this embed by itself, with no purge. | |||
=== Building one diagram from several pages === | === Building one diagram from several pages === | ||
| Line 223: | Line 244: | ||
A worked example with five parts is at [[User:Hash/Sandbox]]. | A worked example with five parts is at [[User:Hash/Sandbox]]. | ||
==== Choosing how deep to draw ==== | |||
Add <code>level</code> to draw every part at a given depth, or <code>level''N''</code> to set part ''N'' on its own (it overrides <code>level</code>): | |||
{| class="wikitable" | |||
! Level !! What each part shows | |||
|- | |||
| <code>1</code> || One block with the part's title | |||
|- | |||
| <code>2</code> || The part's own nodes; any subgraphs inside it are drawn as titled blocks | |||
|- | |||
| <code>3</code>, <code>4</code>, … || One more layer of subgraphs opened at each step | |||
|} | |||
<pre> | |||
<composediagram direction="TD" level="1" level5="3" ...> | |||
</pre> | |||
With no level at all, every part is drawn in full, exactly as before. Setting a part to <code>all</code> (e.g. <code>level5="all"</code>) also means full depth, which is useful when <code>level</code> sets a lower default. | |||
* '''Empty subgraphs are placeholders''' — <code>subgraph FW_Advanced [Advanced Techniques]; end</code> — and simply stay blocks at any level until someone fills them in. No error. | |||
* '''Edges into hidden nodes are redrawn to the block''' that now stands for them, keeping their labels, so the overview's edges can point at nodes deep inside a part and still make sense when that part is collapsed. | |||
* Contents must be written '''inline''' in the part page; a subgraph cannot pull in another page. | |||
Examples of each are at [[User:Hash/Sandbox#Depth levels]]. | |||
==== What you need to get right ==== | ==== What you need to get right ==== | ||
| Line 337: | Line 384: | ||
* [[Help:Uploading files]] — for photographs, scans and CAD files | * [[Help:Uploading files]] — for photographs, scans and CAD files | ||
* [https://www.mediawiki.org/wiki/Extension:Flex_Diagrams Extension:Flex Diagrams] — the extension providing this | * [https://www.mediawiki.org/wiki/Extension:Flex_Diagrams Extension:Flex Diagrams] — the extension providing this | ||
[[Category:Help]] | |||