View source: R/drawio_engine.R
drawio.engine | R Documentation |
This function is called by knitr when a code chunk's engine is set
to drawio
.
This engine uses the draw.io software to export diagrams to images,
and outputs the image into the RMarkdown document.
drawio.engine(options)
options |
The chunk options. Please refer to the official knitr
documentation for more details on these. Several important options for
this package are also described in the documentation of
|
This function should normally not be used directly by the user, but rather called by knitr to process chunks.
It is recommended to set the label
chunk option with a meaningful
value, as it is used to name the resulting image in the file system.
For a list of accepted options to control the export process, please see
parse.options
.
Two additional options are used in this function:
If set to FALSE
, the engine will not execute the
code chunk. The diagram will neither be exported nor rendered in the
document. (Default: TRUE
)
If set to FALSE
, the engine will execute the
code chunk (the diagram will therefore be exported), but the result will
not be rendered in the document. This is useful if you want to
automatically export a diagram but manually use it. (Default: TRUE
)
In a RMarkdown document, type out the following chunks.
Simple chunk with a label ("my-diag1"), and a source file ("diag1.drawio"):
```{drawio my-diag1, src="diag1.drawio"} ```
Setting the output format:
```{drawio my-diag2, src="diag2.drawio", format="pdf"} ```
A few more options, not cropping the result (i.e., the image has the same size as the diagram), using a transparent background, and only exporting the 4th page of the diagram:
```{drawio my-diag3, src="diag3.drawio", format="pdf", crop=FALSE, transparent=TRUE, page.index=4} ```
Setting the options manually with engine.opts
:
```{drawio my-diag4, src="diag4.drawio", engine.opts="--embed-diagram --transparent", format="pdf"} ```
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.