I am trying to make an activity diagram with PlantUML (new beta syntax).
So far I came up with (simplified):
@startuml
start
:A;
if (Q1) then (yes)
:B;
if (Q2) then (yes)
:D;
else (no)
:E;
endif
else (no)
:C;
endif
stop
@enduml
It means, do A, if yes on first question do B otherwise C. After B ask question 2, if yes do D if no do E.
Instead of pointing to E when the answer on question 2 is no I want to go to activity C, however I don't know how to reference it. If I put :C; there (instead of :E; it is just interpreted as a new activity (however it's flow should continue from C there). I assume there is a way to draw a flow like this with PlantUML but I don't see it yet.
What would be the best way to reference an already defined activity?
My current solution (been using plantUML for a week or so) is something like this:
@startuml
start
:A;
if (Q1) then (yes)
:B;
if (Q2) then (yes)
:D;
else (no)
:E;
:call C>
endif
else (no)
:call C>
endif
stop
partition C {
:do 1st C thing;
:do 2nd C thing;
}
@enduml
I moved to graphviz for this exact reason. Plantuml gives some easy syntax for some types of diagrams but for moving in multiple directions it gets challenging.
I try to use plantuml for flow diagrams but when I get close to state machines I move to graphviz. So a graphviz solution to your problem would look like the following.
Original drawing:
digraph drawing1 {
A -> B [label="yes"]
A -> C [label="no"]
B -> D [label="yes"]
B -> E [label="no"]
}
Make B goto C when no.
digraph drawing1 {
A -> B [label="yes"]
A -> C [label="no"]
B -> D [label="yes"]
B -> C [label="no"]
}
If you want to make nodes B and C line up with each other you can use the following code change.
digraph drawing1 {
A -> B [label="yes"]
A -> C [label="no"]
B -> D [label="yes"]
B -> C [label="no"]
{rank=same B C}
}
I gave up on solving similar problems to yours with plantuml.
In Windows, once you install graphviz and want to generate a png output you go to your directory with a file that contains you digraph code; let's call the file test.gv
.
Then run the following command to generate the output test.png
.
dot test.gv -Tpng -o test.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With