当我在shiny和sankeyNetwork(networkD3(中使用modalDialog时遇到问题。如果在应用程序中呈现sankeyNetwork,则不会出现modalDialog - 我只能看到灰色屏幕,但没有对话框窗口。
单击显示模态,当桑基Networ可见时
单击显示模式,当桑基网络不可见
显示下面描述的问题的应用程序示例。
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
的开发版本中得到解决,应尽快在 CRAN 上发布shiny v1.3.3
.