Trouble with layout in component diagram

0 votes
asked Aug 8 in Question / help by Allen

I'm just starting with plantuml and having trouble getting the layout the way I want.  With the below file, I want box1 to appear above box2 and within box2, have c1-4 in a stacked column and c5-7 in another stacked column to the right of it. 

It would also be great if box1 was as wide as box2 and just had c8 pushed to the right side. Is it possible to do something like that?

@startuml
scale 2
rectangle "outer" #white {

  rectangle "Box1" #e0cca6 {
    rectangle "Component 8" as c8 #blue
  }

  rectangle "Box2" #e0cca6 {
    rectangle "Component 1" as c1 #blue
    rectangle "Component 2" as c2 #blue
    rectangle "Component 3" as c3 #blue
    rectangle "Component 4" as c4 #blue
    rectangle "Component 5" as c5 #blue
    rectangle "Component 6" as c6 #blue
    rectangle "Component 7" as c7 #blue
  }
}

c7 -- c1
c7 -- c2
c7 -- c3
c7 -- c4
c7 -- c5
c7 -- c6

c7 .. c8
@enduml

1 Answer

0 votes
answered Aug 9 by The-Lu (70,400 points)
 
Best answer

Hello A.,

From:

Here is a proposal adding hidden arrows:

@startuml
left to right direction
scale 1
rectangle "outer" #white {
  rectangle "Box2" #e0cca6 {
    rectangle "Component 1" as c1 #blue
    rectangle "Component 2" as c2 #blue
    rectangle "Component 3" as c3 #blue
    rectangle "Component 4" as c4 #blue
    rectangle "Component 5" as c5 #blue
    rectangle "Component 6" as c6 #blue
    rectangle "Component 7" as c7 #blue
  }
  
  rectangle "Box1" #e0cca6 {
    rectangle "Component 8" as c8 #blue
  }
}

c1 -- c7
c2 -- c7
c3 -- c7
c4 -- c7
c5 -- c7
c6 -- c7

c8 .. c7

c1 -l[hidden]- c2
c2 -l[hidden]- c3
c3 -l[hidden]- c4

c5 -l[hidden]- c6

c1 -[hidden]- c5
c2 -[hidden]- c6

@enduml

This not so perfect but Enjoy,
Regards,
Th.

commented Aug 9 by The-Lu (70,400 points)

And for the second point:

It would also be great if box1 was as wide as box2 and just had c8 pushed to the right side.

Here is a proposal with hidden rectangle, as:

@startuml
left to right direction
scale 1
rectangle "outer" #white {
  rectangle "Box2" #e0cca6 {
    rectangle "Component 1" as c1 #blue
    rectangle "Component 2" as c2 #blue
    rectangle "Component 3" as c3 #blue
    rectangle "Component 4" as c4 #blue
    rectangle "Component 5" as c5 #blue
    rectangle "Component 6" as c6 #blue
    rectangle "Component 7" as c7 #blue
  }
  
  rectangle "Box1" #e0cca6 {
    rectangle "Component a" as a $a
    rectangle "Component b" as b $b
    rectangle "Component 8" as c8 #blue
  }
}

c1 -- c7
c2 -- c7
c3 -- c7
c4 -- c7
c5 -- c7
c6 -- c7

c8 .r. c7

c1 -l[hidden]- c2
c2 -l[hidden]- c3
c3 -l[hidden]- c4

c5 -l[hidden]- c6

c1 -[hidden]- c5
c2 -[hidden]- c6

a -- b
b -- c8

hide $a
hide $b
@enduml

Regards,
Th.

commented Aug 9 by Allen
That's perfect, thanks!
...