Snippet: Adding Legends to PlantUML Diagrams

The following hack allows us to draw a diagram in a diagram in a table in a legend :D example-diagram.puml @startuml skinparam legendBackgroundColor transparent skinparam legendBorderColor transparent actor Editor as editor queue Queue as "Message\nQueue" editor -> [Component] : call [Component] --> Queue : publish legend right {{ scale 0.7 skinparam defaultFontSize 14 skinparam BackGroundColor transparent skinparam defaultBackgroundColor white !procedure $entry($type, $label, $scale=1) {{\nscale $scale \nskinparam backgroundcolor transparent\nlabel " " as A\nlabel " " as B\n $type \n}} => $label !endprocedure map "<b>Legend</b>" as legend #white { $entry(":Editor:","\nEditor for Data xyz", 0.6) $entry("[Component]","\nSome Component", 0.8) $entry("queue Queue","\nKafka-Topic", 1) $entry("A -> B","Data-Flow") } }} endlegend @enduml ...

October 21, 2022 · 1 min · 128 words · Micha Kops