Как заставить узел идти вниз с блок-схемой русалки

Я рисую блок-схему с помощью 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

и это результат:

Как заставить узел идти вниз с блок-схемой русалки

Я хочу, чтобы узел «возврат результата» опускался вниз.


1
32
1

Ответ:

Решено

Вы можете сказать Mermaid, что конкретная ссылка должна иметь определенный минимальная длина:

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.

Здесь я добавил четыре дополнительных - в ссылку от a2 до ed, чтобы узел 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>