Giter Club home page Giter Club logo

jstree's Introduction

CRAN_Status_Badge Project Status: Active - The project has reached a stable, usable state and is being actively developed. downloads R-CMD-check pkgdown Coverage Status

jsTree

R htmlwidget for inspecting heirachal structures with the ‘jQuery’ ‘jsTree’ Plugin.

Installation

#install.packages('jsTree')
remotes::install_github('yonicd/jsTree')

Conventional Use

library(jsTree)
data(states)
data(state_bird)

collapse columns to text (with sep “/”)

nested_string <- apply(states,1,paste,collapse='/')
jsTree(nested_string)

Add tooltips to state names with the state bird

jsTree(nested_string,tooltips = state_bird)

initialize tree with checked boxes for certain fields

nodestate1 <- states$variable=='Area'
jsTree(nested_string,nodestate=nodestate1)
nodestate2 <- states$variable=='Area'&grepl('^M',states$state.name)
jsTree(nested_string,nodestate=nodestate2)
nodestate3 <- states$variable %in% c('Murder') & states$value >= 10
nodestate4 <- states$variable %in% c('HS.Grad') & states$value <= 55
jsTree(nested_string,nodestate=nodestate3|nodestate4)

change the order of the hierarchy

nested_string2 <- apply(states[,c(4,1,2,3,5)],1,paste,collapse='/')
jsTree(nested_string2)

Use other delimiters to define the heirarchy

nested_string <- apply(states,1,paste,collapse='|-|')
jsTree(nested_string,sep = '|-|')

Interacting with remote repositories

Preview a github repo without cloning it

remotes::install_github('yonicd/vcs')

#get repo master branch directory structure
  vcs::navigate_remote('tidyverse/ggplot2')

Search text in files of a repo without cloning it

jstree's People

Contributors

kchiabunnings avatar yonicd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jstree's Issues

remove '.' rood tree auto created

Hi @yonicd-
I have been playing around a lot the past 24 hours with your package and I was trying to figure out how to get rid of the root folder '.' created automatically please?
image

I don't create this root myself not sure why it is getting added.
Many thanks, Dylan

Expose jsTree plugin parameters

I noticed that you have marked exposing the custom icons as an enhancement. It would also be generally useful to have access to as many of the jsTree plugins as possible. For example, I would love to be able to use the three_state checkbox.

Thanks for this cool package!

custom icons support?

Hi - how could we use custom icons for the items/folders? Is there an example...
I saw a folder of themes? how could we pass with core options?

Catch jstree event in javascript

I know I can use shiny to catch events on the tree. Is it possible to do this just using Javascript with the jsTree htmlwidget?

I have tried to use the htmlwidgets package and appendContent, but I am not sure how to set up up the listener. The jsTree documentation shows how to do it in Javascript. Other widgets seem to insert a listener using a callback.

How do I disable Multi selection in jsTree Package in R Shiny

I am using jsTree in an R Shiny code for Hierarchical dropdowns and I need to disable the multi select option(Multi select is a default option in jsTree).

Please find the sample code snippet that I am using for this.

Region<-c("South","South","South","South","North","North","West","East","West","East")
State<-c("State1","State2","State2","State2","State3","State4","State5","State6","State7","State8")
City<-c("City1","City2","City3","City4","City5","City6","City7","City8","City9","City10")
superfundsite1=data.frame(Region,State,City)
myx10 <- apply(superfundsite1,1,function(x) paste(x,collapse = '/'))
jsTree(myx10)

1.0.3 version failed to render Tree in Shiny

Hi there- the 1.0.1 version from CRAN AND from GitHub of jsTree works fine with the example from the repo (pasted below):

library(jsTree)

ui <- shiny::fluidPage(
  shiny::column(width=4,jsTree::jsTreeOutput('tree')),
  shiny::column(width=8,shiny::uiOutput('chosen'))
)

server <- function(input, output,session) {
  network <- shiny::reactiveValues()
  shiny::observeEvent(input$tree_update,{
    current_selection <- input$tree_update$.current_tree
    if(!is.null(current_selection)) 
      network$tree <- jsonlite::fromJSON(current_selection)
  })
  
  shiny::observeEvent(network$tree,{
    output$results <- shiny::renderPrint({
      str.out <- ''
      if(length(network$tree)>0)
        str.out=network$tree
      return(str.out)
    })    
  })
  
  output$chosen <- shiny::renderUI({
    list(shiny::h3('Selected Items'),
         shiny::verbatimTextOutput(outputId = "results"))
  })
  
  output$tree <- jsTree::renderJsTree({
    nested_string <- apply(states,1,paste,collapse='/')
    jsTree(nested_string,browse = FALSE)
  })
}

shinyApp(ui, server)

But it does lack of some further support fore more arguments such as 'core' newly introduced. However the 1.0.3 version installed from GitHub failed to render. The Rstudio show the HTML widget in viewer but not in the we app itself.
image

The error I have in the shiny app is:
image

Listening on http://127.0.0.1:5618
Warning: Error in : $ operator is invalid for atomic vectors
  78: origRenderFunc
  77: output$tree
   1: runApp

SessionInfo is:
sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server >= 2012 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] jsTree_1.0.3 shiny_1.0.5.9000

loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 crayon_1.3.4 digest_0.6.15 later_0.7.1.9000 mime_0.5 R6_2.2.2 xtable_1.8-2 jsonlite_1.5
[9] magrittr_1.5 rlang_0.2.0 rstudioapi_0.7 data.table_1.11.0 promises_1.0.1 tools_3.4.4 htmlwidgets_1.2 httpuv_1.4.1.9000
[17] yaml_2.1.18 compiler_3.4.4 htmltools_0.3.6

conflict with shinyDashboard css nav

To allow the navigation bar in shinyDashboard to work correctly there is a css conflict.
I've had to use the following when coupling shinyDashboard which also has "nav" in the dom

dashboardBody(
tags$style(HTML('
nav {
float: none !important;
padding: 0 !important;
max-width: none !important;
} '))

otherwise it will cause the navigation bar to be skewed ; perhaps in the css and object nav could be called something more unique due to the conflict with shinyDashboard?

plugins_api do not render tree anymore

Hi @yonicd , sorry I could test the plugins_api banch earlier but I upgraded this morning and this is not working anymore:

data(states)
data(state_bird)
#collapse columns to text (with sep "/")
nested_string <- apply(states,1,paste,collapse='/')
jsTree(nested_string)

image

prevent child nodes to be selected when clicking on parents

Hi @yonicd , thanks very much for your support on this.
There is not final thing I wanted to discuss with you: the fact that when clicking on the parent note, all the childrens get also selected while I did use core = list(multiple = FALSE).
How can I make sure that you can only select the deeper node and making impossible selection of parent ?

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.