Description Usage Arguments Examples
Change nodes and edges attributes on the fly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | sg_change_nodes_p(
proxy,
data,
value,
attribute,
rate = c("once", "iteration"),
refresh = TRUE
)
sg_change_edges_p(
proxy,
data,
value,
attribute,
rate = c("once", "iteration"),
refresh = TRUE
)
|
proxy |
An object of class |
data |
|
value |
Column containing value. |
attribute |
Name of attribute to change. |
rate |
Rate at chich to refresh takes |
refresh |
Whether to refresh the graph after the change is made. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.