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

Sigma API

The Sigma class is the main entry point. It takes a graphology graph, a DOM container, and an options object.

Constructor

new Sigma(graph, container, options?)
ParameterTypeDescription
graphGraphA graphology graph instance
containerHTMLElementDOM element with explicit width and height
optionsobjectOptional configuration (see below)

Options

PropertyTypeDescription
primitivesPShapes, layers, paths, extremities, depth layers. See Primitives schema
stylesStylesDeclarationStyle rules for nodes and edges. See Styles and primitives
settingsPartial<Settings>Behavior and performance settings. See Settings
nodeReducerfunctionEscape hatch for complex node styling. (key, data, attrs, state, graphState, graph) => Partial<NodeDisplayData>
edgeReducerfunctionSame shape as nodeReducer, for edges. Returns Partial<EdgeDisplayData>.
customNodeStateNSRuntime default values for custom node state fields
customEdgeStateESRuntime default values for custom edge state fields
customGraphStateGSRuntime default values for custom graph state fields

Generic type parameters

Sigma<N, E, G, NS, ES, GS, P>;
ParameterExtendsDefaultDescription
NAttributesAttributesNode attributes type
EAttributesAttributesEdge attributes type
GAttributesAttributesGraph attributes type
NS{}{}Custom node state type
ES{}{}Custom edge state type
GS{}{}Custom graph state type
PPrimitivesDeclarationPrimitivesDeclarationPrimitives type

Lifecycle

MethodReturnsDescription
kill()voidDestroy the instance: release WebGL, remove listeners, clean up DOM
resize(force?)thisResize to container dimensions. force bypasses size check
clear()thisClear all canvases (emits beforeClear/afterClear)

Rendering

MethodReturnsDescription
refresh(opts?)thisRe-process data and render. Options: { partialGraph?, skipIndexation?, schedule? }
scheduleRefresh(opts?)thisDebounced version of refresh (always sets schedule: true). Options: { partialGraph?, skipIndexation? }
scheduleRender()thisDebounced: schedule a render-only pass for the next animation frame (no re-processing)

Node state

MethodReturnsDescription
getNodeState(key)NSGet a node’s current state
setNodeState(key, state)thisUpdate a node’s state (partial merge) and schedule render
setNodesState(keys, state)thisUpdate multiple nodes’ state at once

Edge state

MethodReturnsDescription
getEdgeState(key)ESGet an edge’s current state
setEdgeState(key, state)thisUpdate an edge’s state (partial merge) and schedule render
setEdgesState(keys, state)thisUpdate multiple edges’ state at once

Graph state

MethodReturnsDescription
getGraphState()GSGet the global graph state
setGraphState(state)thisUpdate the graph state (partial merge) and schedule render

Display data

MethodReturnsDescription
getNodeDisplayData(key)NodeDisplayData | undefinedGet computed display data for a node (position, size, color, etc.)
getEdgeDisplayData(key)EdgeDisplayData | undefinedGet computed display data for an edge
getNodeDisplayedLabels()Set<string>Get node keys whose labels are currently visible
getEdgeDisplayedLabels()Set<string>Get edge keys whose labels are currently visible

Coordinate conversion

MethodReturnsDescription
graphToViewport(coords)CoordinatesConvert graph-space coordinates to screen pixels
viewportToGraph(coords)CoordinatesConvert screen pixels to graph-space coordinates
framedGraphToViewport(coords)CoordinatesConvert normalized (0–1) graph space to screen pixels
viewportToFramedGraph(coords)CoordinatesConvert screen pixels to normalized graph space
getGraphToViewportRatio()numberDistance multiplier between graph and viewport spaces
viewRectangle()objectGet the visible area in graph coordinates: { x1, y1, x2, y2, height }

All coordinate methods accept an optional override parameter to use custom camera state, matrix, or dimensions instead of the current ones.

Bounding box

MethodReturnsDescription
getBBox(){ x: Extent; y: Extent }Get auto-computed graph bounding box
getCustomBBox()object | nullGet custom bounding box override, if set
setCustomBBox(bbox)thisOverride the bounding box (null to reset)

Settings

MethodReturnsDescription
getSettings()SettingsGet a copy of all current settings
getSetting(key)Settings[K]Get a single setting value
setSetting(key, value)thisSet a single setting and schedule refresh
updateSetting(key, fn)thisUpdate a setting with a function and schedule refresh
setSettings(partial)thisSet multiple settings at once

Graph and container

MethodReturnsDescription
getGraph()GraphGet the current graph instance
setGraph(graph)thisReplace the graph, rebind handlers, and refresh
getContainer()HTMLElementGet the DOM container element
getDimensions()DimensionsGet renderer pixel dimensions { width, height }
getGraphDimensions()DimensionsGet graph extent dimensions

Camera and input

MethodReturnsDescription
getCamera()CameraGet the camera instance. See Camera API
setCamera(camera)voidReplace the camera instance
getMouseCaptor()MouseCaptorGet the mouse event captor
getTouchCaptor()TouchCaptorGet the touch event captor

Utilities

MethodReturnsDescription
scaleSize(size?, cameraRatio?)numberConvert a size to viewport scale based on zoom and itemSizesReference
getStagePadding()numberGet padding applied when autoRescale is enabled
getRenderParams()RenderParamsGet current render parameters (matrix, dimensions, ratios)