How can I define a legende with gradient background colors

0 votes
asked May 8, 2021 in Question / help by kirchsth (5,080 points)

How can I use the gradient background colors in legend?
As soon a gradient color is used the color is handled as text

Thank Helmut

@startuml
skinparam backgroundcolor #AntiqueWhite-Gold
skinparam classBackgroundColor #CornflowerBlue|Wheat

package example #GreenYellow/LightGoldenRodYellow {
  class Dummy
note left of Dummy #blue\9932CC
  this is my
  note on this class
end note
}


legend
|<#CornflowerBlue><color:#darkblue> single color class (only first background color can be used darkblue is text color) |  |

|<#AntiqueWhite-Gold><color:#darkblue> background |  |
|<#Wheat|CornflowerBlue><color:#darkblue> multi color class |  |
|<#blue\9932CC><color:#darkblue> note |  |
|<#GreenYellow/LightGoldenRodYellow><color:#blue> package |  |
endlegend
@enduml

commented May 9, 2021 by Martin (8,360 points)

Your question seems to be about tables not supporting gradients rather than legends - I mean if you put the same table into a rectangle, then you get the same non-support for it:

You've probably discounted it already because it doesn't fill the whole cells, but don't forget that you can use the <back> feature with [some] gradients.  It won't colour a whole cell, and it doesn't support all the gradient types, but it might work for some of your use cases:

1 Answer

+1 vote
answered May 9, 2021 by Martin (8,360 points)
selected May 10, 2021 by kirchsth
 
Best answer

I think you've asked the wrong question, but I'll answer it as posed ("How can I define a legend with gradient background colors?").
You can use a STYLE to define a gradient background for your legend:

But I think your question is really about adding gradient fill to table cells, and my only suggestion for that is to use <back> (see comment above), but the fact it doesn't fill the whole cell probably makes it not suitable for you.  Although by using monospace and right padding with spaces, you can get close:

or

commented May 9, 2021 by kirchsth (5,080 points)
Thank you for the detailed explanation
Helmut
...