Doubts with a generated diagram

0 votes
asked Mar 27, 2022 in Question / help by anonymous
edited Mar 28, 2022

I have the following diagram:
@startuml
switch (¿Tienes dinero?)
case ()
 :NO;
 if (¿Tienes trabajo?) then
  :NO;
  if (¿Tienes posesiones?) then
  :SI;
   :Vendelas;
  else
  :NO;
   while (¿Tienes un alma?)
    :NO;
    :Mientes;
   endwhile
    :SI;
    :Vendela;
  endif
 else
 :SI;
  if (¿Te pagan?) then
  :NO;
   'goto (¿Tienes posesiones?)
  else
  :SI;
  endif
 endif
case ()
 :No para objeto;
 :BLASFEMIA;
case ()
 :SI;
endswitch
:COMPRA;
@enduml

diagram generated
From which I would like to fix the following:

  1. How do I move the ¿Tienes dinero? hexagon more to the right?
  2. Is there any way to connect the arrows directly to COMPRA instead of going through the ◇ first?
  3. How do I connect the NO of ¿Te pagan? to ¿Tienes posesiones??
  4. Is it possible to control the direction of the arrows inside the ifs? I was trying with -direction-> and -[direction]-> but it doesn't work, although according to this it seems that only the colors and the style can be changed.

3 Answers

0 votes
answered Mar 27, 2022 by The-Lu (63,920 points)

Hello A.,

Only for the point (3):

  • How do I connect the NO of ¿Te pagan? to ¿Tienes posesiones??

Here is an attempt, with:

 if (¿Tienes trabajo?) then
  :NO;
  label label_dummy1;
  label label_dummy2;
  label label_tp;

and:

  if (¿Te pagan?) then
  :NO;
   goto label_tp

Here is the result:

It is currently only experimental, see `goto` topics on the forum...

If that can help,
Regards.

0 votes
answered Mar 27, 2022 by Martin (8,360 points)

Regarding point 1.  The ¿Tienes dinero? hexagon is being placed so that it is central across everything below it.  But the human eye would prefer it to be central across its outputs only.  There's no way to adjust it.  I don't know if it makes sense for your diagram, but you can make it 'look' more central by moving one of your RHS cases to the LHS.  Like this:

0 votes
answered Mar 27, 2022 by Martin (8,360 points)
edited Mar 27, 2022 by Martin

For 3, here is an alternative idea using (A) notation:

For #2, try "skinparam ConditionEndStyle hline" and see if you like it better.

commented Mar 28, 2022 by zimchaa (1,040 points)

I would also recommend adding a 'start' and an 'end' to the diagram to make it more accurate and help with the visual of the first option looking differently aligned:

Start and end

commented Apr 5, 2022 by Martin (8,360 points)
Actually it is surprising how much of an improvement adding start/end makes, good idea!
...