### Full Example: Dynamic Diagram Generation with JSON Source: https://plantuml.com/es/preprocessing-json A comprehensive example demonstrating how to load JSON data, define functions, and use loops and conditional logic to dynamically generate a PlantUML diagram with participants and boxes. ```plantuml @startuml !unquoted function DRAW($x) return %set_variable_value($x, 1) !procedure addComponent($part, $component, $as) !if %variable_exists($part) participant "$component" as $as !endif !end procedure !procedure addBox2($part, $box, $colour, $data) !if %variable_exists($part) box "$box" #$colour !foreach $item in $data.participants addComponent($part, $item.name, $item.as) !endfor end box !endif !end procedure DRAW(PART25) !ifdef PART25 title TESTING (Boxes & Participants) //Part25// !endif !$data={ "participants": [ {"name": "XYZ", "as": "xyz"}, {"name": "RST", "as": "rst"}, {"name": "UVW", "as": "uvw"}] } addBox2("PART25", "New Box", "white", $data) @enduml ``` -------------------------------- ### Self-Descriptive Example with JSON Data Source: https://plantuml.com/es/preprocessing-json This example uses JSON data to dynamically create a nested diagram structure with rectangles representing parts, colors, and names, demonstrating the integration of JSON with PlantUML's layout capabilities. ```plantuml @startuml left to right direction !$data={"parts": [ {"shape": "cloud", "name": "id1", "colour": "#palegreen", "desc": "some text"}, {"shape": "folder", "name": "id2", "colour": "#lightblue", "desc": "more text"}, {"shape": "database", "name": "id3", "colour": "#pink", "desc": "even more text"} ] } rectangle Outer { rectangle Inner #tan as " {{json $data }} " together { !foreach $part in $data.parts $part.shape $part.colour $part.name as "$part.desc" Inner --> $part.name !endfor } } @enduml ``` -------------------------------- ### Aligned Notes at the Same Level (with /) Source: https://plantuml.com/es/sequence-diagram Use the `/` syntax between notes to align them at the same level. This example shows notes over Alice and Bob aligned. ```plantuml @startuml note over Alice : initial state of Alice / note over Bob : initial state of Bob Bob -> Alice : hello @enduml ``` -------------------------------- ### Enable Handwritten Style for Deployment Diagrams (Group) Source: https://plantuml.com/es-dark/handwritten Generate deployment diagrams with groups and handwritten styling by setting `!option handwritten true`. This example shows nested structures like packages and nodes. ```plantuml @startuml !option handwritten true package "Some Group" { HTTP - [First Component] [Another Component] } node "Other Groups" { FTP - [Second Component] [First Component] --> FTP } cloud { [Example 1] } database "MySql" { folder "This is my folder" { [Folder 3] } frame "Foo" { [Frame 4] } } [Another Component] --> [Example 1] [Example 1] --> [Folder 3] [Folder 3] --> [Frame 4] @enduml ``` -------------------------------- ### Enable Handwritten Style for Timing Diagrams Source: https://plantuml.com/es-dark/handwritten Generate timing diagrams in a handwritten style by using `!option handwritten true`. This example shows the states of a Web Browser and Web User over time. ```plantuml @startuml !option handwritten true robust "Web Browser" as WB concise "Web User" as WU WB is Initializing WU is Absent @WB 0 is idle +200 is Processing +100 is Waiting WB@0 <-> @50 : {50 ms lag} @WU 0 is Waiting +500 is ok @200 <-> @+150 : {150 ms} @enduml ``` -------------------------------- ### Enable Handwritten Style for Salt Diagrams Source: https://plantuml.com/es-dark/handwritten Generate Salt diagrams in a handwritten format by including `!option handwritten true`. This example depicts a mainframe with login fields and buttons. ```plantuml @startsalt !option handwritten true mainframe This is a **mainframe** { + Login | "MyName " Password | "**** " [Cancel] | [ OK ] } @endsalt ``` -------------------------------- ### Enable Handwritten Style for Object Diagrams Source: https://plantuml.com/es-dark/handwritten Create object diagrams with a handwritten appearance by using `!option handwritten true`. This example shows object instantiation, attributes, and relationships. ```plantuml @startuml !option handwritten true object user1 user1 : name = "Dummy" user1 : id = 123 object user2 { name = "Dummy" id = 123 } object o1 object o2 diamond dia object o3 o1 --> dia o2 "1" -> "1" dia dia --> o3 object London map CapitalCity { UK *-> London USA => Washington Germany => Berlin } note right of London: Big ben user1 --> CapitalCity : visits >@enduml ``` -------------------------------- ### Enable Handwritten Style for Sequence Diagrams Source: https://plantuml.com/es-dark/handwritten Use `!option handwritten true` to render sequence diagrams with a handwritten style. This example shows a simple interaction between Alice and Bob. ```plantuml @startuml !option handwritten true Alice -> Bob : hello note right: Not validated yet @enduml ``` -------------------------------- ### Enable Handwritten Style for EBNF Diagrams Source: https://plantuml.com/es-dark/handwritten Create EBNF diagrams with a handwritten appearance by using `!option handwritten true`. This example includes basic EBNF syntax with comments and repetitions. ```plantuml @startebnf !option handwritten true title Title not_styled_ebnf = {"a", c , "a" (* Note on a *)} | ? special ? | "repetition", 4 * '2'; (* Global End Note *) @endebnf ``` -------------------------------- ### Enable Handwritten Style for State Diagrams Source: https://plantuml.com/es-dark/handwritten Create state diagrams with a handwritten appearance by setting `!option handwritten true`. This example illustrates choices, forks, joins, and transitions between states. ```plantuml @startuml !option handwritten true state choice1 <> state fork1 <> state join2 <> state end3 <> [*] --> choice1 : from start to choice choice1 --> fork1 : from choice to fork choice1 --> join2 : from choice to join choice1 --> end3 : from choice to end fork1 ---> State1 : from fork to state fork1 --> State2 : from fork to state State2 --> join2 : from state to join State1 --> [*] : from state to end join2 --> [*] : from join to end @enduml ``` -------------------------------- ### Enable Handwritten Style for Gantt Charts Source: https://plantuml.com/es-dark/handwritten Generate Gantt charts in a handwritten style by including `!option handwritten true`. This example demonstrates tasks, durations, dependencies, and notes. ```plantuml @startgantt !option handwritten true hide footbox Project starts the 2020-12-01 [Task1] lasts 9 days sunday are closed note bottom memo1 ... memo2 ... explanations1 ... explanations2 ... end note [Task2] lasts 10 days [Task2] starts 7 days after [Task1]'s end note bottom memo1 ... memo2 ... explanations1 ... explanations2 ... end note -- Separator title -- [M1] happens on 5 days after [Task1]'s end -- end -- @endgantt ``` -------------------------------- ### Aligned Notes at the Same Level (Default) Source: https://plantuml.com/es/sequence-diagram By default, notes are not aligned at the same level. This example shows notes over Alice and Bob without alignment. ```plantuml @startuml note over Alice : initial state of Alice note over Bob : initial state of Bob Bob -> Alice : hello @enduml ``` -------------------------------- ### Enable Handwritten Style for Wire Diagrams Source: https://plantuml.com/es-dark/handwritten Generate wire diagrams in a handwritten format by using `!option handwritten true`. This example shows a simple sequence of elements labeled 'first', 'second_box', and 'third'. ```plantuml @startwire !option handwritten true * first * second_box [100x50] * third @endwire ``` -------------------------------- ### Enable Handwritten Style for Network Diagrams (nwdiag) Source: https://plantuml.com/es-dark/handwritten Generate network diagrams using nwdiag with a handwritten style by setting `!option handwritten true`. This example defines two networks with addresses and nodes. ```plantuml @startnwdiag !option handwritten true nwdiag { network dmz { address = "210.x.x.x/24" web01 [address = "210.x.x.1"]; web02 [address = "210.x.x.2"]; } network internal { address = "172.x.x.x/24" web01 [address = "172.x.x.1"]; web02 [address = "172.x.x.2"]; db01; db02; } } @endnwdiag ``` -------------------------------- ### Enable Handwritten Style for Mind Maps Source: https://plantuml.com/es-dark/handwritten Create mind maps with a handwritten style by adding `!option handwritten true`. This example shows a hierarchical structure for world regions and countries. ```plantuml @startmindmap !option handwritten true * World ** America *** Canada *** Mexico *** USA ** Europe ***_ England ***_ Germany ***_ Spain @endmindmap ``` -------------------------------- ### Get JSON Keys Source: https://plantuml.com/es-dark/preprocessing-json Retrieves all keys from a single level of a JSON structure. Useful for iterating over object properties. ```PlantUML @startuml !$myjson = { "root" : [{ "fruits": [ {"name": "apple", "colorId": "1"}, {"name": "pear", "colorId": "2"}, {"name": "pineapple", "colorId": "3"} ] }, { "colors": [ {"id": "1", "name": "red"}, {"id": "2", "name": "green"}, {"id": "3", "name": "yellow"} ] }] } !foreach $key in %get_json_keys($myjson.root) rectangle $key !endfor @enduml ``` ```PlantUML @startwbs !$json_object = { "name": "Mark McGwire", "hr": 65, "avg": 0.278 } * json_object * keys of json_object !foreach $key in %get_json_keys($json_object) * $key !endfor @endwbs ``` -------------------------------- ### Enable Handwritten Style for WBS Diagrams Source: https://plantuml.com/es-dark/handwritten Create Work Breakdown Structure (WBS) diagrams with a handwritten style by adding `!option handwritten true`. This example uses a hierarchical structure similar to a mind map. ```plantuml @startwbs !option handwritten true * World ** America *** Canada *** Mexico *** USA ** Europe ***_ England ***_ Germany ***_ Spain @endwbs ``` -------------------------------- ### Styling HyperlinkColor with CSS Source: https://plantuml.com/es/link Applies custom styling to hyperlinks using CSS within a PlantUML diagram. This example sets the hyperlink color to red for elements matching the '.red' style. ```plantuml @startuml title test on HyperlinkColor [[test link]] class test <> { * aaa + [[normal model]] - bb } class test_with_stereo AS "[[http://www.plantuml.com test]]" <> { * aaa + [[red model]] - bb } @enduml ``` -------------------------------- ### Get JSON Structure Size Source: https://plantuml.com/es-dark/preprocessing-json Calculates the size of JSON elements: number of pairs for objects, number of values for arrays, and number of characters for strings. Numeric and boolean/null values return zero. ```PlantUML @startuml !$json_object= { "name" : "Mark McGwire", "hr" : 65, "avg" : 0.278, "letters": ["a", "b", "c"] } label l [ |= $variable |= get_json_type($var) |= size($var) | json_object | %get_json_type($json_object) | %size($json_object) | json_object.name | %get_json_type($json_object.name) | %size($json_object.name) | json_object.hr | %get_json_type($json_object.hr) | %size($json_object.hr) | json_object.letters | %get_json_type($json_object.letters) | %size($json_object.letters) | ] @enduml ``` -------------------------------- ### Group Actors and Use Cases with Packages Source: https://plantuml.com/es/use-case-diagram Organizes actors and use cases into packages for better structure. Demonstrates grouping with 'package' and 'rectangle'. ```plantuml @startuml left to right direction actor Guest as g package Professional { actor Chef as c actor "Food Critic" as fc } package Restaurant { usecase "Eat Food" as UC1 usecase "Pay for Food" as UC2 usecase "Drink" as UC3 usecase "Review" as UC4 } fc --> UC4 g --> UC1 g --> UC2 g --> UC3 @enduml ``` ```plantuml @startuml left to right direction actor "Food Critic" as fc rectangle Restaurant { usecase "Eat Food" as UC1 usecase "Pay for Food" as UC2 usecase "Drink" as UC3 } fc --> UC1 fc --> UC2 fc --> UC3 @enduml ``` -------------------------------- ### Horizontal Partitioning (teoz mode) Source: https://plantuml.com/es/sequence-diagram Enable 'teoz' mode with `!pragma teoz true` to make partitions span the entire width horizontally. ```plantuml @startuml !pragma teoz true participant a partition p1 b -> c: msg c --> b: OK note right: Some right note end partition p2 a -> b: msg note left: Some left note end @enduml ``` -------------------------------- ### Object Diagrams with Packages and Maps Source: https://plantuml.com/es/object-diagram Demonstrate how objects and maps can be defined within packages and how relationships can span across package boundaries, referencing specific map entries. ```plantuml @startuml package foo { object baz } package bar { map A { b *-> foo.baz c => } } A::c --> foo @enduml ``` ```plantuml @startuml object Foo map Bar { abc=> def=> } object Baz Bar::abc --> Baz : Label one Foo --> Bar::def : Label two @enduml ``` -------------------------------- ### Get JSON Element Type Source: https://plantuml.com/es-dark/preprocessing-json Determines and returns the data type of a JSON element as a string. Useful for conditional logic based on data type. ```PlantUML @startuml !$json_object = { "name": "Mark McGwire", "hr": 65, "avg": 0.278, "letters": ["a", "b", "c"] } label l [ =json_object: {{json $json_object }} |= $variable |= get_json_type($var) | | json_object | %get_json_type($json_object) | json_object.name | %get_json_type($json_object.name) | json_object.hr | %get_json_type($json_object.hr) | json_object.letters | %get_json_type($json_object.letters) ] Test on type: !if %get_json_type($json_object.letters)=="array" json_object.letters is an **%get_json_type($json_object.letters)** !endif @enduml ``` -------------------------------- ### Setting Hyperlink Underline Thickness (1) Source: https://plantuml.com/es/link Demonstrates setting the hyperlink underline thickness to 1 using 'skinparam hyperlinkUnderline 1'. This setting is specific to PNG output. ```plantuml @startuml skinparam hyperlinkUnderline 1 :hyperlinkColor setting; :[[http://plantuml.com]]; @enduml ``` -------------------------------- ### Declaring Participants with Types Source: https://plantuml.com/es-dark/sequence-diagram Shows how to declare participants using various keywords like 'actor', 'boundary', 'control', 'entity', 'database', and 'collections'. Messages are sent to these declared participants. ```plantuml @startuml actor Foo1 boundary Foo2 control Foo3 entity Foo4 database Foo5 collections Foo6 Foo1 -> Foo2 : To boundary Foo1 -> Foo3 : To control Foo1 -> Foo4 : To entity Foo1 -> Foo5 : To database Foo1 -> Foo6 : To collections @enduml ``` -------------------------------- ### Enable Handwritten Style for Deployment Diagrams (Shapes) Source: https://plantuml.com/es-dark/handwritten Use `!option handwritten true` to render deployment diagram shapes with a handwritten look. This applies to various predefined shapes like actor, agent, and database. ```plantuml @startuml !option handwritten true actor actor actor/ "actor/" agent agent artifact artifact boundary boundary card card circle circle cloud cloud collections collections component component control control database database entity entity file file folder folder frame frame hexagon hexagon interface interface label label node node package package person person queue queue rectangle rectangle stack stack storage storage usecase usecase usecase/ "usecase/" @enduml ``` -------------------------------- ### Renaming and Coloring Participants Source: https://plantuml.com/es-dark/sequence-diagram Illustrates renaming participants using the 'as' keyword and changing their background color using '#color'. Demonstrates declaring participants with long names and aliases. ```plantuml @startuml actor Bob #red participant Alice participant "I have a really\nlong name" as L #99FF99 Alice->Bob: Authentication Request Bob->Alice: Authentication Response Bob->L: Log transaction @enduml ``` -------------------------------- ### Define and Use Complex Inline SVG Sprite Source: https://plantuml.com/es-dark/sprite An example of defining a sprite with a more complex inline SVG, demonstrating the use of paths and fills for detailed graphics. This sprite is then used in a diagram. ```plantuml @startuml sprite foo1 Alice->Bob : <$foo1> @enduml ``` -------------------------------- ### Horizontal Partitioning (Default) Source: https://plantuml.com/es/sequence-diagram Use the 'partition' command to group messages horizontally across the entire width. By default, partitions do not span the full width. ```plantuml @startuml participant a partition p1 b -> c: msg c --> b: OK note right: Some right note end partition p2 a -> b: msg note left: Some left note end @enduml ``` -------------------------------- ### Setting Hyperlink Underline Thickness (5) Source: https://plantuml.com/es/link Illustrates setting the hyperlink underline thickness to 5 using 'skinparam hyperlinkUnderline 5'. This setting is specific to PNG output. ```plantuml @startuml skinparam hyperlinkUnderline 5 :hyperlinkColor setting; :[[http://plantuml.com]]; @enduml ``` -------------------------------- ### Basic Actor-UseCase Relationships Source: https://plantuml.com/es/use-case-diagram Establishes relationships between actors and use cases using arrows. Supports arrow length variation and labels. ```plantuml @startuml User -> (Start) User --> (Use the application) : A small label : "Main Admin": ---> (Use the application) : This is\nyet another\nlabel @enduml ``` -------------------------------- ### Sequence Diagram: Using Selectors for Custom Styles Source: https://plantuml.com/es/style Shows how to apply different styles to participants using custom class selectors based on their roles. Useful for differentiating elements with specific functions. ```plantuml @startuml participant "Alice (Primary)" as Alice <> participant "Bob (Secondary)" as Bob <> Alice -> Bob : Message @enduml ``` -------------------------------- ### Define Use Cases Source: https://plantuml.com/es/use-case-diagram Define use cases using parentheses or the 'usecase' keyword. Aliases can be assigned using 'as'. ```plantuml @startuml (First usecase) (Another usecase) as (UC2) usecase UC3 usecase (Last\nusecase) as UC4 @enduml ``` -------------------------------- ### Sequence Diagram: Combining Multiple Styles Source: https://plantuml.com/es/style Demonstrates defining a global style and overriding specific styles for elements in a sequence diagram. Use this to set a base appearance and then fine-tune elements. ```plantuml @startuml participant Alice participant Bob Alice -> Bob : Combined Styles Example @enduml ``` -------------------------------- ### URL Directive in Component/Deployment Diagram Source: https://plantuml.com/es/link Shows how to use the 'url of|for XXX is [[yyy]]' syntax to link components or nodes in component or deployment diagrams. ```plantuml @startuml node Mamal component Dog url of Mamal is [[http://www.google.com]] url of Dog is [[http://www.yahoo.com{This is Dog}]] @enduml ``` -------------------------------- ### Styling HyperlinkColor (Default) Source: https://plantuml.com/es/link Shows the default rendering of hyperlinks and elements when no specific style is applied. Demonstrates basic class and stereotype rendering. ```plantuml @startuml title test on HyperlinkColor [[test link]] class test <> { * aaa + [[normal model]] - bb } class test_with_stereo AS "[[http://www.plantuml.com test]]" <> { * aaa + [[red model]] - bb } @enduml ``` -------------------------------- ### Multi-line Use Case Description Source: https://plantuml.com/es/use-case-diagram Defines a use case with a multi-line description using quotes and various separators like '--', '..', '==', and '__'. ```plantuml @startuml usecase UC1 as "You can use several lines to define your usecase. You can also use separators. -- Several separators are possible. == And you can add titles: ..Conclusion.. This allows large description." @enduml ``` -------------------------------- ### Define and Use Scaled Monochrome Sprite Source: https://plantuml.com/es-dark/sprite Demonstrates how to define a monochrome sprite and then use it with a scaling factor. The scale is applied using '{scale=N}' after the sprite reference. ```plantuml @startuml sprite $foo1 { FFFFFFFFFFFFFFF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF FFFFFFFFFFFFFFF } Alice -> Bob : Testing <$foo1{scale=3}> @enduml ``` -------------------------------- ### Enable Handwritten Style for Activity Diagrams Source: https://plantuml.com/es-dark/handwritten Use the `!option handwritten true` directive to render activity diagrams in a handwritten style. This is useful for diagrams that are still in progress. ```plantuml @startuml !option handwritten true start if (Graphviz installed?) then (yes) :process all diagrams; else (no) :process only __sequence__ and __activity__ diagrams; endif stop @enduml ``` -------------------------------- ### URL Directive in Usecase Diagram Source: https://plantuml.com/es/link Demonstrates the 'url of|for XXX is [[yyy]]' syntax for associating URLs with actors and usecases in a usecase diagram. ```plantuml @startuml actor Mamal usecase Dog url of Mamal is [[http://www.google.com]] url of Dog is [[http://www.yahoo.com{This is Dog}]] @enduml ``` -------------------------------- ### Enable Handwritten Style for Board Diagrams Source: https://plantuml.com/es-dark/handwritten Apply the `!option handwritten true` setting to generate board diagrams with a handwritten appearance. This visually signifies ongoing work. ```plantuml @startboard !option handwritten true scale .75 A1 +U1.1 ++S1 R1 ++S1 R2 +U1.2 A2 @endboard ``` -------------------------------- ### Load JSON Data from URL and Local File Source: https://plantuml.com/es/preprocessing-json Load JSON data into variables using the `%load_json()` function. This function supports loading from both URLs and local file paths. ```plantuml !$foo = %load_json("http://foo.net/users/list.json") !$foo2 = %load_json("myDir/localFile.json") ``` -------------------------------- ### Class Diagram: Visibility Icon Styling Source: https://plantuml.com/es/style Illustrates styling visibility icons, such as for protected members, by targeting the `visibilityIcon` style. Helps visually distinguish elements with specific access modifiers. ```plantuml @startuml class TaskRunner { -- {method} + executeTask {method} # executeForAllSubtasks } class MetadataInspector { -- {method} # inspectClassMetadata {method} # inspectFooterMetadata } TaskRunner <|-- MetadataInspector @enduml ``` -------------------------------- ### Participants with Non-Letter Characters and Aliases Source: https://plantuml.com/es-dark/sequence-diagram Shows how to use quotes for participant names containing non-letter characters and use the 'as' keyword to provide an alias. Also demonstrates sending messages between these participants. ```plantuml @startuml Alice -> "Bob()" : Hello "Bob()" -> "This is very\nlong" as Long Long --> "Bob()" : ok @enduml ``` -------------------------------- ### Enable Handwritten Style for Class Diagrams Source: https://plantuml.com/es-dark/handwritten To create class diagrams in a handwritten format, include `!option handwritten true`. This is suitable for early-stage design documentation. ```plantuml @startuml !option handwritten true class Object class String extends Object class Date extends Object @enduml ``` -------------------------------- ### Command-Line SVG Size Pragma Source: https://plantuml.com/es/svg Specify the `svgSize` pragma via the command line using the `-P` option. Enclose arguments in quotes, especially those with spaces, and use the option multiple times if needed for different elements. ```bash java -jar plantuml.jar "-PsvgSize= XX" "-PsvgSize= I" -Tsvg ``` -------------------------------- ### Basic Sequence Diagram Messages Source: https://plantuml.com/es-dark/sequence-diagram Demonstrates sending messages between participants using solid and dashed arrows, including reverse arrows for clarity. Participants are automatically recognized. ```plantuml @startuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: Another authentication Response @enduml ``` -------------------------------- ### Default Actor Style Source: https://plantuml.com/es/use-case-diagram Demonstrates the default 'stick man' actor style in PlantUML diagrams. ```plantuml @startuml :User: --> (Use) "Main Admin" as Admin "Use the application" as (Use) Admin --> (Admin the application) @enduml ``` -------------------------------- ### Link Maps and Objects in PlantUML Source: https://plantuml.com/es/object-diagram Establish relationships between map entries and objects, including direct composition links and dependencies to specific object fields. ```plantuml @startuml object London map CapitalCity { UK *-> London USA => Washington Germany => Berlin } @enduml ``` ```plantuml @startuml object London object Washington object Berlin object NewYork map CapitalCity { UK *-> London USA *--> Washington Germany *---> Berlin } NewYork --> CapitalCity::USA @enduml ``` -------------------------------- ### Group Messages with alt, opt, loop, par, break, critical, group Source: https://plantuml.com/es/sequence-diagram Use keywords like alt/else, opt, loop, par, break, critical, and group to organize messages. The 'end' keyword closes groups. Nested groups are supported. 'group' can have a label. ```plantuml @startuml Alice -> Bob: Authentication Request alt successful case Bob -> Alice: Authentication Accepted else some kind of failure Bob -> Alice: Authentication Failure end group My own label Alice -> Log : Log attack start loop 1000 times Alice -> Bob: DNS Attack end Alice -> Log : Log attack end end else Another type of failure Bob -> Alice: Please repeat end @enduml ``` -------------------------------- ### Note Across All Participants Source: https://plantuml.com/es/sequence-diagram Create a note spanning all participants using 'note across: description'. This is a newer syntax compared to 'note over FirstPart, LastPart'. ```plantuml @startuml Alice->Bob:m1 Bob->Charlie:m2 note over Alice, Charlie: Old method for note over all part.\n with:\n "note over //FirstPart, LastPart//". note across: New method with:\n"note across" Bob->Alice hnote across:Note across all part. @enduml ``` -------------------------------- ### Links in Notes Source: https://plantuml.com/es/link Demonstrates how to add hyperlinks within notes in a PlantUML diagram. Links can apply to the entire note or specific parts, and can include custom text and tooltips. ```plantuml @startuml :Foo: note left of Foo [[http://www.google.com]] This is a note end note note right of Foo Yet another link to [[http://www.google.com]] as demo. You can also [[http://www.yahoo.fr specify a text]] for the link. And even [[http://www.yahoo.fr{This is a tooltip} add a tooltip]] to the link. end note @enduml ``` -------------------------------- ### Clickable Link in Component/Deployment Diagram Arrow Source: https://plantuml.com/es/link Adds a clickable hyperlink to the label of a connection in a component or deployment diagram. ```plantuml @startuml node Car Car *-- Wheel [[http://plantuml.com/deployment-diagram]] : has some @enduml ``` -------------------------------- ### URL Directive in Sequence Diagram Source: https://plantuml.com/es/link Shows how to use the 'url of|for XXX is [[yyy]]' syntax to associate a URL with an element in a sequence diagram. ```plantuml @startuml Bob -> Alice : ok url of Bob is [[http://www.google.com]] @enduml ``` -------------------------------- ### Setting HyperlinkColor to Red Source: https://plantuml.com/es/link Demonstrates how to change the color of hyperlinks in a PlantUML diagram to red using the 'skinparam hyperlinkColor red' setting. ```plantuml @startuml skinparam hyperlinkColor red :hyperlinkColor setting; :[[http://plantuml.com]]; @enduml ``` -------------------------------- ### Changing Note Appearance with hnote and rnote Source: https://plantuml.com/es/sequence-diagram Use 'hnote' and 'rnote' keywords to change the appearance of notes. 'hnote' is for hexagon and 'rnote' is for rectangle. ```plantuml @startuml caller -> server : conReq hnote over caller : idle caller <- server : conConf rnote over server "r" as rectangle "h" as hexagon endrnote @enduml ``` -------------------------------- ### Enable Handwritten Style for JSON Data Source: https://plantuml.com/es-dark/handwritten Render JSON data structures with a handwritten look by using `!option handwritten true`. This is useful for visualizing JSON in a draft format. ```plantuml @startjson !option handwritten true { "fruit":"Apple", "size":"Large", "color": ["Red", "Green"] } @endjson ``` -------------------------------- ### Define Object Relationships in PlantUML Source: https://plantuml.com/es/object-diagram Illustrate relationships like specialization, implementation, composition, aggregation, and dependency between objects. Supports dotted lines and relationship labels. ```plantuml @startuml object Objeto01 object Objeto02 object Objeto03 object Objeto04 object Objeto05 object Objeto06 object Objeto07 object Objeto08 Objeto01 <|-- Objeto02 Objeto03 *-- Objeto04 Objeto05 o-- "4" Objeto06 Objeto07 .. Objeto08 : Etiqueta @enduml ``` -------------------------------- ### Awesome Actor Style Source: https://plantuml.com/es/use-case-diagram Applies the 'awesome' style to actors using 'skinparam actorStyle awesome'. ```plantuml @startuml skinparam actorStyle awesome :User: --> (Use) "Main Admin" as Admin "Use the application" as (Use) Admin --> (Admin the application) @enduml ``` -------------------------------- ### Basic ASCII Art Diagram Source: https://plantuml.com/es-dark/ascii-art This snippet displays a fundamental ASCII art diagram with labels, arrows, and multi-line messages. It's useful for illustrating simple communication flows or object interactions. ```ascii ,-. `-' ,-------------. /|\ |Bob on | | |several lines| / \ `------+------' Alice | hello | |---------------------->| , | | ,----. | | |Last| | | `-+--' |Is it ok | | |with a message that is | | |on several lines? | ,--------------!. |<----------------------| |this is a note| _\ | | `-----------------' | | ,-----------------!. | | |This other note | _\ | | |should work | | | |on several lines | | | `------------------' | | | | ========================= | ====================================== This is a separation ====================================== | ========================= | | | | | Yes it works! | |-------------------------------------->| | | | | ,------------!. | | |this is |_\| | |another note || | `--------------'| | | |- - . | | | | | | |< - ' | | | | done | | |<- - - - - - - - - - - - - - - - - - - | | | | ______________________________________________________________________ ! OPT / dummy comment | | ! !_____/ | | | ! ! | | | ! ! | Error | | ! ! | On | | ! ! | Several | | ! ! | Line | | ! ! |---------------------->| ! ! | | | ! ! | None | | ! ! |<- - - - - - - - - - - - - - - - - - - | ! !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~! ! | | | ! ! | None | | ! ! |<- - - - - - - - - - - - - - - - - - - | ! ! | | | ! ! | None | | ! ! |<--------------------------------------| ! !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~! ! [other] | | | ! ! | None | | ! ! |<--------------------------------------| ! ! | | | ! ! | ,-------------------!. ! | |This is a long note| _\ ! | |over Alice and Last | ! | `---------------------' ! | None | | ! ! |<--------------------------------------| ! ! | | | ! ! | None | | ! ! |<--------------------------------------| ! ``` -------------------------------- ### Define Objects in PlantUML Source: https://plantuml.com/es/object-diagram Define individual objects or named instances using the 'object' keyword. You can also alias objects for easier reference. ```plantuml @startuml object primerObjeto object "Mi segundo Objeto" as o2 @enduml ``` -------------------------------- ### Multi-line Participant Declaration Source: https://plantuml.com/es-dark/sequence-diagram Demonstrates declaring a participant using multiple lines, including a title and subtitle, within square brackets. ```plantuml @startuml participant Participant [ =Title ---- ""SubTitle"" ] participant Bob Participant -> Bob @enduml ``` -------------------------------- ### Hollow Actor Style Source: https://plantuml.com/es/use-case-diagram Applies the 'hollow' style to actors using 'skinparam actorStyle Hollow'. ```plantuml @startuml skinparam actorStyle Hollow :User: --> (Use) "Main Admin" as Admin "Use the application" as (Use) Admin --> (Admin the application) @enduml ``` -------------------------------- ### Object Diagram Global and Specific Styling Source: https://plantuml.com/es/style Applies a global style at the root and a specific style for objects in an object diagram. Useful for differentiating diagram elements. ```plantuml @startuml object PaymentService object Customer { name = "John Doe" id = 456 } PaymentService -> Customer @enduml ``` -------------------------------- ### Class Diagram: Multiple Custom Class Styles Source: https://plantuml.com/es/style Applies different custom styles to various classes using multiple class selectors. Useful for styling distinct groups of classes within the same diagram. ```plantuml @startuml class Customer <> class Order <> class Product Customer --> Order @enduml ``` -------------------------------- ### JSON Diagram Node and Arrow Styling Source: https://plantuml.com/es/style Styles a JSON diagram by setting properties for nodes and arrows. Demonstrates how the last defined value takes precedence for layered styles. ```plantuml @startjson { "quiz": { "question": "2+2?", "options": ["3", "4", "5"], "answer": "4" } } @endjson ``` -------------------------------- ### Change Color of Monochrome Sprite Source: https://plantuml.com/es-dark/sprite Shows how to use a monochrome sprite and specify a color for it when it's used in the diagram. This allows for dynamic color changes without redefining the sprite itself. ```plantuml @startuml sprite $foo1 { FFFFFFFFFFFFFFF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF F0123456789ABCF FFFFFFFFFFFFFFF } Alice -> Bob : Testing <$foo1,scale=3.4,color=orange> @enduml ``` -------------------------------- ### Define and Use Colored SVG Sprite Source: https://plantuml.com/es-dark/sprite Demonstrates how to define an SVG sprite and then apply specific colors to its elements when used in a diagram. This allows for customization of sprite appearance beyond its default definition. ```plantuml @startuml sprite react rectangle "<$react{scale=1}>" @enduml ``` -------------------------------- ### Default HyperlinkColor Source: https://plantuml.com/es/link Illustrates the default appearance of a hyperlink in a PlantUML diagram, showing the default color and underline. ```plantuml @startuml :hyperlinkColor setting, by default; :[[http://plantuml.com]]; @enduml ``` -------------------------------- ### Setting Top URL for All Links Source: https://plantuml.com/es/link Uses the 'skinparam topurl' setting to define a common prefix for all links within a PlantUML diagram, simplifying URL management. ```plantuml @startmindmap skinparam topurl https://plantuml.com/ * [[index PlantUML website]] ** [[sequence-diagram Sequence]] ** [[mindmap-diagram MindMap]] ** [[wbs-diagram WBS]] ** ... @endmindmap ``` -------------------------------- ### Custom Participant Order Source: https://plantuml.com/es-dark/sequence-diagram Uses the 'order' keyword to explicitly set the display order of participants in the sequence diagram. Lower numbers appear earlier. ```plantuml @startuml participant Last order 30 participant Middle order 20 participant First order 10 @enduml ``` -------------------------------- ### Define Associative Arrays (Maps) in PlantUML Source: https://plantuml.com/es/object-diagram Create associative arrays or maps using the 'map' keyword and '=>' for key-value pairs. Maps can be aliased and include descriptive titles. ```plantuml @startuml map CapitalCity { UK => London USA => Washington Germany => Berlin } @enduml ``` ```plantuml @startuml map "Map **Contry => CapitalCity**" as CC { UK => London USA => Washington Germany => Berlin } @enduml ``` ```plantuml @startuml map "map: Map" as users { 1 => Alice 2 => Bob 3 => Charlie } @enduml ``` -------------------------------- ### Response Message Below Arrow Source: https://plantuml.com/es-dark/sequence-diagram Enables placing response message text below the arrow using 'skinparam responseMessageBelowArrow true'. ```plantuml @startuml skinparam responseMessageBelowArrow true Bob -> Alice : hello Bob <- Alice : ok @enduml ``` -------------------------------- ### WBS Depth-Based Styling Source: https://plantuml.com/es/style Applies styles to WBS diagram nodes based on their depth and assigned class selectors. Useful for visualizing hierarchical structures. ```plantuml @startwbs * World ** America <> *** Canada *** Mexico *** USA **** Texas ** Europe <> *** England *** Germany *** Spain @endwbs ``` -------------------------------- ### URL Directive in Class Diagram Source: https://plantuml.com/es/link Illustrates using the 'url of|for XXX is [[yyy]]' syntax for elements in a class diagram. This allows associating URLs with classes and their relationships. ```plantuml @startuml skinparam topurl http://www.google.com Dog --|> Mammal url of Mammal is [[/search]] url of Dog is [[http://www.yahoo.com{This is Dog}]] Dog o-- Cat Cat --|> Mammal @enduml ``` -------------------------------- ### Notes on Messages Source: https://plantuml.com/es/sequence-diagram Place notes immediately after a message using 'note left' or 'note right'. Multi-line notes can be created using 'end note'. ```plantuml @startuml Alice->Bob : hello note left: this is a first note Bob->Alice : ok note right: this is another note Bob->Bob : I am thinking note left a note can also be defined on several lines end note @enduml ``` -------------------------------- ### Mindmap Detailed Node Styling with Width Constraints Source: https://plantuml.com/es/style Further customizes mindmap nodes with margin, maximum width, and shadowing. Also styles root nodes, leaf nodes, and arrows distinctly. ```plantuml @startmindmap * Hi =) * sometimes i have node in which i want to write a long text * this results in really huge diagram * of course, i can explicitly split with a\nnew line * but it could be cool if PlantUML was able to split long lines automatically, maybe with an option to specify the maximum width of a node @endmindmap ```