mattflor / chorddiag

R interface to D3 chord diagrams
159 stars 44 forks source link

Issue when using chorddiag with collapsibleTree #25

Open rpouillot opened 6 years ago

rpouillot commented 6 years ago

Hi,

Thank you for your package. I have an issue, though, while using the chorddiag and the collapsibleTree packages in the same shiny app. Here is a minimal example. The chord Diagram will not draw, except if I comment out the line collapsibleTreeOutput("tree"). Note that the two graphs use D3.js

Could you have a look? Thank you. R.

library(shiny)
library(chorddiag)
library(collapsibleTree)

# Server logic
ui <-   fluidPage(
  h5("The graph should be here"),
  chorddiagOutput("chordDiagram"),
  h5("The graph should be here"),
# The chord diagram is drawn only if I comment out the following line
  collapsibleTreeOutput("tree"),
  hr()

)

server <- function(input, output) {
  output$chordDiagram <- renderChorddiag({  

    m <- matrix(c(11975,  5871, 8916, 2868,
                  1951, 10048, 2060, 6171,
                  8010, 16145, 8090, 8045,
                  1013,   990,  940, 6907),
                byrow = TRUE,
                nrow = 4, ncol = 4)
    groupnames <- c("black", "blonde", "brown", "red")
    row.names(m) <- groupnames
    colnames(m) <- groupnames
    chorddiag(m)

  })

  output$tree <- renderCollapsibleTree(
    collapsibleTree(warpbreaks, c("wool", "tension"))
  )

}

shinyApp(ui, server)

Note: I use ‘collapsibleTree’ version 0.1.7 ‘shiny’ version 1.1.0 ‘chorddiag’ version 0.1.2 R version 3.5.0