# NOT RUN {
library(shiny)
ui <- fluidPage(
actionButton("add", "add nodes & edges"),
sigmajsOutput("sg")
)
server <- function(input, output, session){
output$sg <- renderSigmajs({
sigmajs()
})
observeEvent(input$add, {
nodes <- sg_make_nodes(50)
nodes$batch <- c(
rep(1000, 25),
rep(3000, 25)
)
edges <- data.frame(
id = 1:80,
source = c(
sample(1:25, 40, replace = TRUE),
sample(1:50, 40, replace = TRUE)
),
target = c(
sample(1:25, 40, replace = TRUE),
sample(1:50, 40, replace = TRUE)
),
batch = c(
rep(1000, 40),
rep(3000, 40)
)
) %>%
dplyr::mutate_all(as.character)
sigmajsProxy("sg") %>%
sg_force_start_p() %>%
sg_read_delay_nodes_p(nodes, id, color, label, size, delay = batch) %>%
sg_read_delay_edges_p(edges, id, source, target, delay = batch) %>%
sg_read_delay_exec_p() %>%
sg_force_stop_p()
})
}
if(interactive()) shinyApp(ui, server)
# }
Run the code above in your browser using DataLab