I want to color classes in my class diagram, based on a certain criteria, and then display a legend, that would look roughly like:
If I could add an HTML table within PlantUML's legend
and endlegend
, I could achieve this by changing the cell backgrounds. However, adding the HTML <table>
doesn't work. I also tried using PlantUML's salt
to insert a table, but I couldn't find any way to color the cells of the table.
Is there any way to achieve this?
This is not perfect, but you can use a creole table. (see http://plantuml.sourceforge.net/creole.html )
There are some drawing artifacts, but is it what you are expecting ?
From the plantuml forum. Where they allowed to copy this answer here.
http://plantuml.sourceforge.net/qa/?qa=3596/how-to-generate-a-legend-with-colors-in-plantuml
There doesn't appear to be a direct way of including a color-coded legend in a PlantUML diagram, but I figured out a workaround which is close enough.
TypeA
,TypeB
,TypeC
inside a packageLEGEND
.Alternatively, the "hidden" connectors could be replaced with
-r-
, like so:These produces the following diagrams. Neither one is perfect, but better than drawing the legend separately in image editor. :-) I do hope PlantUML offers direct support for this in a future release.
I've tried nfec's solution and it was not working for me, but it started me off on a solution that did work. Here is what I got.