How to control position of arrows and notes?

0 votes
asked Apr 26, 2023 in Question / help by BalusC (120 points)

Given

@startuml

rectangle {
  component "A" as c1
  component "B" as c2
  component "C" as c3

  c1 -r-> c2
  note top of link
    This should be on top
  endnote

  c2 -r-> c3
  note top of link
    This should be on top
  endnote

  c3 -l-> c2
  note bottom of link
    This should be on bottom
  endnote

  c2 -l-> c1
  note bottom of link
    This should be on bottom
  endnote

}

@enduml

The output is

I expected the following:

1. Arrow from A to B and B to C should be on top.

2. Note of bottom arrow should be below of it.

I noticed that when the note of the arrow from B to A is shorter than the note of the arrow from A to B, e.g. with the text "B to A" instead of "This should be on bottom", then the arrows are reversed.

But the note "B to A" is still top of the arrow. I want the arrow to be completely straight with the note bottom of it.

How exactly do I control the position of the arrows and notes the way I want?

1 Answer

0 votes
answered Apr 27, 2023 by The-Lu (65,440 points)

Hello B., and all,

If fact there is a language abuse... about note of link...

In fact:

  • note top of link
  • note bottom of link
  • ...

actually means:

  • note top of  link's label
  • note bottom of label's link's label
  • ...
See this example:

See also other example here:

Regards.

commented Apr 28, 2023 by BalusC (120 points)
Thank you.

As you understand, I merely wanted to be able to position the text associated with the link (whether it be label or note, as long as it can be styled) and to have straight links in a predefined position in this specific diagram (in order to achieve the most appealing presentation and the most smooth active reading).

Given the absence of any hint on this, may I assume that this is not at all possible in PlantUML and thus I'd probably better have to look out for a different tool to replace ~70 existing diagrams of a public resource?
commented Apr 28, 2023 by Serge Wenger Work (15,620 points)

Hello,

I think PlantUML is not exactly what you want: See FAQ: https://plantuml.com/en/faq#e216d554ed154ada

commented Apr 28, 2023 by The-Lu (65,440 points)

Hi all,

If not, we may have a possible solution.... by changing of layout...

Perhaps could you test ELK Layout, as:

@startuml
title Current ELK Layout only "top to bottom"
!pragma layout elk

rectangle {
  component "A" as c1
  component "B" as c2
  component "C" as c3

  c1 --> c2
  note right of link
    This is on right
  endnote

  c2 --> c3
  note right of link
    This is on right
  endnote

  c3 -u-> c2
  note left of link
    This is on left
  endnote

  c2 -u-> c1
  note left of link
    This is on left
  endnote

}
@enduml

See also doc. here.:

Regards.

commented May 1, 2023 by BalusC (120 points)
Thank you for the hint on the ELK layout. But unfortunately no, when you make the text of the note on the right hand side shorter than the text of the note on the left hand side, then they swap around. Moreover, this top-down composition is in this specific case worse for active reading.

I'll accept the answser that PlantUML just isn't the right tool for the task I need to do. Too bad because I really liked the idea of being able to generate visual diagrams from plain code instead of a drawing tool.
commented May 2, 2023 by The-Lu (65,440 points)

Another idea will be using: 

  • `skinparam linetype ortho`

But there are also some overlapping of note... sad

...