library(rtemis.draw)
Attaching package: 'rtemis.draw'
The following object is masked from 'package:graphics':
Axis
Attaching package: 'rtemis.draw'
The following object is masked from 'package:graphics':
Axis
The high-level draw_network() covers the common cases. When you need full control — assembling a graph node-by-node, or setting every styling option explicitly — you drop to the S7 classes, exactly as you would with EChartsOption for charts. The pattern mirrors the ECharts low-level API:
GraphNode and GraphEdge objects into a GraphModelSigmaOptiondraw()These classes are the renderer-agnostic R counterparts of the graph model used in rtemis.live.
A GraphModel is a list of nodes, a list of edges, and a directed flag:
model <- GraphModel(
nodes = list(
GraphNode(id = "hub", label = "Hub", value = 5, group = "core"),
GraphNode(id = "a", label = "A", value = 2, group = "core"),
GraphNode(id = "b", label = "B", value = 2, group = "leaf"),
GraphNode(id = "c", label = "C", value = 1, group = "leaf")
),
edges = list(
GraphEdge(source = "hub", target = "a", weight = 1.0, sign = 1),
GraphEdge(source = "hub", target = "b", weight = 0.7, sign = 1),
GraphEdge(source = "hub", target = "c", weight = 0.4, sign = -1),
GraphEdge(source = "a", target = "b", weight = 0.5, sign = 1)
),
directed = FALSE
)Each class carries the same fields as its rtemis.live TypeScript interface:
GraphNode — id (required), label, value (drives size), group (categorical color key).GraphEdge — source, target (required), weight (thickness), sign (1/-1, color).GraphModel — nodes, edges, directed.draw_graph()draw_graph() is the mid-level builder: hand it a GraphModel plus styling and it assembles the render spec and draws it.
SigmaOption render specdraw_graph() builds a SigmaOption internally — the complete, validated render spec for a Sigma.js network (the graph model plus every styling field). It is the Sigma analog of EChartsOption, and you can construct it directly and pass it to the same draw() generic:
draw() dispatches on the option object, so draw(SigmaOption(...)) selects the Sigma backend just as draw(EChartsOption(...)) selects ECharts. Theme handling is identical across backends: pass theme = NULL (the default) for light/dark auto-detection, a Theme object to force one, or theme = NA for none.
The fields available on SigmaOption (and as arguments to draw_network() / draw_graph()):
model — the GraphModel to render.layout — "force" (ForceAtlas2), "circular", "circlepack", or "random".resolution — Louvain resolution; higher values yield more, smaller communities.node_size, scale_by_degree — base node radius in pixels, and whether each node is scaled by its weighted degree.edge_scale — stroke width per unit of normalized weight.node_opacity, edge_opacity — transparency.show_labels — node labels.color_by_group, palette — color nodes by detected community, and the palette to color them with.node_color — single node color when not coloring by group.positive_color, negative_color, blend_edges — edge colors by sign, or each edge as the blend of its two endpoint colors.title — chart title.