6

When I render the flexdashboard the plotly chart only shows on the first tab, and not on the remaining tabs. The reproducible example below uses the flexdashboard example for .tabset use. I am running R 3.6.1

I have used plotly and tabset in the past, and I am not sure why it is not working now.

---
title: "Tabset Column"
output: flexdashboard::flex_dashboard
---

Column 
-------------------------------------

### Chart 1

```{r}
library(ggplot2)
library(plotly)
library(dplyr)

da <-data.frame(ns=rep(0:1,6), month=factor(1:12), a=letters[1:12])

p <- ggplot(da) +
geom_bar(aes(x=month,y=ns,fill=ns),stat = "identity") +
facet_wrap(~a )+
theme_bw(12) + ylab("CYER") +
scale_fill_viridis_c(option="D",direction = -1) 


p2 <- ggplot(da) +
geom_bar(aes(x=month,y=ns,fill=ns),stat = "identity") +
facet_wrap(~a )+
theme_bw(12) + ylab("CYER") +
scale_fill_viridis_c(option="C",direction = -1) 
```

Column {.tabset}
-------------------------------------

### Chart 2

```{r}
ggplotly(p2)%>%layout(
 margin = list(b = 100, l = 100,r = 150))
```   

### Chart 3

```{r}
ggplotly(p)%>%layout(
 margin = list(b = 100, l = 100,r = 150))
```
wibeasley
  • 5,000
  • 3
  • 34
  • 62
  • I'm guessing this is a bug that should be mentioned on either the [flexboard repo](https://github.com/rstudio/flexdashboard/issues) or the [plotly repo](https://github.com/ropensci/plotly/issues). I see you've used flexboard's standard [tabset layout](https://rmarkdown.rstudio.com/flexdashboard/using.html) and are still getting the problem. One tip: when you create the issue, make this example a tad simpler. It fails with just `p <- ggplot(da) + geom_bar(aes(x=month,y=ns,fill=ns),stat = "identity")` as the plot (*ie*, no `p2`) and `plotly::ggplotly(p)` repeated for both charts 2 & 3. – wibeasley Nov 06 '19 at 23:29
  • An even simpler version fails too: use just one tabset column (so remove the left side), and use only one R chunk (within the 2nd tab). And it fails with both `orientation: rows` and `orientation: columns`. My team uses this (tabset + plotly) combination a lot, so if you don't file a bug, we will. If/when you do, will you please post a comment here that links to the GitHub Issue(s) you create? – wibeasley Nov 06 '19 at 23:44
  • I've created an issue at https://github.com/ropensci/plotly/issues/1652 that might help. My advice is to either drop the `fill`, or write the graph in plotly directly (ie, avoid `ggplotly()`). Or use regular ggplot2 (without plotly). – wibeasley Nov 07 '19 at 18:10
  • Thanks for opening the issue @wibeasley! I will follow that too. Thanks. – Catarina Wor Nov 08 '19 at 01:41
  • 2
    Someone pointed me to this related issue: https://github.com/ropensci/plotly/issues/1546 For now reverting back to version 4.8.0 of plotly worked - devtools::install_version("plotly", version = "4.8.0", repos = "http://cran.us.r-project.org") – Catarina Wor Nov 09 '19 at 00:41

0 Answers0