read

0th

Percentile

Read

Read nodes and edges to add to the graph. Other proxy methods to add data to a graph have to add nodes and edges one by one, thereby draining the browser, this method will add multiple nodes and edges more efficiently.

Usage
sg_read_nodes_p(proxy, data, ...)

sg_read_edges_p(proxy, data, ...)

sg_read_exec_p(proxy)

Arguments
proxy

An object of class sigmajsProxy as returned by sigmajsProxy.

data

A data.frame of _one_ node or edge.

...

any column.

Functions

  • sg_read_nodes_p read nodes.

  • sg_read_edges_p read edges.

  • sg_read_exec_p send read nodes and edges to JavaScript front end.

Aliases
  • read
  • sg_read_nodes_p
  • sg_read_edges_p
  • sg_read_exec_p
Examples
# NOT RUN {
library(shiny)

ui <- fluidPage(
	actionButton("add", "add nodes & edges"),
	sigmajsOutput("sg")
)

server <- function(input, output, session){

	nodes <- sg_make_nodes()
	edges <- sg_make_edges(nodes)

	output$sg <- renderSigmajs({
		sigmajs() %>% 
			sg_nodes(nodes, id, label, color, size) %>% 
			sg_edges(edges, id, source, target) %>% 
			sg_layout()
	})

	i <- 10

	observeEvent(input$add, {
		new_nodes <- sg_make_nodes()
		new_nodes$id <- as.character(as.numeric(new_nodes$id) + i)
		i <<- i + 10
		ids <- 1:(i)
		new_edges <- data.frame(
			id = as.character((i * 2 + 15):(i * 2 + 29)),
			source = as.character(sample(ids, 15)),
			target = as.character(sample(ids, 15))
		)
		
		sigmajsProxy("sg") %>% 
			sg_force_kill_p() %>% 
			sg_read_nodes_p(new_nodes, id, label, color, size) %>% 
			sg_read_edges_p(new_edges, id, source, target) %>% 
			sg_read_exec_p() %>% 
			sg_force_start_p() %>% 
			sg_refresh_p()
	})

}

if(interactive()) shinyApp(ui, server)

# }
Documentation reproduced from package sigmajs, version 0.1.3, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.