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

时间:2018-05-19 17:21:34

标签: r shiny modal-dialog networkd3

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

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)

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

谢谢!

鲍尔泰克

1 个答案:

答案 0 :(得分:0)

shiny的开发版本已解决了该问题,应尽快在shiny v1.3.3的CRAN上发布。