Skip to content

Wandrys-dev/shinytreeview

 
 

Repository files navigation

shinytreeview

Hierarchical tree structures input for Shiny applications. Interface for bootstrap-treeview JS library.

Lifecycle: experimental R build status

Installation

Install the development version from GitHub with:

remotes::install_github("dreamRs/shinytreeview")

Example

treeviewInput() allow to select a value (or several) in a hierarchical structure :

Code for this example:

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:

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} to manage JavaScript assets, see packer's documentation for more.

Install nodes modules with:

packer::npm_install()

Modify srcjs/inputs/treeview.js, then run:

packer::bundle()

Re-install R package and try demo applications in examples/.

About

Hierarchical tree input for Shiny apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 54.9%
  • JavaScript 44.6%
  • CSS 0.5%