inst/shiny/src/server/proxy_nodes_server.R

output$network_proxy_nodes <- renderVisNetwork({
  # minimal example
  nodes <- data.frame(id = 1:3)
  edges <- data.frame(from = c(1,2), to = c(1,3))
  
  visNetwork(nodes, edges)%>%
    visNodes(color = "blue", size = 20)
})

observe({
  visNetworkProxy("network_proxy_nodes") %>%
    visNodes(color = input$color, size = input$size, shadow = input$shadow) %>%
    visEdges(dashes = input$dashes, smooth = input$smooth)
})

# observe({
#   visNetworkProxy("network_proxy_nodes") %>%
#     visSetOptions(options = list(nodes = list(color = input$color, size = input$size, shadow = input$shadow),
#     edges = list(dashes = input$dashes, smooth = input$smooth)))
# })

output$code_proxy_nodes  <- renderText({
  '
output$network_proxy_nodes <- renderVisNetwork({
  # minimal example
  nodes <- data.frame(id = 1:3)
  edges <- data.frame(from = c(1,2), to = c(1,3))
  
  visNetwork(nodes, edges)
})
  
observe({
  visNetworkProxy("network_proxy_nodes") %>%
  visNodes(color = input$color, size = input$size, shadow = input$shadow) %>%
  visEdges(dashes = input$dashes, smooth = input$smooth)
})

# same directly with visSetOptions :
observe({
  visNetworkProxy("network_proxy_nodes") %>%
  visSetOptions(options = list(nodes = list(color = input$color, size = input$size, shadow = input$shadow),
  edges = list(dashes = input$dashes, smooth = input$smooth)))
})
 '
})
datastorm-open/visNetwork documentation built on Dec. 3, 2022, 8:50 p.m.