Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

change

Change


Description

Change nodes and edges attributes on the fly

Usage

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
)

Arguments

proxy

An object of class sigmajsProxy as returned by sigmajsProxy.

data

data.frame holding delay column.

value

Column containing value.

attribute

Name of attribute to change.

rate

Rate at chich to refresh takes once refreshes once after all values have been changed, and iteration which refreshes at every iteration.

refresh

Whether to refresh the graph after the change is made.

Examples

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

sigmajs

Interface to 'Sigma.js' Graph Visualization Library

v0.1.5
MIT + file LICENSE
Authors
John Coene [aut, cre, cph] (<https://orcid.org/0000-0002-6637-4107>)
Initial release
2020-06-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.