Skip to content
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

Add tag (=additional stereotype) support, that e.g. specific characteristics can be added to an element #102

Closed
kirchsth opened this issue Dec 18, 2020 · 3 comments · Fixed by #107
Milestone

Comments

@kirchsth
Copy link
Contributor

kirchsth commented Dec 18, 2020

In some diagrams I want to display additional details (e.g. component is part of failover) with a different color.
PlantUML supports multiple stereotypes, and I would add for the tag an additional stereotype.

E.g. all element are extended with a tag argument

ContainerDb($alias, $label, $techn, $descr="", $sprite="", $tag="")

E.g. the "C4_Deployment Diagram Sample - bigbankplc" has a second DB which is part of failover (this DB is marked with the tag "fallback"). It could be modelled like

@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Deployment.puml

skinparam database {
    FontColor<<fallback>> #404040
    BackgroundColor<<fallback>> #c0c0c0
}
...
    Deployment_Node(bigbankdb01, "bigbank-db01", "Ubuntu 16.04 LTS"){
        Deployment_Node(oracle, "Oracle - Primary", "Oracle 12c"){
            ContainerDb(db, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.")
        }
    }
    Deployment_Node(bigbankdb02, "bigbank-db02", "Ubuntu 16.04 LTS"){
        Deployment_Node(oracle2, "Oracle - Secondary", "Oracle 12c"){
            ContainerDb(db2, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.", $tag="fallback")
        }
    }
...

and the output would look like
grafik

I don't know if it can be realized in all scenarios (I have to check it) but could try it.

@adrianvlupu
Copy link
Member

adrianvlupu commented Dec 19, 2020

Hi, while I understand the need to add custom colors and entities to a C4 Diagram, I think that adding another parameter to the Container procedure will overcomplicate things. How about using the $getContainer procedure instead?

@startuml
!include https://raw.githubusercontent.com/adrianvlupu/C4-PlantUML/latest/C4_Container.puml

skinparam database<<fallback>> {
    FontColor #404040
    BackgroundColor #c0c0c0
}
!unquoted procedure FallbackDatabaseContainer($alias, $label, $techn, $descr="", $sprite="")
database "$getContainer($label, $techn, $descr, $sprite)" <<fallback>><<container>> as $alias
!endprocedure

FallbackDatabaseContainer(db2, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.")
@enduml

C4_Container Diagram Sample - bigbankplc

This is not perfect either because it doesn't show up in the legend but I think it's worth adding stuff like this in the docs. What do you think?

@kirchsth
Copy link
Contributor Author

Hi, I also didn't like an additional argument, but then I found the "keywords arguments" and think that the additional argument would not complicate the diagram anymore as long it is not used. And if they are used its only additional argument (without empty placeholder).

- this I wouldn't like too
  System(s2, "S2", "", "", "fallback")
  ContainerDb(db2, "backup db", "Oracle", "", "", "fallback")

- but this I think is ok
  System(s2, "S2", $tags = "fallback")
  ContainerDb(db2, "backup db", "Oracle",  $tags = "fallback")

In some architectures I used e.g. 2 identically databases and "fallback" is only a time dependen role. And therefore I would prefer that I can model it with the same elements.

The internal implementation should be simple and not the problem.
The second advantage would be that I could reuse the same tag for multiple elements (eg. system and container)

kirchsth added a commit to kirchsth/C4-PlantUML that referenced this issue Jan 2, 2021
…om tags/stereotypes support; dynamic legend supports custom colors, border and shadow; dynamic legend displays (only) used elements, tags/stereotypes.

New added macros: SHOW_DYNAMIC_LEGEND(), AddTagSupport(), UpdateSkinparamsAndLegendEntry(), elements macros are extended with $tags="..."
kirchsth added a commit to kirchsth/C4-PlantUML that referenced this issue Jan 2, 2021
…om tags/stereotypes support; ... (2 - update macros docu with added $tags="...")
@kirchsth
Copy link
Contributor Author

kirchsth commented Jan 2, 2021

@adrianvlupu can you please review my PR #107? I think the functionality itself is ok. Maybe you have better names for concrete macros,...
Thank you and best regards
Helmut

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
3 participants