Hi,
I have some issues with progress bars in Shiny and the package networkD3. The progress bar shows up fine without trying to render a diagram from that package. If try to use a progress bar and the networkD3 package, the bar shows up once but not in subsequent calls. I tested in Chrome. Here is a minimum example code:
require(shinyjs)
require(shiny)
require(networkD3)
require(jsonlite)
require(shinydashboard)
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)
Maybe someone has some insight on why this is happening and a possible workaround. In my use case I use several progress bars and none are displayed if I include the flow diagram.