Declaring element or participant
You declare participant using the following keywords, depending on how you want them to be drawn.
Keyword | Description |
---|---|
|
An |
|
A |
|
A |
|
A simplified |
|
A |
You define state change using the @
notation, and the is
verb.
@startuml
robust "Web Browser" as WB
concise "Web User" as WU
@0
WU is Idle
WB is Idle
@100
WU is Waiting
WB is Processing
@300
WB is Waiting
@enduml
@startuml
clock "Clock_0" as C0 with period 50
clock "Clock_1" as C1 with period 50 pulse 15 offset 10
binary "Binary" as B
concise "Concise" as C
robust "Robust" as R
analog "Analog" as A
@0
C is Idle
R is Idle
A is 0
@100
B is high
C is Waiting
R is Processing
A is 3
@300
R is Waiting
A is 1
@enduml
Anchor Points
Instead of using absolute or relative time on an absolute time you can define a time as an anchor point by using the as
keyword and starting the name with a :
.
@XX as :<anchor point name>
Setting scale
You can also set a specific scale.
When using absolute Times/Dates, 1 "tick" is equivalent to 1 second.
Hidden state
It is also possible to hide some state.
@startuml
concise "Web User" as WU
@0
WU is {-}
@100
WU is A1
@200
WU is {-}
@300
WU is {hidden}
@400
WU is A3
@500
WU is {-}
@enduml
@startuml
scale 1 as 50 pixels
concise state0
concise substate1
robust bit2
bit2 has HIGH,LOW
@state0
0 is 18_start
6 is s_dPause
8 is 10_data
14 is {hidden}
@substate1
0 is sSeq
4 is sPause
6 is {hidden}
8 is dSeq
12 is dPause
14 is {hidden}
@bit2
0 is HIGH
2 is LOW
4 is {hidden}
8 is HIGH
10 is LOW
12 is {hidden}
@enduml
[Ref. QA-12222]
Using Time and Date
Highlighted period
You can higlight a part of diagram.
@startuml
robust "Web Browser" as WB
concise "Web User" as WU
@0
WU is Idle
WB is Idle
@100
WU -> WB : URL
WU is Waiting #LightCyan;line:Aqua
@200
WB is Proc.
@300
WU -> WB@350 : URL2
WB is Waiting
@+200
WU is ok
@+200
WB is Idle
highlight 200 to 450 #Gold;line:DimGrey : This is my caption
highlight 600 to 700 : This is another\nhighlight
@enduml
[Ref. QA-10868]
Using notes
You can use the note top of
and note bottom of
keywords to define notes related to a single object or participant (available only for concise
object).
@startuml
robust "Web Browser" as WB
concise "Web User" as WU
@0
WU is Idle
WB is Idle
@100
WU is Waiting
WB is Processing
note top of WU : first note\non several\nlines
note bottom of WU : second note\non several\nlines
@300
WB is Waiting
@enduml
[Ref. QA-6877]
Complete example
Thanks to Adam Rosien for this example.
@startuml
concise "Client" as Client
concise "Server" as Server
concise "Response freshness" as Cache
Server is idle
Client is idle
@Client
0 is send
Client -> Server@+25 : GET
+25 is await
+75 is recv
+25 is idle
+25 is send
Client -> Server@+25 : GET\nIf-Modified-Since: 150
+25 is await
+50 is recv
+25 is idle
@100 <-> @275 : no need to re-request from server
@Server
25 is recv
+25 is work
+25 is send
Server -> Client@+25 : 200 OK\nExpires: 275
+25 is idle
+75 is recv
+25 is send
Server -> Client@+25 : 304 Not Modified
+25 is idle
@Cache
75 is fresh
+200 is stale
@enduml
Digital Example
@startuml
scale 5 as 150 pixels
clock clk with period 1
binary "enable" as en
binary "R/W" as rw
binary "data Valid" as dv
concise "dataBus" as db
concise "address bus" as addr
@6 as :write_beg
@10 as :write_end
@15 as :read_beg
@19 as :read_end
@0
en is low
db is "0x0"
addr is "0x03f"
rw is low
dv is 0
@:write_beg-3
en is high
@:write_beg-2
db is "0xDEADBEEF"
@:write_beg-1
dv is 1
@:write_beg
rw is high
@:write_end
rw is low
dv is low
@:write_end+1
rw is low
db is "0x0"
addr is "0x23"
@12
dv is high
@13
db is "0xFFFF"
@20
en is low
dv is low
@21
db is "0x0"
highlight :write_beg to :write_end #Gold:Write
highlight :read_beg to :read_end #lightBlue:Read
db@:write_beg-1 <-> @:write_end : setup time
db@:write_beg-1 -> addr@:write_end+1 : hold
@enduml
Adding color
You can add link::color[color].
@startuml
concise "LR" as LR
concise "ST" as ST
LR is AtPlace #palegreen
ST is AtLoad #gray
@LR
0 is Lowering
100 is Lowered #pink
350 is Releasing
@ST
200 is Moving
@enduml
[Ref. QA-5776]
Using (global) style
With style
You can use link::style-evolution[style] to change rendering of elements.
@startuml
robust "Web Browser" as WB
concise "Web User" as WU
WB is Initializing
WU is Absent
@WB
0 is idle
+200 is Processing
+100 is Waiting
WB@0 <-> @50 : {50 ms lag}
@WU
0 is Waiting
+500 is ok
@200 <-> @+150 : {150 ms}
@enduml
[Ref. QA-14340]
Applying Colors to specific lines
You can use the <style>
tags and sterotyping to give a name to line attributes.
Compact mode
You can use compact
command to compact the timing layout.
By default
Local mode with only compact
on element
@startuml
compact robust "Web Browser" as WB
compact concise "Web User" as WU
robust "Web Browser2" as WB2
@0
WU is Waiting
WB is Idle
WB2 is Idle
@200
WB is Proc.
@300
WB is Waiting
WB2 is Waiting
@500
WU is ok
@700
WB is Idle
@enduml
[Ref. QA-11130]