I'm using mermaid diagrams in my Rmd reports compiled with Rstudio. In the HTML/PDF output, there is a lot of blank space above and below the charts, see example below.
# Header
Text
```{r}
library(DiagrammeR)
mermaid("
graph TD
classDef style_main_node fill:orange,stroke:#333,stroke-width:0px;
classDef style_sub_node fill:lightgray,stroke:#333,stroke-width:0px;
0(Top)
0 --> A1(Left)
0 --> B1(Center)
0 --> C1(Right)
class 0 style_main_node;
class A1,B1,C1 style_sub_node;
")
```
Text
Is there a way to crop off/adjust the white space around the graph? And possibly also to change its size?
Just specify height and width around diagram with: height = '100%', width = '100%'
# Header
Text
```{r}
library(DiagrammeR)
mermaid("
graph TD
classDef style_main_node fill:orange,stroke:#333,stroke-width:0px;
classDef style_sub_node fill:lightgray,stroke:#333,stroke-width:0px;
0(Top)
0 --> A1(Left)
0 --> B1(Center)
0 --> C1(Right)
class 0 style_main_node;
class A1,B1,C1 style_sub_node;
", height = '100%', width = '100%')
```
Text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With