mirror of
https://github.com/plantuml-stdlib/C4-PlantUML.git
synced 2022-10-18 01:14:54 +00:00
#126: C4 relationships support description, sprite/openIconic and tags (3 - update/add samples)
This commit is contained in:
@@ -211,12 +211,12 @@ $elementSkin
|
||||
!$bg = "#" + $bg
|
||||
!endif
|
||||
' !$tagEntry = $tagEntry + "<" + $bg +">"
|
||||
' <U+23AF> ..white line
|
||||
' <U+23AF> ..white line, not working with png use -
|
||||
!if ($lineColor!="")
|
||||
!$tagEntry = $tagEntry + "<color:"+$lineColor+"> <U+23AF></color> "
|
||||
!$tagEntry = $tagEntry + "<color:"+$lineColor+"> -</color> "
|
||||
!else
|
||||
' !$tagEntry = $tagEntry + "<color:"+$bg+"> <U+23AF></color> "
|
||||
!$tagEntry = $tagEntry + " <U+23AF> "
|
||||
' !$tagEntry = $tagEntry + "<color:"+$bg+"> -</color> "
|
||||
!$tagEntry = $tagEntry + " - "
|
||||
!endif
|
||||
!if ($textColor!="")
|
||||
!$tagEntry = $tagEntry + "<color:"+$textColor+">"
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ SHOW_LEGEND()
|
||||
@enduml
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
## LAYOUT_AS_SKETCH()
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ Rel_R(api, db, "Reads/Writes")
|
||||
|
||||

