我在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)
也许有人对为什么会发生这种情况以及可能的解决方法有所了解。在我的用例中,我使用多个进度条,如果包含流程图,则不会显示任何进度条。
谢谢, 基督徒
答案 0 :(得分:0)
我很确定这与networkD3
如何在sankeyNetwork()
中启用多行工具提示有关。/p>
请参阅... https://github.com/christophergandrud/networkD3/issues/250
更新(2019-05-20)
shiny
的开发版本已解决了该问题,应尽快在shiny v1.3.3
的CRAN上发布。