我编写了代码(使用闪亮),它创建了一个由许多 selectizeInputs 和一个节点网络(visNetwork)组成的 absolutePanel。当从下拉列表之一中选择一个选项时,将突出显示特定节点。目前,如果您单击画布并取消选择节点,下拉列表将重置(使用 updateSelectizeInput)。但是,如果您重复此过程,下拉列表不会重置。为什么下拉列表只在第一次点击时重置?我在下面包含了我的一些代码。
任何帮助将非常感激。
server <- function(input, output, session) {
output$network_proxy_select <- renderVisNetwork({
visNetwork(nodes, edges) %>%
visNodes(font = list(face = "arial,sans-serif")) %>%
visOptions(highlightNearest = list(enabled = TRUE, degree = 0)) %>%
visInteraction(navigationButtons = FALSE, keyboard = TRUE) %>%
visPhysics(stabilization = FALSE) %>%
visEvents(type="on", click = "function(properties){
Shiny.onInputChange('click', properties.nodes);
;}")
})
observe({
if(is.null(input$click)) {
updateSelectizeInput(session, "sel1", selected="")
updateSelectizeInput(session, "sel2", selected="")
updateSelectizeInput(session, "sel3", selected="")
updateSelectizeInput(session, "sel4", selected="")
updateSelectizeInput(session, "sel5", selected="")
updateSelectizeInput(session, "sel6", selected="")
}
})
...
}
ui <- fluidPage(
sidebarLayout(
absolutePanel(top=20, left=20, height="auto", width="auto", draggable=FALSE,
selectizeInput(inputId = "sel1", selected="", choices = c("", ...), multiple = FALSE, width="500px"),
selectizeInput(inputId = "sel2", selected="", choices = c("", ...), multiple = FALSE, width="500px"),
selectizeInput(inputId = "sel3", selected="", choices = c("", ...), multiple = FALSE, width="500px"),
selectizeInput(inputId = "sel4", selected="", choices = c("", ...), multiple = FALSE, width="500px"),
selectizeInput(inputId = "sel5", selected="", choices = c("", ...), multiple = FALSE, width="500px"),
selectizeInput(inputId = "sel6", selected="", choices = c("", ...), multiple = FALSE, width="500px")
),
mainPanel(visNetworkOutput("network_proxy_select", height="900px"), width="auto")
)
)
shinyApp(ui = ui, server = server)