How to enhance the state placement in a state diagram

0 votes
asked Jan 16, 2019 in Question / help by PascalChap (340 points)

I am using PlantUML very often, and I have to thank you for the very useful and clean work you are doing.

I am making mostly sequence diagram, activity diagram and state diagram.

Unfortunately, for the last one (state diagram), the default placement of states and transitions gives sometimes a very poor result:

@startuml

state "State 1" as I
state "State 2" as O
state "State 3" as WS
state "State 4" as P
state "State 5" as LP
state "State 6" as S
state "State 7" as LS

[*] -> I : transition 1
I -> O : transition 2
O -> I : transition 3
O -> O : transition 4
O -> O : transition 5
O -> P : transition 6
P -> O : transition 7
O -> S : transition 8
S -> O : transition 9
P -> LP : transition 10
LP -> WS : transition 11
WS -> S : transition 12
LP -> P : transition 13
WS -> P : transition 14
S -> LS : transition 15
LS -> S : transition 16
LS -> O : transition 17
LS -> P : transition 18
S -> P : transition 19


@enduml

is rendered this way:

https://drive.google.com/file/d/1pXVISwuBLQkVCcdW9-k_Y_469Il1_qxc/view?usp=sharing

I have tried to give some "clue" to the tool, using the down, right options on some transition, but the result is still very poor:

@startuml

state "State 1" as I
state "State 2" as O
state "State 3" as WS
state "State 4" as P
state "State 5" as LP
state "State 6" as S
state "State 7" as LS

[*] -d-> I : transition 1
I -d-> O : transition 2
O -> I : transition 3
O -> O : transition 4
O -> O : transition 5
O -d-> P : transition 6
P -> O : transition 7
O -d-> S : transition 8
S -> O : transition 9
P -r-> LP : transition 10
LP -r-> WS : transition 11
WS -r-> S : transition 12
LP -> P : transition 13
WS -> P : transition 14
S -d-> LS : transition 15
LS -> S : transition 16
LS -> O : transition 17
LS -> P : transition 18
S -> P : transition 19


@enduml

https://drive.google.com/open?id=1aldTnehFcz9TK_mtkl-RulskdbKYfhwM

Is there a way to enhance the result? Up to now, I use another tool (here UMLet), but the look is very different, and the "source" storage is not consistent with my other diagrams. Here is what I would expect ideally, but another readable diagram would satisfy me as well.

https://drive.google.com/open?id=1j2Z3XY8Rsnv1TzrshOw_S_crIdJWUctv

Thanks

1 Answer

0 votes
answered Jan 16, 2019 by plantuml (295,000 points)
selected Jan 16, 2019 by PascalChap
 
Best answer

You should avoid -> arrow in state diagram, and use --> instead.

The better way is to start with --> arrow and then using few -> if you need.

The left to right directive may also help you :

@startuml
left to right direction

state "State 1" as I
state "State 2" as O
state "State 3" as WS
state "State 4" as P
state "State 5" as LP
state "State 6" as S
state "State 7" as LS

[*] --> I : transition 1
I --> O : transition 2
O --> I : transition 3
O --> O : transition 4
O --> O : transition 5
O --> P : transition 6
P --> O : transition 7
O --> S : transition 8
S --> O : transition 9
P --> LP : transition 10
LP --> WS : transition 11
WS --> S : transition 12
LP --> P : transition 13
WS --> P : transition 14
S --> LS : transition 15
LS --> S : transition 16
LS --> O : transition 17
LS --> P : transition 18
S --> P : transition 19
@enduml

 

http://www.plantuml.com/plantuml/uml/RT8_QuOm40Rm_Jx5yOw55nh_w6k7uYe48cHmA1safct0AiJhzw-DoP0Za_1xdhjpI7_GxEZtPuNLV1BIZiv-VHCkrfaFili6S3R8u4txZxZXVE2GOk5HfLXwd7IgbTSnnTgZPDfuPVFjLTK0Rq_lUB-_ue0lI6xU3ll_koXWyAnIBa3bscLWrgxoN0SUKsvWpBNRqDOfFq3dsbrO8jboyGpoIYRD4W4dPIw88exmNMMSu445bqk-gWQPlz74GB6WZG6_yO2yTz2RRJcVu1y0

...