Bug using Shiny dateRangeInput and sankey network diagrams from networkD3?


#1

I’ve got a Shiny dashboard that lets a user provide a set of inputs. One of the inputs asks for a range of dates using dateRangeInput. After choosing all the inputs and pressing an action button a couple sankey network diagrams will display using the networkD3 package. However once the sankey network diagrams display, the dateRangeInput doesn’t work properly and the calendar will freeze when it pops up. I’m including a reproducible example of code below. You should just need shiny, shinydashboard, and networkD3 to reproduce it. Click on the date range and you’ll see the issue I’m talking about. I haven’t figured out a solution to this.

# Setup =================================
# Load Packages
library(networkD3)
library(shiny)
library(shinydashboard)


# UI =================================
ui = dashboardPage(
  dashboardHeader(title = "Title"),
  # UI Sidebar =================================
  dashboardSidebar(
    sidebarMenu(
      dateRangeInput(inputId = "dates",
                     label = "Select time period:",
                     start = "2000-01-01",
                     end = "2018-02-01",
                     min = "2000-01-01",
                     max = "2018-02-01",
                     format = "mm-yyyy")
    )
  ),
  # UI Body =================================
  dashboardBody(
    fluidRow(
      box(sankeyNetworkOutput(outputId = "sankey_diagram"), 
          width = 12)
            )
    )
)

# Server =================================
server = function(input, output, session){
  # Render sankey diagram =================================
  output$sankey_diagram = renderSankeyNetwork({
    
    
    t1 = data.frame(source = c(0,0,
                              1,1),
                   target = c(2,3,
                              2,3),
                   value = c(100, 25,
                             10, 20))
    
    t2 = data.frame(id = c(0,1,2,3),
                      name = c("Group 1", "Group 2", 
                               "Group 3", "Group 4"))
    
    s = sankeyNetwork(Links = t1,
                      Nodes = t2,
                      Source = "source",
                      Target = "target",
                      Value = "value",
                      NodeID = "name",
                      NodeGroup = "name",
                      fontSize = 12,
                      nodeWidth = 30,
                      iterations = 0,
                      colourScale = JS("d3.scaleOrdinal(d3.schemeCategory10);"))
    return(s)
    
  }) 
}
# Run Shiny App =================================
shinyApp(ui, server)```

#2

This is a known issue. There's a PR that fixes this, but we haven't had time to vet it and merge it, much less put together a new release. I'm hoping to get that done in the next couple months.