主题
布局
🌐 Layouts
此页面列出了 Mermaid 图表支持的可用布局算法。
🌐 This page lists the available layout algorithms supported in Mermaid diagrams.
支持的布局
🌐 Supported Layouts
- elk(默认):ELK(Eclipse 布局内核)。随 Mermaid 一起打包;无需设置。可以选择特定的 ELK 算法,如
elk.stress、elk.force、elk.mrtree、elk.sporeOverlap、elk.box和elk.rectpacking。 - dagre:用于分层图的Dagre布局
- cose-bilkent:用于力导向图的 Cose Bilkent 布局
- tidy-tree:用于层级图的整洁树布局,来自
@mermaid-js/layout-tidy-tree包 整洁树配置
思维导图是唯一一种默认不使用 ELK 布局的图表类型;它们使用 cose-bilkent,除非你另有选择。
🌐 Mindmaps are the one diagram type not laid out with ELK by default; they use cose-bilkent unless you ask for something else.
微小的版本省略了 ELK 以保持体积小,并在需要时退回使用 Dagre 来生成图表。
🌐 The tiny build omits ELK to stay small, and falls back to Dagre for diagrams that request it.
使用方法
🌐 How to Use
由于 elk 是默认的,图表使用它时无需进行配置。要选择不同的布局,可以在图表的 YAML 配置或初始化选项中进行设置。例如:
🌐 Since elk is the default, a diagram needs no configuration to use it. To pick a different layout, set it in your diagram's YAML config or initialization options. For example:
代码:
mermaid