我对 Shiny 中的进度条和包networkD3
有一些问题。进度条显示正常,无需尝试从该包呈现图表。如果尝试使用进度条和networkD3
包,该进度条将显示一次,但不会在后续调用中显示。我在Chrome中进行了测试。下面是一个最低示例代码:
require(shinyjs)
require(shiny)
require(networkD3)
require(jsonlite)
ui <- function(){
fluidPage(
fluidRow(
column(width = 12, style = "margin: 0px; padding: 0px;",
box(title = "Flow Diagram", status = "primary", solidHeader = F, width = 7,
sankeyNetworkOutput("sankeyFlow", width = "100%", height = "500px")
)
),
sliderInput("numLanes", label = "Number of Top Lanes", min = 0, max = 30, value = 10)
)
)
}
server <- function(input, output, session) {
observeEvent(c(input$numLanes), {
withProgress(message = "Wait...", value = NULL, {
Sys.sleep(1.0)
})
})
output$sankeyFlow <- renderSankeyNetwork({
print("sankey")
withProgress(message = "Updating flow diagram...", value = NULL, {
# Load energy projection data
URL <- "https://cdn.rawgit.com/christophergandrud/networkD3/master/JSONdata/energy.json"
Energy <- jsonlite::fromJSON(URL)
nLanes <- input$numLanes
plot <- sankeyNetwork(Links = Energy$links, Nodes = Energy$nodes, Source = "source",
Target = "target", Value = "value", NodeID = "name",
units = "TWh", fontSize = 12, nodeWidth = 30)
return(plot)
})
})
}
shinyApp(ui = ui, server = server)
也许有人对发生这种情况的原因和可能的解决方法有一些见解。在我的用例中,我使用了几个进度条,如果我包含流程图,则不会显示任何进度条。
谢谢基督教
确定这与networkD3
如何在sankeyNetwork()
中启用多行的工具提示存在冲突/错误。
看。。。https://github.com/christophergandrud/networkD3/issues/250
更新 (2019-05-20(
此问题已在 shiny
的开发版本中得到解决,应尽快在 CRAN 上发布 shiny v1.3.3
.