overlapping arrows when components are in rectangles

+1 vote
asked Aug 6 in Question / help by chrikoch (140 points)

I created a minimal example to visualize my problem:

With this code everything works as expected:

@startuml

component A
component B

A -> B: request
B -> A: response

@enduml


But when I put A and B in rectangles, the arrows for request and response overlap so they can't be read anymore:

@startuml

rectangle "1" {
  component A
}
rectangle "2" {
  component B
}

A -> B: request
B -> A: response

@enduml

Any ideas how to fix this?

2 Answers

0 votes
answered Aug 6 by The-Lu (69,220 points)
selected Aug 6 by chrikoch
 
Best answer

Hello C.,

From:

@startuml
component A
component B
A -> B: request
B -> A: response
@enduml

and:

@startuml

rectangle "1" {
  component A
}
rectangle "2" {
  component B
}

A -> B: request
B -> A: response

@enduml

It seems there are some issues on plantuml side with those examples...sad

Then here is a workaround changing arrow direction, as:

@startuml

rectangle "1" {
  component A
}
rectangle "2" {
  component B
}

A -> B: request
A <- B: response

@enduml

Enjoy,
Th.

commented Aug 6 by chrikoch (140 points)
Great, that works! Is there any chance this will be fixed? Actually, my puml files are autogenerated and I can't adjust them easily.
0 votes
answered Aug 6 by xiaoqi (380 points)

Or you can use Port to make this in tricky way:

@startuml

left to right direction

rectangle "1" {

  component A {

    portOut a1

    portOut a2

  }

}

rectangle "2" {

  component B {

    portIn b1

    portIn b2

  }

}

a1 --> b1: request

b2 --> a2: response

@enduml
...