Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-07T07:53:07.000Z (over 1 year ago)
- Last Synced: 2024-05-21T02:10:42.057Z (6 months ago)
- Language: R
- Size: 197 KB
- Stars: 40
- Watchers: 4
- Forks: 7
- Open Issues: 6
-
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.
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![R-CMD-check](https://github.com/dreamRs/shinytreeview/actions/workflows/R-CMD-check.yaml/badge.svg)](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 :
![](man/figures/example-treeview.png)
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 :
![](man/figures/example-treecheck.png)
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/`.