View source: R/visIgraphLayout.R
visIgraphLayout | R Documentation |
Use a igraph layout for compute coordinates and fast rendering. This function affect x and y coordinates to nodes data.frame using a igraph layout, and then render network faster with no stabilization. We set some options as : visNodes(physics = FALSE) & visEdges(smooth = FALSE) & visPhysics(stabilization= FALSE), but you can overwrite them using arguments or by add another call after visIgraphLayout
visIgraphLayout( graph, layout = "layout_nicely", physics = FALSE, smooth = FALSE, type = "square", randomSeed = NULL, layoutMatrix = NULL, ... )
graph |
: a visNetwork object |
layout |
: Character Name of igraph layout function to use. Default to "layout_nicely" |
physics |
: Boolean. Default to FALSE. Enabled physics on nodes ? |
smooth |
: Boolean. Default to FALSE. Use smooth edges ? |
type |
: Character Type of scale from igrah to vis.js. "square" (default) render in a square limit by height. "full" use width and height to scale in a rectangle. |
randomSeed |
: Number. The nodes are randomly positioned initially. This means that the settled result is different every time. If you provide a random seed manually, the layout will be the same every time. |
layoutMatrix |
: in case of layout = 'layout.norm'. the 'layout' argument (A matrix with two or three columns, the layout to normalize) |
... |
: Adding arguments to layout function |
See online documentation https://datastorm-open.github.io/visNetwork/
visNodes for nodes options, visEdges for edges options, visGroups for groups options, visLegend for adding legend, visOptions for custom option, visLayout & visHierarchicalLayout for layout, visPhysics for control physics, visInteraction for interaction, visNetworkProxy & visFocus & visFit for animation within shiny, visDocumentation, visEvents, visConfigure ...
## Not run: nnodes <- 200 nnedges <- 400 nodes <- data.frame(id = 1:nnodes) edges <- data.frame(from = sample(1:nnodes, nnedges, replace = T), to = sample(1:nnodes, nnedges, replace = T)) # with default layout visNetwork(nodes, edges) %>% visIgraphLayout() # use full space visNetwork(nodes, edges) %>% visIgraphLayout(type = "full") # in circle ? visNetwork(nodes, edges) %>% visIgraphLayout(layout = "layout_in_circle") %>% visOptions(highlightNearest = list(enabled = T, hover = T), nodesIdSelection = T) # keep physics with smooth curves ? visNetwork(nodes, edges) %>% visIgraphLayout(physics = TRUE, smooth = TRUE) # fix randomSeed to keep position visNetwork(nodes, edges) %>% visIgraphLayout(randomSeed = 123) visNetwork(nodes, edges) %>% visIgraphLayout(randomSeed = 123) # layout_with_sugiyama nodes <- data.frame(id = 1:5) edges <- data.frame(from = c(1, 2, 2, 4), to = c(2, 3, 4, 5)) visNetwork(nodes, edges) %>% visIgraphLayout(layout = "layout_with_sugiyama", layers = c(1, 2, 3, 3, 4)) visNetwork(nodes, edges) %>% visIgraphLayout(layout = "layout_with_sugiyama") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.