Learn R Programming

DiagrammeR (version 0.8.4)

vivagraph: Render graph with VivaGraphJS

Description

Render a graph object with the VivaGraphJS library.

Usage

vivagraph(graph = NULL, layout = "forceDirected", positions = NULL, config = NULL, height = NULL, width = NULL, elementId = NULL)

Arguments

graph
a dgr_graph object, created using the create_graph function.
layout
a string where "forceDirected" is the default whereas "constant" is another layout option.
positions
data.frame of two columns x and y with fixed positions if you intend to provide preset positions for nodes.
config
list of other config options. While currently this does nothing, we expect to add additional configuration options here.
height
string or integer with a valid CSS height for the container for our htmlwidget.
width
string or integer with a valid CSS width for the container for our htmlwidget.
elementId
string with a valid CSS id.

Examples

Run this code
## Not run: 
# # Create a graph using the \code{create_nodes}, \code{create_edges},
# # and \code{create_graph} functions
# nodes <-
#   create_nodes(nodes = LETTERS,
#                type = "letter",
#                shape = sample(c("circle", "rectangle"),
#                               length(LETTERS),
#                               replace = TRUE),
#                fillcolor = sample(c("aqua", "gray80",
#                                     "pink", "lightgreen",
#                                     "azure", "yellow"),
#                                   length(LETTERS),
#                                   replace = TRUE))
# 
# edges <-
#   create_edges(from = sample(LETTERS, replace = TRUE),
#                to = sample(LETTERS, replace = TRUE),
#                rel = "letter_to_letter")
# 
# graph <-
#   create_graph(nodes_df = nodes,
#                edges_df = edges,
#                graph_attrs = "layout = neato",
#                node_attrs = c("fontname = Helvetica",
#                               "style = filled"),
#                edge_attrs = c("color = gray20",
#                               "arrowsize = 0.5"))
# 
# vivagraph(graph = graph)
# ## End(Not run)

Run the code above in your browser using DataLab