State Diagram
State diagrams provide a visual representation of the various states a system or an object can be in, as well as the transitions between those states. They are essential in modeling the dynamic behavior of systems, capturing how they respond to different events over time. State diagrams depict the system's life cycle, making it easier to understand, design, and optimize its behavior. Using PlantUML to create state diagrams offers several advantages:- Text-Based Language: Quickly define and visualize the states and transitions without the hassle of manual drawing.
- Efficiency and Consistency: Ensure streamlined diagram creation and easy version control.
- Versatility: Integrate with various documentation platforms and support multiple output formats.
- Open-Source & Community Support: Backed by a strong community that continuously contributes to its enhancements and offers invaluable resources.
Simple State
You can use [*] for the starting point and ending point of
the state diagram.
Use --> for arrows.
|
🎉 Copied!
|
|
Change state rendering
You can use hide empty description to render state as simple box.
|
🎉 Copied!
|
|
Composite state
A state can also be composite. You have to define it using the state
keywords and brackets.
Internal sub-state
|
🎉 Copied!
|
|
Sub-state to sub-state
|
🎉 Copied!
|
|
[Ref. QA-3300]
|
🎉 Copied!
|
|
Long name
You can also use the state keyword to use long description
for states.
|
🎉 Copied!
|
|
History [[H], [H*]]
You can use [H] for the history and [H*] for the deep history of a substate.
|
🎉 Copied!
|
|
Fork [fork, join]
You can also fork and join using the <<fork>> and <<join>> stereotypes.
|
🎉 Copied!
|
|
Concurrent state [--, ||]
You can define concurrent state into a composite state using either --
or || symbol as separator.
Horizontal separator --
|
🎉 Copied!
|
|
Vertical separator ||
|
🎉 Copied!
|
|
[Ref. QA-3086]
Conditional [choice]
The stereotype <<choice>> can be used to use conditional state.
|
🎉 Copied!
|
|
Stereotypes full example [start, choice, fork, join, end, history, history*]
Start, choice, fork, join, end
|
🎉 Copied!
|
|
[Ref. QA-404, QA-1159 and GH-887]
History, history*
|
🎉 Copied!
|
|
[Ref. QA-16824]
Minimal example with all stereotypes
|
🎉 Copied!
|
|
[Ref. QA-19174]
Point [entryPoint, exitPoint]
You can add point with <<entryPoint>> and <<exitPoint>> stereotypes:
|
🎉 Copied!
|
|
Pin [inputPin, outputPin]
You can add pin with <<inputPin>> and <<outputPin>> stereotypes:
|
🎉 Copied!
|
|
[Ref. QA-4309]
Expansion [expansionInput, expansionOutput]
You can add expansion with <<expansionInput>> and <<expansionOutput>> stereotypes:
|
🎉 Copied!
|
|
[Ref. QA-4309]
Arrow direction
You can use -> for horizontal arrows. It is possible to
force arrow's direction using the following syntax:
-down->or-->-right->or->(default arrow)-left->-up->
|
🎉 Copied!
|
|
You can shorten the arrow definition by using only the first character of the direction (for example, -d- instead of
-down-)
or the two first characters (-do-).
Change line color and style
You can change line color and/or line style.
|
🎉 Copied!
|
|
[Ref. QA-93]
Change head or tail of arrow line
|
🎉 Copied!
|
|
Note
You can also define notes using
note left of, note right of, note top of, note bottom of
keywords.
You can also define notes on several lines.
|
🎉 Copied!
|
|
You can also add note on start or end state:
|
🎉 Copied!
|
|
[Ref. QA-20400]
You can also have floating notes.
|
🎉 Copied!
|
|
Note on link
You can put notes on state-transition or link, with note on link keyword.
|
🎉 Copied!
|
|
More in notes
You can put notes on composite states.
|
🎉 Copied!
|
|
Inline color
|
🎉 Copied!
|
|
[Ref. QA-1812]
Skinparam
You can use the skinparam command to change colors and fonts for the drawing.
You can use this command :
- In the diagram definition, like any other commands,
- In an included file,
- In a configuration file, provided in the command line or the Ant task.
|
🎉 Copied!
|
|
Test of all specific skinparam to State Diagrams
|
🎉 Copied!
|
|
Changing style
You can change style.
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
[Ref. GH-880]
Change state color and style (inline style)
You can change the color or style of individual state using the following notation:
#color ##[style]color
#color), then line style and line color (##[style]color ).
|
🎉 Copied!
|
|
[Ref. QA-1487]
#color;line:color;line.[bold|dashed|dotted];text:color
FIXME
🚩
text:color seems not to be taken into account
FIXME
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
[Adapted from QA-3770]
Alias
With State you can use alias, like:
|
🎉 Copied!
|
|
or:
|
🎉 Copied!
|
|
[Ref. QA-1748, QA-14560]
Display JSON Data on State diagram
Simple example
|
🎉 Copied!
|
|
[Ref. QA-17275] For another example, see on JSON page.
State description
You can add description to a state or to a composite state.
|
🎉 Copied!
|
|
[Ref. QA-16719]
Style for Nested State Body
|
🎉 Copied!
|
|
[Ref. QA-16774]