knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  cache = FALSE
)

Register the plantuml knitr engine

The plantuml knitr engine plantuml_knit_engine() needs to be registered with knitr. This is done automatically when loading the package plantuml.

library(plantuml)

PlantUML Code Chunk Options

The following options are available, in addition to the standard options:

A simple chart as png

A png grph is nice, because it can be shown in all kinds of documents, including html, pdf and docx. But it is a bitmap format, i.e. when scaling in the grapoh becomes pixelated. ```{plantuml diagram_png, eval = TRUE, echo = FALSE, plantuml.format = "png", plantuml.path = "graphs", plantuml.preview = TRUE} left to right direction actor "Food Critic" as fc package Restaurant { usecase "Eat Food" as UC1 usecase "Pay for Food" as UC2 usecase "Drink" as UC3 } fc --> UC1 fc --> UC2 fc --> UC3

## A simple chart as png and with code
To also show the plantuml code, you have to set `echo = TRUE`:
```{plantuml diagram_png_code, eval = TRUE, echo = TRUE, plantuml.format = "png", plantuml.path = "graphs"}
left to right direction
actor "Food Critic" as fc
package Restaurant {
  usecase "Eat Food" as UC1
  usecase "Pay for Food" as UC2
  usecase "Drink" as UC3
}
fc --> UC1
fc --> UC2
fc --> UC3

A simple chart using format auto with code

When specifying plantuml.format = "auto" the apropriate vector format is chosen for the output format:

Therefore, the vector format appropritw for the output format is is chosen for the output format.

```{plantuml diagram_svg, eval = TRUE, plantuml.format = "auto", plantuml.path = "graphs"} robust "DNS Resolver" as DNS robust "Web Browser" as WB concise "Web User" as WU

@0 WU is Idle WB is Idle DNS is Idle

@+100 WU -> WB : URL WU is Waiting WB is Processing

@+200 WB is Waiting WB -> DNS@+50 : Resolve URL

@+100 DNS is Processing

@+300 DNS is Idle

## Now only the code
```{plantuml code, eval = FALSE, plantuml.format = "png", plantuml.path = "graphs"}
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: Another authentication Response
@enduml

And now as ASCII Art

This does not play nicely with LaTeX and therefore pdf due to unicode characters used. I have no idea at the moment how to make this nicer. ```{plantuml asciiart, eval = TRUE, plantuml.format = "txt", plantuml.path = "graphs", comment = ""} @startuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request Alice <-- Bob: Another authentication Response @enduml ```



rkrug/plantuml documentation built on June 3, 2023, 6:24 a.m.