-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use default bgColor and fontColor for new element tags #154
Comments
Which color should be used with v1.1? The "dark blue" person or the "blue" container? I think there is no logic rule which can be used. Therefore I introduced the undefined colors. You can overwrite it in your diagram
The legend texts are constants and can be changed too like below
In #150 I implemented a better "undefined/default" color handling, maybe you want to check it too. BR Helmut
|
@kirchsth I don't think this implementation would be useful to me. This is because, it doesn't adhere to how I think the legend should work and doesn't follow the legend entry patterns for default items like In your example above, I think there should be 2 different @startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
AddElementTag("v1.0", $borderColor="#d73027", $bgColor=$CONTAINER_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR)
AddElementTag("container_v1.1", $fontColor="#d73027", $bgColor=$CONTAINER_BG_COLOR)
AddElementTag("person_v1.1", $fontColor="#d73027", $bgColor=$PERSON_BG_COLOR)
AddElementTag("backup", $fontColor="orange", $bgColor=$CONTAINER_BG_COLOR)
AddRelTag("backup", $textColor="orange", $lineColor="orange")
AddRelTag("db_read_writes", $textColor="blue", $lineColor=$ARROW_COLOR)
Person(user, "Customer", "People that need products")
Person(admin, "Administrator", "People that administrates the products via the new v1.1 components", $tags="person_v1.1")
Container(spa, "SPA", "angular", "The main interface that the customer interacts with via v1.0", $tags="v1.0")
Container(spaAdmin, "Admin SPA", "angular", "The administrator interface that the customer interacts with via new v1.1", $tags="container_v1.1")
Container(api, "API", "java", "Handles all business logic (incl. new v1.1 extensions)", $tags="v1.0+container_v1.1")
ContainerDb(db, "Database", "Microsoft SQL", "Holds product, order and invoice information")
Container(archive, "Archive", "Audit logging", "Stores 5 years", $tags="backup")
Rel(user, spa, "Uses", "https")
Rel(spa, api, "Uses", "https")
Rel_R(api, db, "Reads/Writes", $tags="db_read_writes")
Rel(admin, spaAdmin, "Uses", "https")
Rel(spaAdmin, api, "Uses", "https")
Rel_L(api, archive, "Writes", "messages", $tags="backup")
SHOW_LEGEND()
@enduml The above code and resultant image shows how I typically define new tags to ensure correct legend entries. So I suppose what I am really looking for then, are specialized AddPersonTag()
AddSystemTag()
AddContainerTag()
AddComponentTag() I think we can currently set defaults for |
you can change the default person,... and relations style with calls like
Is this what you want? (source of the image is in Read.me) BR Helmut |
@kirchsth No, I am not trying to update the default element and relation styles as that will change the style of all the element and relation types specified in The issue is what happens when we use the procedures to add a tag to an element or relation and we do not specify all the arguments. What I am proposing is how the library should set the unspecified arguments for display in the legend. If I have 2 containers, where I would like to add a tag to one of them, then I use the AddElementTag procedure. However, I only wish to change the fontColor of the default container styling. I achieve this as expected by calling the @startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
AddElementTag(tagged, $fontColor=red)
Container(default, Container 1, tech)
Container(tagged, Container 2, tech, $tags="tagged")
SHOW_LEGEND()
@enduml In my opinion, the legend should be displayed as below. The unspecified But since the current
So I will then only apply that tag to a container element. In order that users do not have to always specify all the argument values to generate a proper legend, I am proposing that new procedures be created e.g. !procedure AddContainerTag($tagStereo, $bgColor=$CONTAINER_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$CONTAINER_BORDER_COLOR, $shadowing="false")
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing)
!endprocedure
!procedure AddPersonTag($tagStereo, $bgColor=$PERSON_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$PERSON_BORDER_COLOR, $shadowing="false")
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing)
!endprocedure Or alternatively we can extend UpdateElementStyle and UpdateRelStyle to accept a stereo name so that it will only update the style of elements with the given tag e.g. ' Only update default styling for given `elementName` tagged with `tag` value
UpdateElementStyle(elementName, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?tag)
' example
UpdateElementStyle("container", $fontColor="red", $tag="tagged") Or even better AddElementTag($tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?elementName)
' Style will only be applied to elements with stereo <<tagged>> AND <<container>>.
' Since we know we are applying the style to a container, we can use the container bgColor and borderColor if not specified
AddElementTag("tagged", $fontColor="red", $elementName="container") This pattern should apply also to the current functionality of Given the below code @startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
' AddElementTag(tagged, $fontColor=red)
UpdateElementStyle("container", $fontColor=red)
Container(default, Container 1, tech)
Container(tagged, Container 2, tech, $tags="tagged")
SHOW_LEGEND()
@enduml Since I didn't specify a bgColor, I get the following legend with a pink background and a text specifying "no back color" I would have expected the following instead. (Assumed that since bgColor is not a required argument, the bgColor of both the legend and element specified (container) would use the default color of Hope this is clearer |
I think I understand your wish, following source
should be displayed like But PlantUML offers only few preprocessor calls (details). You could try to extend SHOW_LEGEND() with missing functionanlity and create a PR (please don't forget the combination of multiple tags, ....). BR Helmut PS.: source of the diagram based on the current implementation
|
Hi @dannief, with #173 I added Element specific tag defintions with element specific default colors like
that repeated color defintions can be avoided like below @startuml
!include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Container.puml
' AddElementTag("tagged", $fontColor=red)
AddContainerTag("tagged container", $fontColor=red)
AddPersonTag("tagged person", $fontColor=red)
Container(c1, Container 1, tech)
Container(cTagged, Container 2, tech, $tags="tagged container")
Person(p1, Person 1)
Person(pTagged, Person 2, $tags="tagged person")
SHOW_LEGEND()
@enduml Maybe this helps. |
In the diagram below, when new elements or rel tags are defined, if
$fontColor
or$bgColor
are not specified (for element tags for example), then the generated legend shows texts:(no text)
and(no back color)
. But since the element or relation uses the default colors, if not defined in the procedure, I think we should use the same colors in the legend. I find I keep setting the colors back to default colors, just so that(no text)
and(no back color)
are not displayed in the legend.The text was updated successfully, but these errors were encountered: