https://github.com/dreamRs/shinytreeview
Hierarchical tree input for Shiny apps
https://github.com/dreamRs/shinytreeview
Last synced: 3 months ago
JSON representation
Hierarchical tree input for Shiny apps
- Host: GitHub
- URL: https://github.com/dreamRs/shinytreeview
- Owner: dreamRs
- License: gpl-3.0
- Created: 2020-05-05T14:37:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-01T07:10:19.000Z (8 months ago)
- Last Synced: 2024-08-06T03:04:03.330Z (7 months ago)
- Language: R
- Size: 199 KB
- Stars: 41
- Watchers: 4
- Forks: 8
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- jimsghstars - dreamRs/shinytreeview - Hierarchical tree input for Shiny apps (R)
README
# shinytreeview
> Hierarchical tree structures input for Shiny applications. Interface for [bootstrap-treeview](https://github.com/patternfly/patternfly-bootstrap-treeview) JS library.
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://github.com/dreamRs/shinytreeview/actions/workflows/R-CMD-check.yaml)## Installation
Install the development version from GitHub with:
```r
remotes::install_github("dreamRs/shinytreeview")
```## Example
`treeviewInput()` allow to select a value (or several) in a hierarchical structure :

Code for this example:
```r
library(shiny)
library(shinytreeview)data("cities")
ui <- fluidPage(
tags$h3("treeviewInput cities example"),
treeviewInput(
inputId = "tree",
label = "Choose a city:",
choices = make_tree(
cities, c("continent", "country", "city")
),
multiple = FALSE,
prevent_unselect = TRUE,
width = "100%"
),
verbatimTextOutput(outputId = "result")
)server <- function(input, output, session) {
output$result <- renderPrint({
input$tree
})
}if (interactive())
shinyApp(ui, server)
````treecheckInput()` allow to check a value (or several) in a hierarchical structure :

Code for this example:
```r
library(shiny)
library(shinytreeview)data("cities")
ui <- fluidPage(
tags$h3("treeviewInput cities example"),
treecheckInput(
inputId = "tree",
label = "Choose a city:",
choices = make_tree(
cities, c("continent", "country", "city")
),
width = "100%"
),
verbatimTextOutput(outputId = "result")
)server <- function(input, output, session) {
output$result <- renderPrint({
input$tree
})
}if (interactive())
shinyApp(ui, server)
```## Development
This package use [{packer}](https://github.com/JohnCoene/packer) to manage JavaScript assets, see packer's [documentation](https://packer.john-coene.com/#/) for more.
Install nodes modules with:
```r
packer::npm_install()
```Modify `srcjs/inputs/treeview.js`, then run:
```r
packer::bundle()
```Re-install R package and try demo applications in `examples/`.