如果使用 sankeyNetwork (networkD3),则不会出现 modalDialog

modalDialog doesn`t appear if sankeyNetwork (networkD3) is used

我在 shiny 和 sankeyNetwork (networkD3) 中使用 modalDialog 时遇到问题。如果 sankeyNetwork 在应用程序中呈现,则 modalDialog 不会出现 - 我只能看到灰色屏幕但没有对话框 window.

Click Show Modal when sankeyNetwor is visible

Click Show Modal when sankeyNetwork is not visible

显示下面所述问题的应用程序示例。

library(shiny)
library(networkD3)

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

  observeEvent(input$show_modal,{
    showModal(modalDialog(
      title = NULL, size = "m",
      h4("Test Window"),
      footer = NULL, easyClose = T
    ))
  })

  output$sankey <- renderSankeyNetwork({
    nodes<-data.frame(
      name=paste0(rep("opt",9),seq(1,9)), stringsAsFactors = F)

    links<-data.frame(
      source=c(0,0,0,1,1,2,2,3,4,4,5,6),
      target=c(4,5,6,5,6,4,6,6,7,8,7,8),
      value=c(2,3,5,1,2,3,1,6,1,3,7,4))

    quest<-list(nodes=nodes, links=links)
    sankeyNetwork(Links = quest$links, Nodes = quest$nodes, Source = "source",
                  Target = "target", Value = "value", NodeID = "name",
                  units = "opt", fontSize = 16, nodeWidth = 30, iterations = 2, sinksRight = T)
  })

  output$show_sankey<-renderUI({
    if(input$show_sankeyNetwork_box) sankeyNetworkOutput('sankey')
  })

}

ui <- fluidPage(titlePanel("Modaldialog + sankeyNetwork (networkD3) Problem"),
                sidebarLayout(
                  sidebarPanel(
                    actionButton("show_modal", "Show modal"),
                    checkboxInput('show_sankeyNetwork_box', "Show sankeyNetwork", value = F)),
                  mainPanel(
                    uiOutput('show_sankey'))
                ))

shinyApp(ui = ui, server = server)

你知道如何处理这个问题吗?

谢谢!

巴尔泰克

此问题已在 shiny 的开发版本中得到解决,应该会在 shiny v1.3.3 后尽快在 CRAN 上发布。