PlantUML 状態遷移図のサンプル

シンプルな例

@startuml
skin rose
state A
state B

[*]--> A :開始
A->B :call B
B->A :back
B-->[*] :終了
@enduml

影(shadow)を取り除き、セルを簡易表示

@startuml
skin rose
skinparam shadowing false
hide empty description
state A
state B

[*]--> A :開始
A->B :call B
B->A :back
B-->[*] :終了
@enduml


「back」の表示を消す場合は、
B->A :back から、B->A : (全角スペース1文字)にする。

分岐(選択)がある場合、
<<choice>> で表現

@startuml
skin rose
skinparam shadowing true
hide empty description

state A
state B
state c1 <<choice>> 

A -->c1 : start
c1-->B : case1
c1-->C : case2 
B -->D : skip
B -left->C
C -->D : down
D -up->C : back
@enduml

入れ子の記述
入れ子の場合中に記述するstateを省略できる

@startuml
skin rose
skinparam shadowing true
hide empty description

state Phase1{
  A ->B : action_1
}
state Phase2{
  B-->C : action_2
  C ->D : action_3
}
@enduml

注釈をつける
1行書式
  note 方向 of 対象: 注釈
複数行書式
  note 方向 of 対象
   注釈
  end note

左右上下は、 left , right , top , bottom

@startuml 状態遷移図 note left of, note right of, note top of, note bottom of
skin rose
skinparam shadowing true
hide empty description

state A
state B

[*] -> A :開始
B -left[dashed]-> A :call A
note top of A: Aの説明

A -> B :call B
note right of B
Bの説明
bbbb
end note

B --> [*] :終了
@enduml