g6 {g6R}R Documentation

Create a G6 Graph Visualization

Description

Creates an interactive graph visualization using the G6 graph visualization library. This function is the main entry point for creating G6 graph visualizations in R.

Usage

g6(
  nodes = NULL,
  edges = NULL,
  combos = NULL,
  jsonUrl = NULL,
  iconsUrl = "//at.alicdn.com/t/font_2678727_za4qjydwkkh.js",
  width = "100%",
  height = NULL,
  elementId = NULL
)

Arguments

nodes

A data frame or list of nodes in the graph. Each node should have at least an "id" field. See 'Data Structure' section for more details. Default: NULL.

edges

A data frame or list of edges in the graph. Each edge should have "source" and "target" fields identifying the connected nodes. See 'Data Structure' section for more details. Default: NULL.

combos

A data frame or list of combo groups in the graph. Each combo should have at least an "id" field. Nodes can be assigned to combos using their "combo" field. See 'Data Structure' section for more details. Default: NULL.

jsonUrl

An url pointing to a valid JSON containing the graph data in G6 format. See https://assets.antv.antgroup.com/g6/20000.json for an example. Can't be used at the same time as nodes, edges, and combos.

iconsUrl

A URL pointing to a JavaScript file containing custom icons. Default provides reasonable set of icons from https://at.alicdn.com/t/project/2678727/caef142c-804a-4a2f-a914-ae82666a31ee.html?spm=a313x.7781069.1998910419.35.

width

Width of the graph container in pixels or as a valid CSS unit. Default: NULL (automatic sizing).

height

Height of the graph container in pixels or as a valid CSS unit. Default: NULL (automatic sizing).

elementId

A unique ID for the graph HTML element. Default: NULL (automatically generated).

Details

The g6 function creates a G6 graph as an htmlwidget that can be used in R Markdown, Shiny applications, or rendered to HTML. It takes graph data in the form of nodes, edges, and optional combo groupings, along with various configuration options for customizing the appearance and behavior of the graph.

Nodes

The nodes parameter should be a data frame or list of nodes with at least an id field for each node. Additional fields can include:

Edges

The edges parameter should be a data frame or list of edges with at least source and target fields identifying the connected nodes. Additional fields can include:

Combos

The combos parameter is used for grouping nodes and can be a data frame or list with combo definitions. Fields include:

Nodes are assigned to combos by setting their combo field to the ID of the combo.

Value

An htmlwidget object that can be printed, included in R Markdown documents, or used in Shiny applications. This widget contains the graph data and configuration necessary to render the G6 graph visualization.

Examples

# Create a simple graph with two nodes and one edge
nodes <- data.frame(
  id = c("node1", "node2")
)

edges <- data.frame(
  source = "node1",
  target = "node2"
)

g6(nodes = nodes, edges = edges)

[Package g6R version 0.1.0 Index]