如何在 flexdashboard 中创建一个 js 复选框? shinyTree 不起作用(R,闪亮)
How to create a js checkbox in flexdashboard? shinyTree does not work (R, shiny)
我在 flexdashboard 中使用 shinyTree 时遇到问题。在常规闪亮的应用程序中运行良好:
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)
但是,当我在 Flexdashboard 中使用它时,它 returns 一个空选项卡(请参阅此文件:https://mega.nz/file/DCozwIiJ#ttcBe581FPfhINVoczfBvaXhgRlXwVSu-wd2JhXTEEY)
您是否知道为什么会发生这种情况以及如何在 flexdashboard 中创建一个 js 树复选框?
jsTreeR
包比 shinyTree
包能做的更多。它适用于 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}
```
我在 flexdashboard 中使用 shinyTree 时遇到问题。在常规闪亮的应用程序中运行良好:
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)
但是,当我在 Flexdashboard 中使用它时,它 returns 一个空选项卡(请参阅此文件:https://mega.nz/file/DCozwIiJ#ttcBe581FPfhINVoczfBvaXhgRlXwVSu-wd2JhXTEEY)
您是否知道为什么会发生这种情况以及如何在 flexdashboard 中创建一个 js 树复选框?
jsTreeR
包比 shinyTree
包能做的更多。它适用于 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}
```