6

I was hoping for input on embedding Gantt charts into an R markdown file.

I'm using the Mermaid function in the DiagrammeR package to make Gantt charts. I'd like to have the different plots separated into tabs in the markdown file. However, the plots only display on the 1st tab. If I have a 2nd or 3rd tab, the content is blank, and I can't figure out why.

Here's some reproducible code:

---
title: "Gantt Charts!"
output: 
   html_document
---

```{r results = 'hide', message = FALSE, error = FALSE, echo = FALSE, warning = FALSE}
    
library(DiagrammeR) 

```

### Personnel {.tabset .tabset-pills}

#### Joe Bob
```{r, echo = FALSE}

mermaid("
                gantt
                dateFormat  YYYY-MM-DD
                title Joe Bob's Chart
                
                section Project
                Design              :active,        proj_1,    2017-05-10, 2017-05-17
                Implementation      :               proj_2,    2017-05-17, 2017-05-31
                
                ")
```

#### John Doe
```{r, echo = FALSE}

mermaid("
                gantt
                dateFormat  YYYY-MM-DD
                title John Doe's Chart
                
                section Test
                Analysis          :crit, active,        test_1,    2017-05-18, 2017-05-31
                Presentation      :active,              test_2,    2017-05-25, 2017-06-05
                
                ")
```

When I run the mermaid blocks of code independently, they both work. But for some reason, the plots don't render in the additional tabs. Does anyone know why and how to fix?

Thanks!

Julian
  • 6,586
  • 2
  • 9
  • 33
AlexP
  • 577
  • 1
  • 4
  • 15
  • 1
    You can open the html in browser, then turn on developer tools in firefox or chrome. There are some errors about negative values for `rect`. If you look at the two htmlwidgets that responsible for the two tabs with `document.getElementsByClassName("DiagrammeR");` in javascript console, you will see the second one have 0 as size. My guess is the 2nd tab is not visible in document init, so it didn't get proper size, and that didn't update after you switch the tab. This could be some bug in the interaction between `DiagrammeR` and `RMarkdown`. – dracodoc May 18 '17 at 14:19
  • Not sure what the problem is. Seems to work fine for me. Try updating to a beta build of RStudio. http://dailies.rstudio.com/ I'm running Version 1.1.211. – CoderGuy123 May 23 '17 at 01:36
  • Hmm strange. I updated to 1.1.211, but still had the same problem. Visible on the 1st tab, but blank on the 2nd one. – AlexP May 25 '17 at 13:15
  • You ever get this fixed? – LemenDrop Aug 06 '18 at 13:22

1 Answers1

0

I have ran your code, they work fine on my end. Please see the outcome below:

tab1 (tab 1)

tab2 (tab 2)

Grasshopper_NZ
  • 302
  • 1
  • 10