library(rtemis.draw).:rtemis.draw 0.3.0 🖌 aarch64-apple-darwin23
Attaching package: 'rtemis.draw'
The following object is masked from 'package:graphics':
Axis
.:rtemis.draw 0.3.0 🖌 aarch64-apple-darwin23
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.