# NOT RUN {
library(shiny)
nodes <- sg_make_nodes()
nodes$new_color <- "red"
edges <- sg_make_edges(nodes)
ui <- fluidPage(
actionButton("start", "Change color"),
sigmajsOutput("sg")
)
server <- function(input, output){
output$sg <- renderSigmajs({
sigmajs() %>%
sg_nodes(nodes, id, size, color) %>%
sg_edges(edges, id, source, target)
})
observeEvent(input$start, {
sigmajsProxy("sg") %>% # use sigmajsProxy!
sg_change_nodes_p(nodes, new_color, "color")
})
}
if(interactive()) shinyApp(ui, server) # run
# }
Run the code above in your browser using DataLab