我希望基于单击actionButton来渲染和重新渲染simpleNetwork图形。但是,出于某种原因,多次单击该按钮不会创建新的simpleNetwork实例,而是似乎使用缓存版本。如何通过多次点击让simpleNetwork图表完全重新渲染?
我在下面列举了一个例子以及问题的GIF:
library(shiny)
library(networkD3)
server <- function(input, output, session) {
data <- eventReactive(input$click, {
src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
networkData <- data.frame(src, target)
})
output$simple <- renderSimpleNetwork({
simpleNetwork(data())
})
}
ui <- fluidPage(titlePanel("networkD3 + Shiny"),
sidebarLayout(
sidebarPanel(actionButton("click", "Render")),
mainPanel(simpleNetworkOutput(
"simple", width = "100%", height = "700px"
))
))
shinyApp(ui = ui, server = server)