Force UML output to grow vertically instead of horizontally

+1 vote
asked Feb 10, 2020 in Question / help by msawye16 (140 points)
Apologies if this is covered in the documentation but I have not been able to find anything.

PlantUML class diagrams tend to grow horizontally.

I am dealing with a large UML diagram and I would like to "encourage" the diagram to grow vertically.

Any help will be appreciated.

Thanks,

Mark
commented Feb 18, 2020 by Magnus
Hi,

I have same problem with a component diagram. Have some 50 components with some 100:s of associations. Try to structure the diagram using packages and force packages to line up vertically. Everything nice and tidy as long as I only have the packages, but the more components I add, and the more associations there is, the more horizontal distribution I get, despite only using the "double dash" notation.

Would somehow like a way to have priority for relations between structure elements, now all relations seems to be prioritized equally.

/Magnus

1 Answer

+1 vote
answered Feb 11, 2020 by Serge Wenger Work (15,620 points)

Hello,

With "-" diagram grows horizonzally. With "--" vertically. It is general in PlantUML. For example:

@startuml
class A
Class B
Class C
Class D
A <|- B
B <|-- C
C<|-- D
@enduml

You can find in the doc :https://plantuml.com/en/use-case-diagram Changing arrows direction

commented Feb 11, 2020 by msawye16 (140 points)

I've been a PlantUML user for many years and I am embarrassed to say that I did not know about the differences between single and double dashes

surprise

Thanks for the tip ...

/mbs

commented Feb 12, 2020 by Serge Wenger Work (15,620 points)
You are welcome
commented Feb 12, 2020 by albert (3,540 points)
You were not alone on the difference between "-" and "--"
commented Feb 12, 2020 by msawye16 (140 points)

A well kept secret wink

commented Aug 9 by Jörg

This may be the answer for the beginners basics but when it comes to more complex diagrams with rectangles/components/packages nested and even hackish layout optimizations like "box1 -[hidden]-> box2" plantuml will still render stuff more horizontal than vertical where a much more reasonable approach for UX is to rather grow vertically. Have you ever seen a web-page with a lot of text that you all scroll horizontally? Typically both for web and print the horizontal with is limited to a maximum and when space runs out you grow vertically.

The rendering engine for PUML seems to be based on graphviz and no normal human brain is able to understand what this engine is doing. Sometimes kind of irrelevant changes cause a nice layout to turn into useless chaos. All is a magic black box and until some degree you can gain control but above that you are lost in space.

I do not want to rant here - PUML is absolutely awesome but it is simply incorrect that it follows my spec and "->" means horizontal connection and alignment while "-->" means vertical.

Try to align this nicely and vertically as I tried to specify:

@startuml
allowmixing

rectangle All {
  rectangle Box1 {
    package pkg1 {
      package subpkg1 {
        class Class1
        class Class2
      }
      package subpkg2 {
        class Class3
      }
    }
    package pkg2 {
      package subpkg1 {
        interface Interface1
      }
      package subpkg2 {
        class Class4 implements Interface2
      }
    }
    package pkg3 {
      package subpkg1 {
        class Class5
      }
      package subpkg2 {
        interface Interface3
        class Class6
      }
      package data {
        class Class7
        interface Interface4
        class Class8
      }
    }
  }
  rectangle Box2 {
    database DB
    database S3
  }

  Box1 -[hidden]-> Box2
  pkg1 -[hidden]-> pkg2
  pkg2 -[hidden]-> pkg3
  Class4 --> Interface1
  Interface3 <|.. Class6
  Interface3 <|.. Class7
  Interface4 --> Class7
  Interface4 --> DB
  Class8 --> S3
}

@enduml
...