|
||||
|
||||
Entities can be decorated with tags and explained via dynamic calculated legends, for example:
|
||||
Entities and Relations can be decorated with tags and explained via dynamic calculated legends, for example:
|
||||
|
||||
```csharp
|
||||
@startuml
|
||||
@@ -105,6 +105,9 @@ Entities can be decorated with tags and explained via dynamic calculated legends
|
||||
|
||||
AddTagSupport("v1.0", $borderColor="#d73027")
|
||||
AddTagSupport("v1.1", $fontColor="#d73027")
|
||||
AddTagSupport("backup", $fontColor="orange")
|
||||
|
||||
AddRelTagSupport("backup", $textColor="orange", $lineColor="orange")
|
||||
|
||||
Person(user, "Customer", "People that need products")
|
||||
Person(admin, "Administrator", "People that administrates the products via the new v1.1 components", $tags="v1.1")
|
||||
@@ -112,18 +115,20 @@ Container(spa, "SPA", "angular", "The main interface that the customer interacts
|
||||
Container(spaAdmin, "Admin SPA", "angular", "The administrator interface that the customer interacts with via new v1.1", $tags="v1.1")
|
||||
Container(api, "API", "java", "Handles all business logic (incl. new v1.1 extensions)", $tags="v1.0+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")
|
||||
Rel(admin, spaAdmin, "Uses", "https")
|
||||
Rel(spaAdmin, api, "Uses", "https")
|
||||
Rel_L(api, archive, "Writes", "messages", $tags="backup")
|
||||
|
||||
SHOW_LEGEND()
|
||||
@enduml
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## Supported Diagram Types
|
||||
@@ -183,7 +188,7 @@ Take a look at each of the [C4 Model Diagram Samples](samples/C4CoreDiagrams.md)
|
||||
|
||||
## Relationship Types
|
||||
|
||||
* `Rel(from, to, label, ?technology)`
|
||||
* `Rel(from, to, label, ?technology, ?description, ?sprite, ?tags)`
|
||||
* `BiRel` (bidirectional relationship)
|
||||
|
||||
You can force the direction of a relationship by using:
|
||||
@@ -193,6 +198,44 @@ You can force the direction of a relationship by using:
|
||||
* `Rel_L`, `Rel_Left`
|
||||
* `Rel_R`, `Rel_Right`
|
||||
|
||||
Relation specific sprites are not down scaled, they requires typically smaller icons.
|
||||
Or alternatively if sprite argument starts with `&` an OpenIconic name can be used (details see https://useiconic.com/open)
|
||||
|
||||
```csharp
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Dynamic.puml
|
||||
|
||||
Person(user, "User1")
|
||||
Person(user2, "User2")
|
||||
System(system, "System")
|
||||
|
||||
' if sprite starts with &, sprite defines a OpenIconic, details see https://useiconic.com/open/
|
||||
Rel_D(user, system, "requests", "async message", "if sprite starts with &, it defines a OpenIconic like &envelope-closed", $sprite = "&envelope-closed")
|
||||
|
||||
' normal sprites are too big
|
||||
Rel_R(user, user2, "informs", "courier", "normal sprites are too big", "person2")
|
||||
|
||||
' special smaller sprites have to be used
|
||||
sprite $triangle {
|
||||
00000000000
|
||||
00000F00000
|
||||
0000FBF0000
|
||||
0000FBF0000
|
||||
000F999F000
|
||||
000F999F000
|
||||
00F66666F00
|
||||
00F66666F00
|
||||
0F3333333F0
|
||||
0F3333333F0
|
||||
0FFFFFFFFF0
|
||||
00000000000
|
||||
}
|
||||
Rel(user, system, "orders", "http", "only small sprites looks ok, like the small triangle", "triangle")
|
||||
@enduml
|
||||
```
|
||||
|
||||

|
||||
|
||||
In rare cases, you can force the layout of objects which have no relationships by using:
|
||||
|
||||
* `Lay_U`
|
||||
@@ -252,11 +295,16 @@ C4-PlantUML also comes with some default person sprite options:
|
||||
Additional tags/stereotypes can be added to the existing element stereotypes (component, ...) and highlight,... specific aspects:
|
||||
|
||||
* `AddTagSupport(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing)`:
|
||||
After this call the given tag can be used in the diagram, the styles of the tagged elements are updated and the tag is be displayed in the dynamic legend.
|
||||
* `UpdateElementStyle(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing)`
|
||||
This call updates the style of the default element stereotypes (component, ...) and creates no additional legend entry.
|
||||
Introduces a new element tag. The styles of the tagged elements are updated and the tag is be displayed in the dynamic legend.
|
||||
* `AddRelTagSupport(tagStereo, ?textColor, ?lineColor)`:
|
||||
Introduces a new relation tag. The styles of the tagged relations are updated and the tag is be displayed in the dynamic legend.
|
||||
|
||||
Each element can be extended with one or multiple custom tags/stereotypes via the keyword argument `$tags="..."`, like `Container(spaAdmin, "Admin SPA", $tags="v1.1")`.
|
||||
* `UpdateElementStyle(elementName, ?bgColor, ?fontColor, ?borderColor, ?shadowing)`
|
||||
This call updates the default style of the elements (component, ...) and creates no additional legend entry.
|
||||
* `UpdateRelStyle(textColor, lineColor)`
|
||||
This call updates the default relationship colors and creates no additional legend entry.
|
||||
|
||||
Each element can be extended with one or multiple custom tags via the keyword argument `$tags="..."`, like `Container(spaAdmin, "Admin SPA", $tags="v1.1")`.
|
||||
Multiple tags can be combined with `+`, like `Container(api, "API", $tags="v1.0+v1.1")`.
|
||||
|
||||
**Comments**
|
||||
@@ -266,17 +314,26 @@ Multiple tags can be combined with `+`, like `Container(api, "API", $tags="v1.0+
|
||||
* `SHOW_LEGEND()` has to be last line in diagram.
|
||||
* Don't use space between `$tags` and `=` (PlantUML does not support it).
|
||||
* Don't use `,` as part of the tag names (PlantUML does not support it in combination with keyword arguments).
|
||||
* If 2 tags defines the same skinparameter, the first definition is used.
|
||||
* If specific skinparameters have to be merged (e.g. 2 tags change the font color) an additional combined tag has to be defined. Use `&` as part of combined tag names. This convention can be used in other tools.
|
||||
* If 2 tags defines the same skinparam, the first definition is used.
|
||||
* If specific skinparams have to be merged (e.g. 2 tags change the font color) an additional combined tag has to be defined. Use `&` as part of combined tag names.
|
||||
|
||||
* Colors of relationship tags cannot be automatically merged (PlantUML does not support it).
|
||||
If one tag modifies the line color and the other the text color, an additional combined tag has to be defined and used.
|
||||
|
||||
```csharp
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
|
||||
|
||||
UpdateElementStyle(person, $fontColor="green")
|
||||
AddTagSupport("v1.0", $fontColor="#d73027", $borderColor="#d73027")
|
||||
AddTagSupport("v1.1", $fontColor="#ffffbf", $borderColor="#ffffbf")
|
||||
AddTagSupport("v1.0&v1.1", $fontColor="#fdae61", $borderColor="#fdae61")
|
||||
AddTagSupport("fallback", $bgColor="#888888")
|
||||
AddTagSupport("fallback", $bgColor="#444444")
|
||||
|
||||
UpdateRelStyle(black, black)
|
||||
AddRelTagSupport("service1", $textColor="red")
|
||||
AddRelTagSupport("service2", $lineColor="red")
|
||||
AddRelTagSupport("service1&service2", $textColor="red", $lineColor="red")
|
||||
|
||||
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="v1.1")
|
||||
@@ -289,11 +346,19 @@ Rel(spaAdmin, api, "Uses", "https")
|
||||
Rel_L(spa, spa2, "Updates", "https")
|
||||
Rel_R(spaAdmin, spaAdmin2, "Updates", "https")
|
||||
|
||||
Person(user, "A user")
|
||||
System(system, "A system")
|
||||
|
||||
Rel_D(user, system, "uses service1 via this call", $tags="service1")
|
||||
Rel_D(user, system, "uses service2 via this call", $tags="service2")
|
||||
Rel_D(user, system, "uses both services via this call", $tags="service1&service2+service1+service2")
|
||||
|
||||
Lay_D(api, user)
|
||||
SHOW_LEGEND(false)
|
||||
@enduml
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
**Custom schema definition**
|
||||
|
||||
@@ -314,11 +379,14 @@ If the custom (color) schema is defined via `UpdateElementStyle()` then the lege
|
||||
!$COLOR_B_3 = "#8073ac"
|
||||
!$COLOR_B_4 = "#542788"
|
||||
!$COLOR_B_5 = "#2d004b"
|
||||
!$COLOR_REL_LINE = "#8073ac"
|
||||
!$COLOR_REL_TEXT = "#8073ac"
|
||||
|
||||
UpdateElementStyle("person", $bgColor=$COLOR_A_5, $fontColor=$COLOR_NEUTRAL, $borderColor=$COLOR_A_1, $shadowing="true")
|
||||
UpdateElementStyle("external_person", $bgColor=$COLOR_B_5, $fontColor=$COLOR_NEUTRAL, $borderColor=$COLOR_B_1)
|
||||
UpdateElementStyle("system", $bgColor=$COLOR_A_4, $fontColor=$COLOR_NEUTRAL, $borderColor=$COLOR_A_2)
|
||||
UpdateElementStyle("external_system", $bgColor=$COLOR_B_4, $fontColor=$COLOR_NEUTRAL, $borderColor=$COLOR_B_2)
|
||||
UpdateRelStyle($lineColor=$COLOR_REL_LINE, &textColor=$COLOR_REL_TEXT)
|
||||
|
||||
Person(customer, "Personal Banking Customer")
|
||||
System(banking_system, "Internet Banking System")
|
||||
@@ -335,7 +403,7 @@ SHOW_LEGEND()
|
||||
@enduml
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
## Element properties
|
||||
|
||||
|
||||
Reference in New Issue
Block a user