4

A class diagram seems to always be linear - either in horizontal or, if I add left to right direction, vertical.

Horizontal Diagram

However, in many cases the layout could do a better use of the screen space. Check this one out:

Star Diagram

This last diagram could easily have A as a center in the middle of the screen and then have all other classes around it.

I know that PlantUML uses Graphviz behind the curtains to do the layout, which supports a variety of styles. So, can I tell PlantUML to do something smarter when it comes to class diagrams?

Bruno Brant
  • 8,226
  • 7
  • 45
  • 90

2 Answers2

3

Do you mean something like centered A class

produced by

B -l-* A
C -l-* A
A *-r- D
A *-r- E

I defined the classes in ascending order A, B, ..E. Check out the Layout Section of the new Hitchhiker's Guide for details. Or the Section Changing arrows direction in the class diagram page of plantuml.com.

(Tested in Linux Mint 20 Ulyana, Emacs 26.3, org mode 9.3.1, PlantUml 1.2018.13 src block, graphviz 2.43.0)

pjs
  • 121
  • 1
  • 4
0

Looking at the code of your second example, we see it has horizontal associations, e.g., A *- B. If you always use vertical associations, e.g. A *-- B, GraphViz does always does a better job:

A *-- B
A *-- C
A *-- D
A *-- E
A *-- F
A *-- G
A *-- H
A *-- I
A *-- J

enter image description here

Fuhrmanator
  • 11,459
  • 6
  • 62
  • 111