Mermaid FlowChart如何让节点到底

How to make node go to bottom with Mermaid FlowChart

我正在用 Mermaid 绘制流程图,但它没有按照我想要的方式工作。

这是我的代码:

flowchart TD
    a0[["xml_parsing"]]
    a1{{"result = []"}}
    a2{"any elements in  collection?"}
    a3{{"container = next element"}}
    a4{{"name = text of SHORT-NAME tag of container"}}
    a5{"is name end with '_PIM'?"}
    a6{{"size = text of NvMNvBlockLength tag of container"}}
    a7{{"append [container, name, size] to result"}}
    ed([return result])

    a0-->a1-->a2-->|YES|a3-->a4-->a5-->|NO|a2
    a5-->|YES|a6-->a7-->a2-->|NO|ed

这是结果:

我想让 return result 节点到底部。

你可以告诉美人鱼特定的 link 应该有特定的 minimum length:

Each node in the flowchart is ultimately assigned to a rank in the rendered graph, i.e. to a vertical or horizontal level (depending on the flowchart orientation), based on the nodes to which it is linked. By default, links can span any number of ranks, but you can ask for any link to be longer than the others by adding extra dashes in the link definition.

在这里,我在 link 中从 a2ed 添加了四个额外的 -,因此 ed 节点与a7 节点。如果你想要它更低,只需添加另一个 -.

<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.14.0/mermaid.min.js"></script>

<div class="mermaid">
flowchart TD
    a0[["xml_parsing"]]
    a1{{"result = []"}}
    a2{"any elements in  collection?"}
    a3{{"container = next element"}}
    a4{{"name = text of SHORT-NAME tag of container"}}
    a5{"is name end with '_PIM'?"}
    a6{{"size = text of NvMNvBlockLength tag of container"}}
    a7{{"append [container, name, size] to result"}}
    ed([return result])

    a0-->a1-->a2-->|YES|a3-->a4-->a5-->|NO|a2
    a5-->|YES|a6-->a7-->a2------>|NO|ed
    %%                    ^^^^^^
</div>