Activity diagram
An activity diagram describes a workflow or process: the steps, the order they happen in, and the decisions and parallel paths along the way. It's well suited to business processes, algorithms, and anything that flows from a start to an end. In PlantUML, you write each activity on its own line, using arrows and keywords likeif, repeat, and fork to express control flow. The diagram is generated for you.
- Text in, diagram out. Describe the flow top to bottom, branches and loops included.
- Reads top to bottom. The order in your text is the order in your diagram.
- Easy to restructure. Reordering steps or adding a branch is a text edit, not a redraw.
Simple action
Activities label starts with : and ends with ;.
Text formatting can be done using creole wiki syntax.
They are implicitly linked in their definition order.
|
🎉 Copied!
|
|
Other simple action (defined as a list)
Simple action list separated by -
|
🎉 Copied!
|
|
Simple action list separated by *
With one level
|
🎉 Copied!
|
|
With several levels
|
🎉 Copied!
|
|
[Ref. GH-2376]
Start/Stop/End
You can use start and stop keywords to denote the
beginning and the end of a diagram.
|
🎉 Copied!
|
|
You can also use the
end keyword.
|
🎉 Copied!
|
|
Conditional [if, then, else, endif]
You can use if, then, else and endif keywords to put tests in your diagram.
Labels can be provided using parentheses.
The 3 syntaxes are possible:
if (...) then (...) ... [else (...) ...] endif
|
🎉 Copied!
|
|
if (...) is (...) then ... [else (...) ...] endif
|
🎉 Copied!
|
|
if (...) equals (...) then ... [else (...) ...] endif
|
🎉 Copied!
|
|
[Ref. QA-301]
Several tests (horizontal mode)
You can use theelseif keyword to have several tests (by default, it is the horizontal mode):
|
🎉 Copied!
|
|
Several tests (vertical mode)
You can use the command!pragma useVerticalIf on to have the tests in vertical mode:
|
🎉 Copied!
|
|
You can use the
-P command-line option to specify the pragma:
java -jar plantuml.jar -PuseVerticalIf=on
[Refs. QA-3931, GH-582]
Switch and case [switch, case, endswitch]
You can use switch, case and endswitch keywords to put switch in your diagram.
Labels can be provided using parentheses.
|
🎉 Copied!
|
|
Conditional with stop on an action [kill, detach]
You can stop action on a if loop.
|
🎉 Copied!
|
|
But if you want to stop at the precise action, you can use the
kill or detach keyword:
kill
|
🎉 Copied!
|
|
[Ref. QA-265]
detach
|
🎉 Copied!
|
|
Repeat loop
Simple repeat loop
You can userepeat and repeat while keywords to have repeat loops.
|
🎉 Copied!
|
|
Repeat loop with repeat action and backward action
It is also possible to use a full action asrepeat target and insert an action in the return path using the backward keyword.
|
🎉 Copied!
|
|
[Ref. QA-5826]
Break on a repeat loop [break]
You can use the break keyword after an action on a loop.
|
🎉 Copied!
|
|
[Ref. QA-6105]
Goto and Label Processing [label, goto]
⚠ It is currently only experimental 🚧
You can use label and goto keywords to denote goto processing, with:
label <label_name>goto <label_name>
|
🎉 Copied!
|
|
[Ref. QA-15026, QA-12526 and initially QA-1626]
While loop
Simple while loop
You can usewhile and endwhile keywords to have while loop.
|
🎉 Copied!
|
|
It is possible to provide a label after the
endwhile keyword, or using the is keyword.
|
🎉 Copied!
|
|
While loop with backward action
It is also possible to insert an action in the return path using thebackward keyword.
|
🎉 Copied!
|
|
[Ref. QA-11144]
Infinite while loop
If you are usingdetach to form an infinite while loop, then you will want to also hide the partial arrow that results using -[hidden]->
|
🎉 Copied!
|
|
Parallel processing [fork, fork again, end fork, end merge]
You can use fork, fork again and end fork or end merge keywords to denote parallel processing.
Simple fork
|
🎉 Copied!
|
|
fork with end merge
|
🎉 Copied!
|
|
[Ref. QA-5320]
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
[Ref. QA-13731]
Label on end fork (or UML joinspec):
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
[Ref. QA-5346]
Other example
|
🎉 Copied!
|
|
Split processing
Split
You can usesplit, split again and end split keywords to denote split processing.
|
🎉 Copied!
|
|
Input split (multi-start)
You can usehidden arrows to make an input split (multi-start):
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
[Ref. QA-8662]
Output split (multi-end)
You can usekill or detach to make an output split (multi-end):
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
Notes
Text formatting can be done using creole wiki syntax.
A note can be floating, using floating keyword.
|
🎉 Copied!
|
|
You can add note on backward activity:
|
🎉 Copied!
|
|
[Ref. QA-11788] You can add note on partition activity:
|
🎉 Copied!
|
|
[Ref. QA-2398]
Colors
You can specify a color for some activities.
|
🎉 Copied!
|
|
You can also use gradient color.
|
🎉 Copied!
|
|
[Ref. QA-4906]
Lines without arrows
You can use skinparam ArrowHeadColor none in order to connect activities using lines only, without arrows.
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
Arrows
Using the -> notation, you can add texts to arrow, and change
their color.
It's also possible to have dotted, dashed, bold or hidden arrows.
|
🎉 Copied!
|
|
Simple colored arrow [link]
You can use simple colored arrow with the link keyword.
|
🎉 Copied!
|
|
Multiple colored arrow
You can use multiple colored arrow.
|
🎉 Copied!
|
|
[Ref. QA-4411]
Connector (or Circle)
You can use parentheses to denote connector.
|
🎉 Copied!
|
|
Color on connector
You can add color on connector.
|
🎉 Copied!
|
|
[Ref. QA-10077] And even use style on Circle:
|
🎉 Copied!
|
|
[Ref. QA-19975]
Grouping or partition
Group
You can group activity together by defining group:
|
🎉 Copied!
|
|
Partition
You can group activity together by defining partition:
|
🎉 Copied!
|
|
It's also possible to change partition color:
|
🎉 Copied!
|
|
[Ref. QA-2793] It's also possible to add link to partition:
|
🎉 Copied!
|
|
[Ref. QA-542]
Group, Partition, Package, Rectangle or Card
You can group activity together by defining:- group;
- partition;
- package;
- rectangle;
- card.
|
🎉 Copied!
|
|
Swimlanes
Using pipe |, you can define swimlanes.
It's also possible to change swimlanes color.
|
🎉 Copied!
|
|
You can add
if conditional or repeat or while loop within swimlanes.
|
🎉 Copied!
|
|
You can also use
alias with swimlanes, with this syntax:
|[#<color>|]<swimlane_alias>| <swimlane_title>
|
🎉 Copied!
|
|
[Ref. QA-2681]
Detach or kill [detach, kill]
It's possible to remove an arrow using the detach or kill keyword:
detach
|
🎉 Copied!
|
|
kill
|
🎉 Copied!
|
|
Emoji as action (with icon stereotype)
You can use emoji as action, with the stereotype <<icon>>:
|
🎉 Copied!
|
|
[Ref. GH-2436]
SDL (Specification and Description Language) (with SDL sterotype)
Table of SDL Shape Name
| Name | Stereotype syntax | Deprecated syntax |
| Input |
<<input>>
|
<
|
| Output |
<<output>>
|
>
|
| Procedure |
<<procedure>>
|
|
|
| Load |
<<load>>
|
\
|
| Save |
<<save>>
|
/
|
| Continuous |
<<continuous>>
|
}
|
| Task |
<<task>>
|
]
|
SDL using stereotype (Current official form)
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
UML (Unified Modeling Language) Shape (with UML stereotype)
Table of UML Shape Name
| Name | Stereotype syntax |
| ObjectNode |
<<object>>
|
|
ObjectNode typed by signal |
<<objectSignal>> or <<object-signal>>
|
|
AcceptEventAction without TimeEvent trigger |
<<acceptEvent>> or <<accept-event>>
|
|
AcceptEventAction with TimeEvent trigger |
<<timeEvent>> or <<time-event>>
|
|
SendSignalAction SendObjectAction with signal type |
<<sendSignal>> or <<send-signal>>
|
| Trigger |
<<trigger>>
|
UML Shape Example using Stereotype
|
🎉 Copied!
|
|
[Ref. GH-2185, QA-16558, GH-1659]
Complete example
|
🎉 Copied!
|
|
Condition Style
Inside style (by default)
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
Diamond style
|
🎉 Copied!
|
|
InsideDiamond (or Foo1) style
|
🎉 Copied!
|
|
|
🎉 Copied!
|
|
[Ref. QA-1290 and #400]
Condition End Style
Diamond style (by default)
- With one branch
|
🎉 Copied!
|
|
- With two branches (
B1,B2)
|
🎉 Copied!
|
|
Horizontal line (hline) style
- With one branch
|
🎉 Copied!
|
|
- With two branches (
B1,B2)
|
🎉 Copied!
|
|
[Ref. QA-4015]
Using (global) style
Without style (by default)
|
🎉 Copied!
|
|
With style
You can use style to change rendering of elements.
|
🎉 Copied!
|
|
Creole on Activity
You can use Creole or HTML Creole on Activity diagram:
|
🎉 Copied!
|
|