Search code examples
plantuml

Is there a way to have a single column of elements inside a PlantUML component diagram?


I'm trying to vertical align, on a single column, elements of a PlantUML component diagram. I tried with both "top o bottom direction" and "left to right direction" options, but with no good result. Only way I found is to wrap every element inside an anonymous "frame" and to set the "left to right direction" option. Is there a way to avoid this?

As a related question, is there a documentation that explain how elements are aligned to the final view, and how "top to bottom" and "left to right" are supposed to work?

Many thanks!


Solution

  • You can vertically align all components with no dependency, by switching to the left to right direction and using the down indicator.

    @startuml
    left to right direction
    [a] -down-> [b]
    [c] -down-> [d]
    [e] -down-> [f]
    @enduml
    

    vertically aligned components

    In addition to that, you can further enforce object positions by using [hidden] arrows. See "Help on layout" in the class diagram documentation.

    @startuml
    [x] -[hidden]down- [down]
    [x] -[hidden]up- [up] 
    [x] -[hidden]left- [left]
    [x] -[hidden]right- [right]
    @enduml
    

    position in component diagram

    I don't think there is more documentation other what you can find in the official docs, the forum and the source code. PlantUML is limited in its styling and positioning capabilities.

    If you need something management-ready, maybe consider exporting a graph as SVG and edit it using a tool which can edit vector graphics. (i.e. Inkscape, Microsoft Visio, ...)