Relationship layout with nested components

0 votes
asked Jun 25, 2020 in Question / help by del-boy

Hi. 

I am trying to create a diagram with nested elements. Concretely, I am using C4 lib and want to utilise Boundary element (which is basically a rectangle, like most elements in C4 library are). Among other things, I need a relationship to the boundary, not the element inside it. This produces weird looking arrows. 

Without C4, this is example of it.

I have tried searching for similar experiences, but no luck. 

Are there any tips&tricks or config options or anything I could do to make this look more natural? Thanks. 

1 Answer

0 votes
answered Jun 25, 2020 by The-Lu (63,920 points)

Hello D.,

[You can see those similar questions:

  1. https://forum.plantuml.net/9875/arrow-is-starting-on-a-strange-side-of-file
  2. https://forum.plantuml.net/10464/component-arrows-starting-wrong-side-component-components]

Then, for a workaround, You can use embedded diagram or sub-diagram.

Pay attention to the fact: what you gain with, you also lose with (because it is an independent sub-diagram [without any link with the hosted diagram]).

See more details:

From:

rectangle rect1 {
  rectangle nested1
  rectangle nested2
}
rectangle rect2

rect1 -r-> rect2

And:


[Click to see on the PlantUML online server]

We can use sub-diagram feature:

rectangle rect1 [
== rect1
..
{{
  rectangle nested1
  rectangle nested2
}}
]
rectangle rect2

rect1 -r-> rect2

Then we obtain:


[Click to see...]

[We observe also one issue with the order of the element between the sub-diagram and the title of component (a dummy dotted line (with "..") above is necessary to achieve the expected result.): see also this defect /10967.]

If that can help,
Regards,
Th.

commented Jun 25, 2020 by del-boy
Hi.

Thank you for taking the time for answering and linking relevant questions, sorry for the duplicate (I guess I did not found right keywords for search).

This suggestions is useful for me, since I did not know about sub-diagrams (I am quite new to PlantUML). It can solve this problem in some use cases. However, I do have use cases where I need both - connection to container AND connection to element inside of container, in which case this will not work. Do you have any additional suggestion what to do in those cases, if anything?
...