Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal ShinyTree #62

Open
prabhjot0509 opened this issue Mar 4, 2019 · 3 comments
Open

Horizontal ShinyTree #62

prabhjot0509 opened this issue Mar 4, 2019 · 3 comments

Comments

@prabhjot0509
Copy link

Hi,

Is there an option make the ShinyTree horizontal. For example, we have a hierarchial data, the tree in horizontal layout would look much better than the current vertical layout.

Thanks!

@trafficonese
Copy link
Contributor

trafficonese commented Mar 4, 2019

This CSS should do it:

.jstree-node {
        display: inline !important;
    }

Full Shiny Example:

library(shiny)
library(shinyTree)

dt <- list(
  root1 = structure("123",stinfo="A"),
  root2 = list(
    SubListA = list(leaf1 = structure("leaf1",stinfo="B"), leaf2 = "", leaf3=""),
    SubListB = list(leafA = "", leafB = "")
  )
)

ui <- fluidPage(
  tags$head(tags$style(
    "
    .jstree-node {
        display: inline !important;
    }
    "
  )),
  shinyTree("tree")
)

server <- function(input, output, session) {
  output$tree <- renderTree({
    dt
  })
}

shinyApp(ui, server)

@prabhjot0509
Copy link
Author

Thank you so much for such a quick response.

It is really good to know that we can change the alignment according to our need. I was in particular looking for a tree like structure wherein Root 1 is in the first row, then Root2 in second and so on. I am looking for something like the image in the question below:

https://stackoverflow.com/questions/9238672/how-does-a-script-optimally-layout-a-pure-hierarchical-graphviz-dot-graph

Would be really helpful if someone can help to bring the graph in this particular format. I am new to scripting so my questions might sound to be very basic.

Thanks for your help!

@trafficonese
Copy link
Contributor

This will be a bit more complicated and jsTree does not support such structures. Maybe you could fiddle around with some CSS to model the tree to your desire.

But you could/should also check out other packages, which are maybe better suited for this task:

collapsibleTree
data.tree
ggraph
networkD3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants