How to order the subjects in PlantUML sequence diagram?
Asked Answered
K

1

9

I have a PlantUML sequence diagram where Alice exchanges messages with Cecil once and then only the communication with Bob happens. This flow causes the subjects are ordered by the time of their first interaction.

@startuml
Alice -> Cecil: hi
Cecil -> Alice: fu

Alice -> Bob: hi
Bob -> Alice : hello

Alice -> Bob: howdy?
Bob -> Alice: fine

Alice -> Bob: r u sure?
Bob -> Alice: ye
@enduml

enter image description here

It looks ugly - I want to avoid showing the interaction between Alice and Bob over Cecil.

How to assure a custom order of the subjects, i.e. Alice - Bob - Cecil?

Kiona answered 11/12, 2020 at 11:20 Comment(0)
K
17

I have found it out. Just use the keyword, participant. The order of generated participants follows the order of their definitions. Alternatively, it is possible to define the order explicitly (participant Alice order 1).

Source: UML Sequence Diagram: Participants

@startuml
participant Alice
participant Bob
participant Cecil

Alice -> Cecil: hi
Cecil -> Alice: fu
Alice -> Bob: hi
Bob -> Alice : hello
Alice -> Bob: howdy?
Bob -> Alice: fine
Alice -> Bob: r u sure?
Bob -> Alice: ye
@enduml

enter image description here

Kiona answered 11/12, 2020 at 11:27 Comment(1)
That seems to be working with sub diagram that are imported!Chela

© 2022 - 2024 — McMap. All rights reserved.