Skip to main content

Activity Diagram

Activity diagrams are graphical representations of workflows of stepwise activities and actions with support for choice, iteration and concurrency. Wikipedia

Introduction

The Activity Diagram is inspired by PlantUML's Activity Diagram Beta Syntax.

Simple Action

Simple action starts with : and ends with ;, with description between them.

activityDiagram
  title: Activity Diagram Simple Action
  :Action 1;
  :Action 2;
Action 1Action 2Activity Diagram Simple Action

start/end keyword

You can use start and end keyword to denote the beginning and the end of a diagram.

activityDiagram
  start
  :No pain;
  :No gain;
  end
No painNo gain

Conditional

You can use if, then and else to put tests and branches. Labels can be provided using parentheses.

  • if (...) then (...)
activityDiagram
  if (diagram registered ?) then
    :get implementation;
  else (no)
    :print error;
  endif
diagram registered ?get implementationprint erroryesno

While Loop

You can use while and endwhile to make while loops.

And it's possibleto provide a label after the endwhile keyword, or using the is keyword to provide label for the link.

activityDiagram
  start
  while (data available)
    :read data;
    :generate diagrams;
  endwhile

  while (met another test) is (yes)
    :do something;
  endwhile (done)
  end
data availableread datagenerate diagramsmet another testdo somethingyesdone

Repeat Loop

You can use repeat and repeatwhile to make repeat loops.

activityDiagram
  start
  repeat
    :read data;
    :generate diagrams;
  repeatwhile (data available ?)
  end
data available ?read datagenerate diagramsno
activityDiagram
  start
  repeat :prepare for each loop;
    :read data;
    :generate diagrams;
  repeatwhile (there is more data ?) is (alright then) not (nope)
  end
there is more data ?prepare for each loopread datagenerate diagramsalright thennope

Switch And Case

You can use switch, case and endswitch to pu switch sentences.

activityDiagram
  switch (test ?)
  case ( condition A )
    :Text 1;
  case ( condition B )
    :Text 2;
  case ( condition C )
    :Text 3;
  endswitch
test ?Text 1Text 2Text 3condition Acondition Bcondition C

Grouping

You can use several keywords to make groups:

  • group
  • partition

And it's possible to add color #\d{6} after the grouping keyword to specify background color.

activityDiagram
  start
  partition Init {
    :Read config;

    group #88bbf4 "Inner Process" {
      :Init themes;
      :Init symbols;
    }
  }
  end
InitRead configInner ProcessInit themesInit symbols

Parallel processing (fork)

You can use fork / forkagain / endfork / endmerge to denote parallel processing.

  1. Simple fork.
activityDiagram
  start
  fork
    :Action 1;
  forkagain
    :Action 2;
  forkagain
    :Action 3;
  endfork
  end
Action 1Action 1Action 2Action 2Action 3Action 3
  1. With endmerge.
activityDiagram
  start
  fork
    :Action 1;
  forkagain
    :Action 2;
  endmerge
  end
Action 1Action 1Action 2Action 2
  1. Another example of combining conditional and fork.
activityDiagram
  start
  if (multiprocessor?) then
    fork
      :Action 1;
    forkagain
      :Action 2;
    endfork
    else (monoproc)
      :Action 1;
      :Action 2;
    endif
  end
multiprocessor?Action 1Action 1Action 2Action 2Action 1Action 2yesno

Note

Add @note, placement, and participant names after action to add a note.

  1. placement keywords left and right.
  2. note can be multiline, in this case you need to add @end_note to end it.
activityDiagram
  start
  :Some action;
  @note right: note on the right

  if (diagram registered ?) then
    :get implementation;
  else (no)
    :print error;
  endif

  @note left
  left multiline note,
  no colon after placement
  @end_note
  end
Some actiondiagram registered ?get implementationprint errornote on the rightleft multiline note,no colon after placementyesno

Arrow Label

In the next line of action, you can add label to the arrow with the arrow label notation.

Currently only single line text is supported.

-> multiline description;
activityDiagram
  start
  :Action 1;
  -> Hey there;
  :Action 2;
  end
Action 1Action 2Hey there

Override config

You can override diagarm config through @param directive.

All available configs can be seen in the Config page.

activityDiagram
  @param actionBackground #61afef
  @param textColor #fff
  @param noteTextColor #purple
  @param edgeColor #143C9A
  @param edgeType curved
  @param {
    keywordBackground #143C9A
    labelTextColor #143C9A
  }
  start
  partition Init {
    :Read config;
    @note right: comment
  }
  while (data available) is (yes)
    :read data;
  endwhile
  end
InitRead configdata availableread datacommentyes