Skip to content
This is the alpha v4 version website. Looking for the v3 documentation?

Primitives schema

Primitives declare the rendering pipeline: what shapes, layers, paths, and extremities sigma compiles into WebGL programs. Pass them in the primitives option when creating a Sigma instance.

For a conceptual overview, see Styles and primitives.

Top-level structure

{
primitives: {
nodes?: NodePrimitives,
edges?: EdgePrimitives,
depthLayers?: string[],
},
}

Node primitives

{
nodes: {
shapes?: NodeShapeSpec[],
layers?: NodeLayerSpec[],
label?: LabelOptions,
backdrop?: BackdropOptions,
labelAttachments?: Record<string, LabelAttachmentRenderer>,
rotateWithCamera?: boolean,
variables?: VariablesDefinition,
},
}

The rotateWithCamera primitive specifies if nodes should keep their vertical orientations when the camera angle changes or not.

shapes

Array of SDF shape factories. The first is the default. Each node selects its shape via the shape style property.

Built-in factories (from sigma/rendering):

FactoryNameOptions
sdfCircle()"circle"-
sdfSquare(opts?)"square"cornerRadius?, rotation?
sdfTriangle()"triangle"-
sdfDiamond()"diamond"-

layers

Array of layer factories composited from back to front. Layers auto-disable when they have no data for a node.

Built-in:

FactoryPackageDescription
layerFill(opts?)sigma/renderingSolid color fill
layerBorder(opts?)@sigma/node-borderConcentric borders
layerImage(opts?)@sigma/node-imageImage or pictogram
layerPiechart(opts?)@sigma/node-piechartPie chart slices

label

Node label rendering options.

FieldTypeDescription
font{ family?, weight?, style?, size? }Default font settings
colorstringDefault label color
positionLabelPositionDefault label position
marginnumberGap between node edge and label
zoomToLabelSizeRatioFunction(ratio: number) => numberMaps camera ratio to a label size factor. Returning a value < 1 makes labels bigger. Defaults to () => 1 (fixed pixel size).

backdrop

Backdrop shape configuration, used for hover highlights around nodes and their labels. Each field accepts either a constant value (baked into the shader) or an attribute reference { attribute, default? } to read it from per-node storage.

FieldTypeDescription
colorstring | { attribute: string, default?: string }Backdrop fill color
shadowColorstring | { attribute: string, default?: string }Shadow color
shadowBlurnumber | { attribute: string, default?: number }Shadow blur radius (pixels)
paddingnumber | { attribute: string, default?: number }Padding around node + label

labelAttachments

A dictionary of named renderers for label attachments. A renderer returns a LabelAttachmentContent object or null to skip. See the attachments how-to.

Three content shapes are supported:

  • { type: "canvas", canvas: HTMLCanvasElement }: pre-rendered canvas (dimensions taken from canvas.width/height).
  • { type: "svg", svg: string | SVGElement }: SVG markup (dimensions parsed from width/height or viewBox).
  • { type: "html", html: string | HTMLElement, css?: string, width?: number, height?: number }: HTML fragment rendered via an SVG foreignObject.
labelAttachments: {
hoverInfo: (ctx: LabelAttachmentContext) => ({
type: "svg",
html: "<svg>...</svg>",
}),
}

variables

Custom typed attributes that layers can consume and that become available as style properties.

variables: {
borderSize: { type: "number", default: 0 },
borderColor: { type: "color", default: "transparent" },
}
FieldValuesDescription
type"number", "color", "string", "boolean"Variable type
defaultmatches typeDefault value when attribute is missing

Edge primitives

{
edges: {
paths?: EdgePathSpec[],
extremities?: EdgeExtremitySpec[],
layers?: EdgeLayerSpec[],
variables?: VariablesDefinition,
defaultHead?: string,
defaultTail?: string,
label?: EdgeLabelOptions,
},
}

paths

Array of path factories. The first is the default. By default, edges use [pathLine(), pathLoop()], with pathLoop handling self-loops, and selected automatically through selfLoopPath.

Built-in factories (from sigma/rendering):

FactoryNameOptions
pathLine()"straight"-
pathCurved(opts?)"curved"segments?, curvature? (accepts a ValueSource<number>)
pathStep(opts?)"step"orientation?, rotateWithCamera?, offset?, cornerRadius?, …
pathStepCurved(opts?)"step-curved"orientation?, rotateWithCamera?, offset?, …
pathCurvedS(opts?)"curved-s"curve control points / segments
pathLoop(opts?)"loop"self-loop geometry options

extremities

Array of extremity factories for arrowheads and other endpoint shapes. See How to: Edge extremities for usage recipes.

All built-in extremities share the same option shape. lengthRatio and widthRatio are expressed as multiples of the edge thickness; margin shifts the shape away from the node along the edge direction (in pixels).

Built-in factories (from sigma/rendering):

FactoryNameOptionsDefault lengthRatioDefault widthRatio
extremityArrow(opts?)"arrow"lengthRatio?, widthRatio?, margin?54
extremityBar(opts?)"bar"lengthRatio?, widthRatio?, margin?0.754
extremityCircle(opts?)"circle"lengthRatio?, widthRatio?, margin?4lengthRatio + 1
extremityDiamond(opts?)"diamond"lengthRatio?, widthRatio?, margin?54
extremitySquare(opts?)"square"lengthRatio?, widthRatio?, margin?44

Each edge picks an extremity via the head and tail style properties, using the name in the table above (or "none" to skip).

layers

Edge layer factories composited together.

FactoryPackageDescription
layerPlain()sigma/renderingSolid edge body
layerDashed(opts?)sigma/renderingDashed overlay. Options: dashSize, gapSize, dashColor, dashOffset, solidExtremities

label

Edge label rendering options.

FieldTypeDescription
colorEdgeLabelColorSpecificationLabel color. Accepts a CSS string or { attribute, color? } to read from an edge attribute.
position"over" | "above" | "below" | "auto"Default edge label placement
marginnumberDistance between label and edge path (in pixels) for "above"/"below"/"auto"
fontSizeMode"fixed" | "scaled"Whether labels scale with zoom
textBorder{ width: number, color: EdgeLabelColorSpecification }Outline around label characters for readability
minVisibilityThresholdnumberMinimum label visibility ratio (0–1). Labels less visible than this are hidden. Default: 0.5.
fullVisibilityThresholdnumberVisibility ratio at which labels reach full opacity. Labels fade between the two thresholds. Default: 0.6.

Depth layers

An array of strings defining the rendering order. Elements assigned to later layers render on top.

Default:

["edges", "nodes", "topEdges", "topNodes"];

Nodes and edges are assigned to depth layers via the depth and labelDepth style properties. See Hover and search page for a common use-case, where depth is used to bring highlighted nodes and edges above the rest of the graph.