AdeelK93 / collapsibleTree

Create Interactive Collapsible Tree Diagrams in R using D3.js
https://adeelk93.github.io/collapsibleTree/
158 stars 41 forks source link

troubles plotting in shiny. #42

Open picousse opened 6 years ago

picousse commented 6 years ago

i have code that works in terminal. however if i want to put it in a shiny, the plots doesn't show.

ui.R file:

library(collapsibleTree)
iibrary(shiny)

ui <- fluidPage(

  # Application title
  titlePanel("Tree"),

  sidebarLayout(
    sidebarPanel(
      width = 2,
      textInput("tr", "tr (comma seperated): ", value = "xxxx", width = NULL, placeholder = NULL),

      actionButton(
        "tr_update",
        "Draw Tree",
        icon = NULL,
        width = NULL
      )

    ),
    mainPanel(
      collapsibleTreeOutput("d3", height = "700px")
    )
  )
)

server.r file


library(shiny)
library(inbioseR)
library(collapsibleTree)
require(data.tree)

# Define server logic required to draw a histogram
server <- function(input, output, session) {
  p <- eventReactive(input$tr_update, {

... code to create correct dataframe (which seems in order)    

t #final dataframe to return with a column, compare_str to be used as attribute

  })

  output$d3 <- renderCollapsibleTree({
    t <- p()
    collapsibleTreeNetwork(t,  collapsed = FALSE, linkLength=100, tooltipHtml = 'compare_str')
    })

}

why doesn't this show up?