Monday 16 January 2023

PlantUML: add numbers to the messages in a sequence diagram

'autonumber' keyword add numbers to the messages.

 

autoNumber.txt

@startuml

autonumber
p1 -> p2: Hi
p1 <- p2: Hello
p1 -> p2: Where are you

@enduml

 

Above snippet generates below diagram.

 

 


We can even customize the staring number of the messages using below notation.

 

autonumber startingNumber

 

specifyStartingNumber.txt

@startuml

autonumber
p1 -> p2: Hi
p1 <- p2: Hello
p1 -> p2: Where are you

autonumber 10
p1 <- p2: I am in Bangalore
p1-> p2: Shall we meet today?

@enduml

 

Above snippet generates below diagram.

 


 

We can also specify the increment while numbering the messages.

autonumber startingNumber increment

 

specifyNumberIncrement.txt

@startuml

autonumber 10 3
p1 -> p2: Hi
p1 <- p2: Hello
p1 -> p2: Where are you
p1 <- p2: I am in Bangalore
p1-> p2: Shall we meet today?

@enduml

Above snippet generates below diagram.


 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment