DiagrammeR (version 0.9.0)

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 node data frame (ndf)
ndf <-
  create_node_df(
    n = 6,
    label = TRUE,
    fillcolor = c("lightgrey", "red", "orange",
                  "pink", "aqua", "yellow"),
    shape = "circle",
    value = c(2, 1, 0.5, 1, 1.8, 1),
    type = c("1", "1", "1", "2", "2", "2"),
    x = c(1, 2, 3, 4, 5, 6),
    y = c(-2, -1, 0, 6, 4, 1))

# Create an edge data frame (edf)
edf <-
  create_edge_df(
    from = c(1, 2, 3, 4, 6, 5),
    to = c(4, 3, 1, 3, 1, 4),
    color = c("green", "green", "grey",
              "grey", "blue", "blue"),
    rel = "leading_to")

# Create a graph object
graph <-
  create_graph(
    nodes_df = ndf,
    edges_df = edf)

vivagraph(graph)
# }

Run the code above in your browser using DataLab