help untangle the state diagrams

+1 vote
asked Jul 12, 2022 in Question / help by anonymous

I am creating state diagrams flow but it's starting to get cluttered as I add more states.

scale 350 width
state A               #khaki
state B           #BUSINESS
state C         #bisque
state D       #APPLICATION
state E          #IndianRed
state F   #MediumTurquoise
state G             #Salmon
state E      #HoneyDew
state G          #PaleTurquoise
state H     #Aqua

state JOIN_STATE_UNDEFINED      <<join>>
state JOIN_STATE_FAILED         <<join>>
state JOIN_STATE_STARTUP_REQ    <<join>>
state JOIN_STATE_SHUT_DOWN      <<join>>

[*] --> A
A --> B

B --> C
C -[#Red]-> JOIN_STATE_FAILED
C -[#IndianRed]-> JOIN_STATE_UNDEFINED
C --> D

C --> JOIN_STATE_SHUT_DOWN
D --> JOIN_STATE_SHUT_DOWN
F --> JOIN_STATE_SHUT_DOWN
G --> JOIN_STATE_SHUT_DOWN
H --> JOIN_STATE_SHUT_DOWN


D --> F
D --> D

D -[#Red]-> JOIN_STATE_FAILED
'D --> G : EV_MODULE_STARTUP_REQUEST fails
D -[#IndianRed]-> JOIN_STATE_UNDEFINED
'D --> E : EV_MODULE_STARTUP_REQUEST timeout

F --> G
F -[#Red]-> JOIN_STATE_FAILED
F -[#IndianRed]-> JOIN_STATE_UNDEFINED

G --> H
G -[#Red]-> JOIN_STATE_FAILED
G -[#IndianRed]-> JOIN_STATE_UNDEFINED

E -[#Crimson]-> G
E -[#FireBrick]-> E

E --> A

JOIN_STATE_UNDEFINED -[#IndianRed]-> E
JOIN_STATE_FAILED -[#Red]-> G
JOIN_STATE_SHUT_DOWN --> E

@enduml

commented Jul 12, 2022 by anonymous
HERE'S THE RESULTANT OUTPUT:

https://ibb.co/FByh6jH

1 Answer

+2 votes
answered Nov 3, 2022 by dmf19 (380 points)

I recommend using skinParam lineType ortho

It is not perfect, but better IMO.

commented Nov 3, 2022 by craftonix_aa (100 points)
I have a similar complicated state diagram, so thanks for this tip!

I'm wondering if the developers of PlantUML would consider adding an option to render state diagrams similar to how sequence diagrams are rendered, i.e. states are listed left to right, and transitions are listed top to bottom. This would avoid all the layout complications of GraphViz.
commented Nov 16, 2022 by dmf19 (380 points)
See my related comment in https://forum.plantuml.net/16938/change-state-diagram-arrowhead-color-specific-connectors.  If you make the connector labels specially formatted nodes instead, and use ortho linetype, you get a much better result.
commented Mar 19 by var23rav (100 points)
  1. arrow format
    • skinparam linetype polyline
  2. Add back ground color to the state
    • state "state_display_name"   as  identifier_name    #color_hex_code
  3. the color_hex_code should match the to_state_identifier_name    background color
  4. add label to the arrow to, use the background color same as state background color
    • from_state_identifier_name   -[#color_hex_code]->   to_state_identifier_name   : <back:#color_hex_code>to_state_display_name 

...