I have a problem with using shinyTree in flexdashboard. In a regular shiny app works well:
library(shiny)
library(shinyTree)
server <- function(input, output) {
output$tree <- renderTree({
opciones = list('All'= list(
'Human' = structure(list('OP1'='OP1', 'OP2'='OP2'),stopened=TRUE),
'Mouse' = structure(list('OP3'='OP3'), stopened=TRUE)))
attr(opciones[[1]],"stopened")=TRUE
opciones
})
}
ui <- fluidPage(
shinyTree("tree", checkbox = "TRUE")
)
shinyApp(ui = ui, server = server)
However, when I use it in Flexdashboard, it returns an empty tab (see this file: https://mega.nz/file/DCozwIiJ#ttcBe581FPfhINVoczfBvaXhgRlXwVSu-wd2JhXTEEY)
Do you have any idea why this could be happening and how to create a js tree checkbox in flexdashboard?
The jsTreeR
package can do more than the shinyTree
package. And it works fine with flexdashboard
:
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(jsTreeR)
```
```{r}
nodes <- list(
list(
text = "RootA",
data = list(value = 999),
icon = "far fa-moon red",
children = list(
list(
text = "ChildA1",
icon = "fa fa-leaf green"
),
list(
text = "ChildA2",
icon = "fa fa-leaf green"
)
)
),
list(
text = "RootB",
icon = "far fa-moon red",
children = list(
list(
text = "ChildB1",
icon = "fa fa-leaf green"
),
list(
text = "ChildB2",
icon = "fa fa-leaf green"
)
)
)
)
output[["jstree"]] <- renderJstree({
jstree(nodes, dragAndDrop = TRUE, checkboxes = TRUE, theme = "proton")
})
output[["treeSelected"]] <- renderPrint({
input[["jstree_selected"]]
})
```
Column {data-width=400}
-----------------------------------------------------------------------
### Checkbox tree
```{r}
jstreeOutput("jstree")
```
Column {data-width=400}
-----------------------------------------------------------------------
### Selected nodes
```{r}
verbatimTextOutput("treeSelected")
```
### Chart C
```{r}
```