christophergandrud / networkD3

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

showModal does not pop up with renderSankeyNetwork in Shiny App. #216

Closed Sourabh1221 closed 5 years ago

Sourabh1221 commented 6 years ago

Hi,

I am developing a Shiny application which has two components Sankey Diagram and one action button which pop up "SaveMsg" dialog box on click of button .

I am seeing unexpected behavior where, If I user actionbutton and Sankeyvisualization in one dashboard, on click of action button, dashboard screen greyed out.

however If I comment Sankey code and keep only Action button on UI, Action button works as expected by showing pop up message of "save successfull". If I comment action button code and keep only Sankey code in UI, I am able to see sankey output on dashboard.

Sankey code and action button both are working as expected separately, however if I place both in one dashboard action button greyed outscreen dashboard screen.

I have also attached recreated sample code-

library(shiny)
library(networkD3)
library(shinydashboard)

value <-  c(12,21,41,12,81)
source <- c(4,1,5,2,1)
target <- c(0,0,1,3,3)
edges2 <- data.frame(cbind(value,source,target))

names(edges2) <- c("value","source","target")
indx  <- c(0,1,2,3,4,5)
ID    <- c('CITY_1','CITY_2','CITY_3','CITY_4','CITY_5','CITY_6')
nodes <-data.frame(cbind(ID,indx))

ui <- dashboardPage(
  dashboardHeader(
  ),
  dashboardSidebar(disable = TRUE),
  dashboardBody(
    fluidPage(
      actionLink("savebtn", "Save button")
      ,sankeyNetworkOutput("simple")
    )
  )
)

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

  observeEvent(input$savebtn, {
    showModal(modalDialog(
      title = "Save successful"))
  })

  output$simple <- renderSankeyNetwork({
    sankeyNetwork(Links = edges2, Nodes = nodes,
                  Source = "source", Target = "target",
                  Value = "value",  NodeID = "ID" 
                  ,units = "SSN" )
  })
}

shinyApp(ui = ui, server = server)
cjyetman commented 6 years ago

This is very likely the same problem as described in #214 and resolved in #215

Sourabh1221 commented 6 years ago

Hi cjyetman , Thanks for prompt response, Can you please confirm what action steps I have to take either in installing new package or to updating anything in Shiny D3NETWORK code. Thanks!!

cjyetman commented 6 years ago

At the moment, you would have to clone the repo and apply PR #215, then install the modified package. Otherwise, wait until PR #215 has been merged, and then you will be able to install the dev version with...

devtools::install_github("christophergandrud/networkD3")
cjyetman commented 5 years ago

Looks like this is/will be finally fixed upstream with https://github.com/rstudio/shiny/commit/3d117807ac4ffe14942e41edd8e8a5b364dc80a6

will close this issue once I have verified it

cjyetman commented 5 years ago

This issue has been resolved with the dev version of shiny and should be released on CRAN soon as shiny v1.3.3.