Create a graph.

e_graph(e, layout = "force", name = NULL, rm_x = TRUE, rm_y = TRUE, ...)

e_graph_gl(
  e,
  layout = "force",
  name = NULL,
  rm_x = TRUE,
  rm_y = TRUE,
  ...,
  itemStyle = list(opacity = 1)
)

e_graph_nodes(
  e,
  nodes,
  names,
  value,
  size,
  category,
  symbol = NULL,
  legend = TRUE
)

e_graph_edges(e, edges, source, target)

Arguments

e

An echarts4 object as returned by e_charts.

layout

Layout, one of force, none or circular.

name

Name of graph.

rm_x, rm_y

Whether to remove the x and y axis, defaults to TRUE.

...

Any other parameter.

itemStyle

This option is available for for GL and canvas graph but is only necessary for GL.

nodes

Data.frame of nodes.

names

Names of nodes, unique.

value

values of nodes.

size

Size of nodes.

category

Group of nodes (i.e.: group membership).

symbol

Symbols of nodes.

legend

Whether to add serie to legend.

edges

Data.frame of edges.

source, target

Column names of source and target.

See also

Examples

value <- rnorm(10, 10, 2)

nodes <- data.frame(
  name = sample(LETTERS, 10),
  value = value,
  size = value,
  symbol = sample(c("circle", "rect", "triangle"), 10, replace = TRUE),
  grp = rep(c("grp1", "grp2"), 5),
  stringsAsFactors = FALSE
)

edges <- data.frame(
  source = sample(nodes$name, 20, replace = TRUE),
  target = sample(nodes$name, 20, replace = TRUE),
  stringsAsFactors = FALSE
)

e_charts() %>%
  e_graph() %>%
  e_graph_nodes(nodes, name, value, size, grp, symbol) %>%
  e_graph_edges(edges, source, target)

# Use graphGL for larger networks
nodes <- data.frame(
  name = paste0(LETTERS, 1:1000),
  value = rnorm(1000, 10, 2),
  size = rnorm(1000, 10, 2),
  grp = rep(c("grp1", "grp2"), 500),
  stringsAsFactors = FALSE
)

edges <- data.frame(
  source = sample(nodes$name, 2000, replace = TRUE),
  target = sample(nodes$name, 2000, replace = TRUE),
  stringsAsFactors = FALSE
)

e_charts() %>%
  e_graph_gl() %>%
  e_graph_nodes(nodes, name, value, size, grp) %>%
  e_graph_edges(edges, source, target)