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;

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

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

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

Repeat Loop

You can use repeat and repeatwhile to make repeat loops.

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

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

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

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
  1. With endmerge.
activityDiagram
  start
  fork
    :Action 1;
  forkagain
    :Action 2;
  endmerge
  end
  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

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

  @start_note left
  left multiline note,
  no colon after placement
  @end_note
  end

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

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