2

I'm creating a diagram with different types of arrows (line, dashed, dotted, etc.). But instead of adding a label to each arrow I would like to create a legend where a replica of each arrow type is displayed alongside its meaning.

Is there a way to tell PlantUML to simply draw a small segment of a specific arrow type?

C2H5OH
  • 5,452
  • 2
  • 27
  • 39

1 Answers1

2

Is there a way to tell PlantUML to simply draw a small segment of a specific arrow type?

Generally speaking, no, especially not in a legend.

However, I can think of a way (it's somewhat complicated). A legend will let you include images, and you can use PlantUML to generate each arrow image.

Here's one example to get a regular arrow (I'm making the classes small and hiding them with some magic):

skinparam style strictuml
scale 0.5
hide empty members
skinparam Class {
    BorderColor transparent
    BackgroundColor transparent
    FontColor transparent
}
class " " as A
class " " as B
A -> B

If you render that, you get a URL of https://www.plantuml.com/plantuml/png/ROpB2i9034Nt-OhWNd7ZLkWK_8yu4tJeF4gIBahntmqAWcWk10udkJhbDfDGHRMri6_9qPPQG2Cv7mydkEV4o7Ms5IlNAuk2Vjx6Gggu0Vg4BebbxAKBcb1JF-5cRqTnkabVMlhlBxtPhtb0VFNlFAGuV6E00VTd34y0 which looks like

arrow

Next, you plug that URL into an <img:> tag in a legend of another diagram:

@startuml test
legend
    | <img:https://www.plantuml.com/plantuml/png/ROpB2i9034Nt-OhWNd7ZLkWK_8yu4tJeF4gIBahntmqAWcWk10udkJhbDfDGHRMri6_9qPPQG2Cv7mydkEV4o7Ms5IlNAuk2Vjx6Gggu0Vg4BebbxAKBcb1JF-5cRqTnkabVMlhlBxtPhtb0VFNlFAGuV6E00VTd34y0> | regular arrow |
end legend
@enduml

The result is

enter image description here

Fuhrmanator
  • 11,459
  • 6
  • 62
  • 111
  • Very interesting approach. Unfortunately, I could not get the standalone arrow with PlantUML version 1.2022.6 – C2H5OH Aug 19 '22 at 00:31
  • @C2H5OH What is the result (error message)? What platform are you on? Another way you can do it is to download the image of each arrow to your local file system (e.g., `regular_arrow.png`), and link to it locally, e.g., `` if you're having trouble getting it dynamically. – Fuhrmanator Aug 19 '22 at 00:47
  • No error message, I see empty rounded squares attached to the arrow. But you are right, I can download them from the website. In the end, I turned those into sprites instead of using the images directly, so the diagram can be self contained. Thanks a lot for the suggestion. – C2H5OH Aug 19 '22 at 17:25