How to force activity diagram to squash horizontally

0 votes
asked Oct 24, 2023 in Question / help by anonymous
edited Oct 24, 2023

Hello, I am building an activity diagram to be placed inside DoxyGen documentation and it is very wide, because it places boxes that are vertically below each other also horizontally next to each other, which I think is awfull waste of space and makes the diagram unnecessarily wide. Is there any way how to force diagram stay as thin as possible?

To help you imagine what I mean, the blocks are arranged like this:

Block
Block
Block

But I'd want it to arrange them like this:

      Block      
Block
Block

Which would safe some horizontal space.

EDIT:
Example of plantuml that result in unsatisfactory diagram layout:

@startuml
title Example

|Line1|
start
|Line3| /' this is here to plot Line3 swimline before Line2'/
|Line2|
if (ondition1) then (true)
|Line3|
    :Do the first thing;
else (false) 
    |Line2|
    if (Condition2) then (true)
    |Line3|
        :Do the second thing;
    |Line1|
    else (false)
        |Line2|
        if (Condition3) then (true)
        |Line3|
            :Do the third thing;
        else (false)
        endif
        :Also do this;
        |Line1|
    endif
endif
|Line1|
:end;
stop
@enduml

commented Oct 24, 2023 by albert (3,580 points)
Can you give some plantuml example code that results in the unwanted type of diagram?
commented Oct 24, 2023 by anonymous
example added to the question

1 Answer

0 votes
answered Mar 12 by dickmaley (4,120 points)

Original diagram

image

Alternative 1

image

@startuml
title Example

start
partition Line1 {
  partition Line3 {
    /' this is here to plot Line3 swimline before Line2'/
  }
  partition Line2 {
    if (Condition1) then (true)
      partition Line3 {
        :Do the first thing;
      }
    else (false)
      if (Condition2) then (true)
        partition Line3 {
          :Do the second thing;
        }
      else (false)
        if (Condition3) then (true)
          partition Line3 {
            :Do the third thing;
          }
        endif
        :Also do this;
      endif
    endif
  }
}
:end;
stop
@enduml

Alternative 2

image

@startuml
title Example

|Line1|
start
if (Condition1) then (true)
    :Do the first thing;
else (false)
    if (Condition2) then (true)
        :Do the second thing;
    else (false)
        if (Condition3) then (true)
            :Do the third thing;
        else (false)
        endif
        :Also do this;
    endif
endif
:end;
stop
@enduml

...