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

Vertical layout #7

Closed
sinacek opened this issue Mar 10, 2017 · 3 comments
Closed

Vertical layout #7

sinacek opened this issue Mar 10, 2017 · 3 comments

Comments

@sinacek
Copy link

sinacek commented Mar 10, 2017

Hi,
thank you a lot for this shiny widget! I would like ask you if you have in plan add there option for vertical layout of tree?
The second question is if can widget also return id or name of the last clicked node (collapsed/expanded)

Thanks a lot for response
Frantisek

@yonicd
Copy link
Owner

yonicd commented Mar 10, 2017

both options added.

  • New shiny observer 'activeNode' added to return meta data of last clicked node. (full example app see here)

Server Side

  observeEvent(input$d3_update,{
    activeNode<-input$d3_update$.activeNode
    if(!is.null(activeNode)) network$click <- jsonlite::fromJSON(activeNode)
  })
  
  observeEvent(network$click,{
    output$clickView<-renderTable({
      as.data.frame(network$click)
    },caption='Last Clicked Node',caption.placement='top')
  })
  

UI Side

  tableOutput("clickView")
  • give option to grow a horizontal tree (default) and a vertical tree
    #horizontal(default)
    d3tree(list(root = df2tree(rootname = 'Titanic',struct = as.data.frame(Titanic),toolTip = letters[1:5]),
    layout = 'collapse'))
    
    #vertical
    d3tree(list(root = df2tree(rootname = 'Titanic',struct = as.data.frame(Titanic),toolTip = letters[1:5]),
    layout = 'collapse'),direction = 'v')
    

@yonicd yonicd closed this as completed Mar 10, 2017
@sinacek
Copy link
Author

sinacek commented Mar 10, 2017

@yonicd
Copy link
Owner

yonicd commented Mar 10, 2017

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

No branches or pull requests

2 participants