Legend: named background color requires #

0 votes
asked Dec 30, 2020 in Question / help by kirchsth (600 points)

Hello PlantUML team, after some tests I observed this issue:

If I define a color with e.g. "#hexCodes" then I can use it in legendes without any problems.
If I define a color via its name then I cannot used it as background color without an additional #.
Is this intended?

@startuml
legend right
|= **Legend** |
|<#FFFFFF><color:DarkGreen> person </color> |
|<#DarkGreen><color:White> named color with additional # works </color> |
|<DarkGreen><color:White> named color not working </color> |
endlegend
@enduml

Based on that problem I have to define the background color twice (depending on the context) and I have to know the correct hex codes too.

Thank you for your support, best regards
Helmut

1 Answer

0 votes
answered Dec 30, 2020 by plantuml (241,480 points)

If I define a color with e.g. "#hexCodes" then I can use it in legendes without any problems.
If I define a color via its name then I cannot used it as background color without an additional #.
Is this intended?

Yes, this is intended. I agree that this not very consistent. If it confused you, you could use a # in every case.

Based on that problem I have to define the background color twice (depending on the context)

Here, I am confused. Why do you have to define the background color twice ?

and I have to know the correct hex codes too.

And why do you have to know the correct hex code ?

I think you should give us an example so that we fully understand the issue.

Thanks !

commented Dec 30, 2020 by kirchsth (600 points)

Thank you, I didn't know that named colors can start with "#" too. This solves my problem.

Best regards
Helmut

PS.: My original problem was that I have global color definitions and want to use them on all places, like

!$PERSON_BG_COLOR = "#004400"
!$SYSTEM_BG_COLOR = "DarkGreen"

and only $PERSON_BG_COLOR could be used as legend background (starts with #) and $SYSTEM_BG_COLOR not (and therefore I thought I need hex coded values)

...