christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
649 stars 270 forks source link

conflict of networkD3 and d3treeR on shiny #261

Closed dingying85 closed 5 years ago

dingying85 commented 5 years ago

Dear developer,

I found when a conflict between the networkD3 and d3treeR, below is a reproducible example: library(shiny) library(plotly) library(networkD3) library(treemap) library(d3treeR) ui <- fluidPage( plotlyOutput("p"), forceNetworkOutput("o"), d3treeOutput("a") )

server <- function(input, output, session) {

output$p <- renderPlotly({ ds <- data.frame(labels = c("A", "B", "C"), values = c(10, 40, 60)) plot_ly(ds, labels = ~labels, values = ~values) %>% add_pie() %>% layout(title = "Basic Pie Chart using Plotly") })

output$o <- renderForceNetwork({ forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.4, zoom = TRUE)

})

output$a <- renderD3tree({ data(GNI2014)

tm <- treemap( GNI2014, index=c("continent", "iso3"), vSize="population", vColor="GNI", type="value" )

d3tree( tm,rootname = "World" ) })

}

shinyApp(ui, server)

cjyetman commented 5 years ago

see #162

in short d3treeR uses v3 of D3 while networkD3 uses v4 and they are not compatible in many ways