Class diagram vertical packages alignment

0 votes
asked Nov 24, 2021 in Question / help by Grolribasi (220 points)

Hello, I have a diagram that looks like this

I would prefer the last package to be right underneath the second one and the second one to be right underneath the first one. 

Left to right direction places the packages vertically to each other and mixes up the order of the class blocks in a package. 

How am I to force vertical alignment?

commented Nov 25, 2021 by Martin (6,780 points)

Yes, this is a pain.  For some reason Plantuml treats container shapes differently and tries to connect via the corners.  
Here's some ideas.
Making the arrows from client to server longer, will get the packages on different rows, but the horizontal alignment is screwy:


If you don't plan to link any of the inner boxes, then you can turn the container contents into sub-diagrams, so that the containers are no longer containers.  Also I had to remove your english aliases, as I don't think the package syntax supports title, alias, and description as three separate strings.


Finally you can use the Elk layout engine instead (I also tried the Smetana engine, but that didn't do the vertical layout for some reason), but it doesn't seem to support the colouring:

commented Nov 25, 2021 by Grolribasi (220 points)

Thanks for the ideas. I wasn't going to link the inner blocks so I tried to use the second diagram you proposed. It gave out an error, however :

error

commented Nov 25, 2021 by Grolribasi (220 points)

I solved the error by removing the line:

!pragma layout elk

Thanks for the solution, it is really helpful. 

commented Nov 25, 2021 by Martin (6,780 points)
Appologies for leaving that pragma in, I was trying lots of combinations.  Glad I could help.

1 Answer

+1 vote
answered Dec 7, 2021 by Martin (6,780 points)
selected Dec 9, 2021 by Grolribasi
 
Best answer

In lieu of any other answers, I present my one from the comment above.  However it is quite restrictive: because it uses stand-alone sub-diagrams, so you can't add any arrows between elements in different packages.  I've used the Elk layout engine as it bunches up the packages tighter.

commented Dec 9, 2021 by Grolribasi (220 points)
Thank you, I've accepted it.
...