PlantUML State Machine control arrow direction to itself layout

1.1k views Asked by At

How do I draw an arrow out from the left side of the layout component?

When I using

@startuml
[*] --> A
A -right-> A
A -left-> A 
@enduml

enter image description here

but both arrows were drawing out from the right of the layout component A.

1

There are 1 answers

2
Fuhrmanator On

I don't think it's possible to have arrows going left or right (edit: see the forum request). They are merely hints for layout (GraphViz does the work). Some things you can try:

  • Label the transition (the arrows get spaced out):
@startuml
[*] --> A
A --> A :transition1
A --> A :transition2
A --> B : other
@enduml

enter image description here

  • If you have more than one "self" transition, put them all on the same transition.
@startuml
[*] --> A
A --> A :transition1\ntransition2
A --> B : other
@enduml

enter image description here

Finally, try to use vertical (-->) as much as possible, since the GraphViz layout avoids overlapping if you can allow vertical edges. Sometimes the resulting graphs are bigger in size, but you don't have to goof around tweaking an algorithm you can't really control.