Search code examples
plantuml

plantuml: Right to left arrows, grouped components


I have the following diagram:

@startuml
left to right direction

rectangle    Foo1
rectangle    Foo2
rectangle    Foo3

node Bar1
node Bar2
node Bar3

storage Baz1
storage Baz2
storage Baz3

Foo1 --> Bar2
Foo2 --> Bar1
Bar1 --> Baz3
Bar2 --> Baz1
@enduml

Where some components are orphaned and dont have arrows. see here It renders fine but the orphaned components are all listed at the first tier.

I want to modify it so that I would have my components arranged like this:


Foo1 -> Bar2 -> Baz1

Foo2 -> Bar1 -> Baz3

Foo3    Bar3    Baz2

update:

@albert points out that we can use invisible arrows to get the effect we want. And it works.

What if however we had something like:

@startuml
left to right direction

rectangle    Foo1
rectangle    Foo3

node Bar1
node Bar2
node Bar3

storage Baz1
storage Baz2
storage Baz3

Foo1 --> Bar2
Bar1 --> Baz3
Bar2 --> Baz1
@enduml

we'd get something like this: + I suppose we could add the following hidden arrows:

Foo1 -[#hidden]-> Bar1
Foo1 -[#hidden]-> Bar3
Bar2 -[#hidden]-> Baz2

and that would give us the desired effect or in text-form:

Foo3   Bar1  Baz3
Foo1   Bar2  Baz1
       Bar3  Baz2

Would be great if we could add invisible components FooH, BarH. ie:

FooH -[#hidden]-> Bar1
FooH -[#hidden]-> Bar3
BarH -[#hidden]-> Baz2

ie we'd use hidden arrows for invisible components which would separate them from legitimate arrows. I can't however find an easy way of marking a component as invisible.


Solution

  • I think that one of the key point here will be the [hidden] for the arrow. You would start using using something like:

    @startuml
    left to right direction
    
    rectangle    Foo1
    rectangle    Foo2
    rectangle    Foo3
    
    node Bar1
    node Bar2
    node Bar3
    
    storage Baz1
    storage Baz2
    storage Baz3
    
    Foo1 --> Bar2
    Foo2 --> Bar1
    Bar1 --> Baz3
    Bar2 --> Baz1
    Foo3 -[hidden]-> Bar3
    Bar3 -[hidden]-> Baz2
    @enduml
    

    edit

    When you want to hide a component like Foo1 you can use e.g.

    hide Foo1