Can't Fix Reversed Order of Nested Rectangles with Content

0 votes
asked Jun 7, 2021 in Question / help by schabimperle
edited Jun 7, 2021

If I define two components C1/C2 they are rendered in the order of their definition:

@startuml
[C1]
[C2]
@enduml

If I define two components C1/C2 in another object like a rectangle, their order is reversed. However, I can fix this with a (hidden) link:

@startuml
rectangle {
    [C1]
    [C2]
    C1 -> C2
}
@enduml

What I can't fix is the order of two rectangles with content in another one (I want R1 before R2). The only thing thats changing when I put a link between R1 and R2 or C1 and C2 is a weird link leftwards:

@startuml
rectangle {
    rectangle R1 {
        [C1]
    }
    rectangle R2 {
        [C2]
    }
    R1 -> R2
}
@enduml

http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuIfAJIv9p4lFILMevb800WG_o10a10NHpeQnO4ujkYeZ55L6IAf09kZQ0LLmrN8vfEQb0Aq30000

How can I get R1 left of R2 without changing the order of definition?

1 Answer

0 votes
answered Jun 7, 2021 by The-Lu (67,000 points)
 
Best answer

Hello S.,

How can I get R1 left of R2 without changing the order of definition?

For that, as a workaround, you can add:

left to right direction

and change the arrow direction:

R1 --> R2

As:

@startuml
left to right direction
rectangle {
    rectangle R1 {
        [C1]
    }
    rectangle R2 {
        [C2]
    }
}
R1 --> R2
@enduml

If that can help,
Regards,
Th.

commented Jun 7, 2021 by The-Lu (67,000 points)

Or add sub-diag as:

@startuml
rectangle r [
{{
    rectangle R1 {
        [C1]
    }
    rectangle R2 {
        [C2]
    }
    R1 -> R2
}}
]
@enduml

Regards,
Th.

commented Jun 7, 2021 by schabimperle
Hi Th,

this works perfectly fine for the sample!

However it causes other problems with my actual diagram. I will probably resort to another solution. Too bad, all the trial and error with the placement of objects and edges dampens my initial enthusiasm for the textual approach of creating diagrams.

Anyway, thanks for the fast response!
...