Skip to main content

Class: Sigma<N, E, G>

Defined in: sigma/src/sigma.ts:121

Main class.

Param

Graph to render.

Param

DOM container in which to render.

Param

Optional settings.

Extends

  • TypedEventEmitter<SigmaEvents>

Type Parameters

N extends Attributes = Attributes

E extends Attributes = Attributes

G extends Attributes = Attributes

Constructors

new Sigma()

new Sigma<N, E, G>(graph, container, settings): Sigma<N, E, G>

Defined in: sigma/src/sigma.ts:192

Parameters

graph

AbstractGraph<N, E, G>

container

HTMLElement

settings

Partial<Settings<N, E, G>> = {}

Returns

Sigma<N, E, G>

Overrides

TypedEventEmitter<SigmaEvents>.constructor

Properties

rawEmitter

rawEmitter: EventEmitter

Defined in: sigma/src/types.ts:114

Inherited from

TypedEventEmitter.rawEmitter

Methods

addListener()

addListener<Event>(type, listener): this

Defined in: sigma/src/types.ts:120

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

listener

SigmaEvents[Event]

Returns

this

Inherited from

TypedEventEmitter.addListener


clear()

clear(): this

Defined in: sigma/src/sigma.ts:2048

Method used to clear all the canvases.

Returns

this


createCanvas()

createCanvas(id, options): HTMLCanvasElement

Defined in: sigma/src/sigma.ts:1647

Function used to create a canvas element.

Parameters

id

string

Context's id.

options

object & { beforeLayer: string; } | { afterLayer: string; } = {}

Returns

HTMLCanvasElement


createCanvasContext()

createCanvasContext(id, options): this

Defined in: sigma/src/sigma.ts:1661

Function used to create a canvas context and add the relevant DOM elements.

Parameters

id

string

Context's id.

options
style

Partial<CSSStyleDeclaration>

Returns

this


createLayer()

createLayer<T>(id, tag, options): T

Defined in: sigma/src/sigma.ts:1608

Function used to create a layer element.

Type Parameters

T extends HTMLElement

Parameters

id

string

Context's id.

tag

string

The HTML tag to use.

options

object & { beforeLayer: string; } | { afterLayer: string; } = {}

Returns

T


createWebGLContext()

createWebGLContext(id, options): WebGLRenderingContext

Defined in: sigma/src/sigma.ts:1682

Function used to create a WebGL context and add the relevant DOM elements.

Parameters

id

string

Context's id.

options

object & { canvas: HTMLCanvasElement; style: undefined; } | { canvas: undefined; style: CSSStyleDeclaration; } = {}

#getContext params to override (optional)

Returns

WebGLRenderingContext


emit()

emit<Event>(type, ...args): boolean

Defined in: sigma/src/types.ts:119

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

args

...Parameters<SigmaEvents[Event]>

Returns

boolean

Inherited from

TypedEventEmitter.emit


eventNames()

eventNames<Event>(): Event[]

Defined in: sigma/src/types.ts:116

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Returns

Event[]

Inherited from

TypedEventEmitter.eventNames


framedGraphToViewport()

framedGraphToViewport(coordinates, override): Coordinates

Defined in: sigma/src/sigma.ts:2221

Method returning the coordinates of a point from the framed graph system to the viewport system. It allows overriding anything that is used to get the translation matrix, or even the matrix itself.

Be careful if overriding dimensions, padding or cameraState, as the computation of the matrix is not the lightest of computations.

Parameters

coordinates

Coordinates

override

CoordinateConversionOverride = {}

Returns

Coordinates


getBBox()

getBBox(): object

Defined in: sigma/src/sigma.ts:2323

Method returning the graph's bounding box.

Returns

object

x

x: Extent

y

y: Extent


getCamera()

getCamera(): Camera

Defined in: sigma/src/sigma.ts:1759

Method returning the renderer's camera.

Returns

Camera


getCanvases()

getCanvases(): PlainObject<HTMLCanvasElement>

Defined in: sigma/src/sigma.ts:2449

Method that returns the collection of all used canvases. At the moment, the instantiated canvases are the following, and in the following order in the DOM:

  • edges
  • nodes
  • edgeLabels
  • labels
  • hovers
  • hoverNodes
  • mouse

Returns

PlainObject<HTMLCanvasElement>

  • The collection of canvases.

getContainer()

getContainer(): HTMLElement

Defined in: sigma/src/sigma.ts:1780

Method returning the container DOM element.

Returns

HTMLElement


getCustomBBox()

getCustomBBox(): null | { x: Extent; y: Extent; }

Defined in: sigma/src/sigma.ts:2332

Method returning the graph's custom bounding box, if any.

Returns

null | { x: Extent; y: Extent; }


getDimensions()

getDimensions(): Dimensions

Defined in: sigma/src/sigma.ts:1846

Method returning the current renderer's dimensions.

Returns

Dimensions


getEdgeDisplayData()

getEdgeDisplayData(key): undefined | DisplayData

Defined in: sigma/src/sigma.ts:1884

Method used to get all the sigma edge attributes. It's useful for example to get values that are set by the edgeReducer.

Parameters

key

unknown

The edge's key.

Returns

undefined | DisplayData

A copy of the desired edge's attribute or undefined if not found


getEdgeDisplayedLabels()

getEdgeDisplayedLabels(): Set<string>

Defined in: sigma/src/sigma.ts:1903

Method used to get the set of currently displayed edge labels.

Returns

Set<string>

A set of edge keys whose label is displayed.


getGraph()

getGraph(): AbstractGraph<N, E, G>

Defined in: sigma/src/sigma.ts:1789

Method returning the renderer's graph.

Returns

AbstractGraph<N, E, G>


getGraphDimensions()

getGraphDimensions(): Dimensions

Defined in: sigma/src/sigma.ts:1855

Method returning the current graph's dimensions.

Returns

Dimensions


getGraphToViewportRatio()

getGraphToViewportRatio(): number

Defined in: sigma/src/sigma.ts:2306

Method returning the distance multiplier between the graph system and the viewport system.

Returns

number


getMaxListeners()

getMaxListeners(): number

Defined in: sigma/src/types.ts:118

Returns

number

Inherited from

TypedEventEmitter.getMaxListeners


getMouseCaptor()

getMouseCaptor(): MouseCaptor<N, E, G>

Defined in: sigma/src/sigma.ts:1828

Method returning the mouse captor.

Returns

MouseCaptor<N, E, G>


getNodeDisplayData()

getNodeDisplayData(key): undefined | NodeDisplayData

Defined in: sigma/src/sigma.ts:1872

Method used to get all the sigma node attributes. It's useful for example to get the position of a node and to get values that are set by the nodeReducer

Parameters

key

unknown

The node's key.

Returns

undefined | NodeDisplayData

A copy of the desired node's attribute or undefined if not found


getNodeDisplayedLabels()

getNodeDisplayedLabels(): Set<string>

Defined in: sigma/src/sigma.ts:1894

Method used to get the set of currently displayed node labels.

Returns

Set<string>

A set of node keys whose label is displayed.


getRenderParams()

getRenderParams(): RenderParams

Defined in: sigma/src/sigma.ts:1573

Function used to get the render params.

Returns

RenderParams


getSetting()

getSetting<K>(key): Settings<N, E, G>[K]

Defined in: sigma/src/sigma.ts:1922

Method returning the current value for a given setting key.

Type Parameters

K extends keyof Settings<N, E, G>

Parameters

key

K

The setting key to get.

Returns

Settings<N, E, G>[K]

The value attached to this setting key or undefined if not found


getSettings()

getSettings(): Settings<N, E, G>

Defined in: sigma/src/sigma.ts:1912

Method returning a copy of the settings collection.

Returns

Settings<N, E, G>

A copy of the settings collection.


getStagePadding()

getStagePadding(): number

Defined in: sigma/src/sigma.ts:1595

Function used to retrieve the actual stage padding value.

Returns

number


getTouchCaptor()

getTouchCaptor(): TouchCaptor<N, E, G>

Defined in: sigma/src/sigma.ts:1837

Method returning the touch captor.

Returns

TouchCaptor<N, E, G>


getViewportZoomedState()

getViewportZoomedState(viewportTarget, newRatio): CameraState

Defined in: sigma/src/sigma.ts:2164

Method used to (un)zoom, while preserving the position of a viewport point. Used for instance to zoom "on the mouse cursor".

Parameters

viewportTarget

Coordinates

newRatio

number

Returns

CameraState


graphToViewport()

graphToViewport(graphPoint, override): Coordinates

Defined in: sigma/src/sigma.ts:2298

Method used to translate a point's coordinates from the graph system (the reference system of data as they are in the given graph instance) to the viewport system (pixel distance from the top-left of the stage).

This method accepts an optional camera which can be useful if you need to translate coordinates based on a different view than the one being currently being displayed on screen.

Parameters

graphPoint

Coordinates

override

CoordinateConversionOverride = {}

Returns

Coordinates


kill()

kill(): void

Defined in: sigma/src/sigma.ts:2352

Method used to shut the container & release event listeners.

Returns

void


killLayer()

killLayer(id): this

Defined in: sigma/src/sigma.ts:1734

Function used to properly kill a layer.

Parameters

id

string

Layer id.

Returns

this


listenerCount()

listenerCount<Event>(type): number

Defined in: sigma/src/types.ts:129

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

Returns

number

Inherited from

TypedEventEmitter.listenerCount


listeners()

listeners<Event>(type): SigmaEvents[Event][]

Defined in: sigma/src/types.ts:128

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

Returns

SigmaEvents[Event][]

Inherited from

TypedEventEmitter.listeners


off()

off<Event>(type, listener): this

Defined in: sigma/src/types.ts:126

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

listener

SigmaEvents[Event]

Returns

this

Inherited from

TypedEventEmitter.off


on()

on<Event>(type, listener): this

Defined in: sigma/src/types.ts:121

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

listener

SigmaEvents[Event]

Returns

this

Inherited from

TypedEventEmitter.on


once()

once<Event>(type, listener): this

Defined in: sigma/src/types.ts:122

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

listener

SigmaEvents[Event]

Returns

this

Inherited from

TypedEventEmitter.once


prependListener()

prependListener<Event>(type, listener): this

Defined in: sigma/src/types.ts:123

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

listener

SigmaEvents[Event]

Returns

this

Inherited from

TypedEventEmitter.prependListener


prependOnceListener()

prependOnceListener<Event>(type, listener): this

Defined in: sigma/src/types.ts:124

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

listener

SigmaEvents[Event]

Returns

this

Inherited from

TypedEventEmitter.prependOnceListener


rawListeners()

rawListeners<Event>(type): SigmaEvents[Event][]

Defined in: sigma/src/types.ts:130

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

Returns

SigmaEvents[Event][]

Inherited from

TypedEventEmitter.rawListeners


refresh()

refresh(opts?): this

Defined in: sigma/src/sigma.ts:2073

Method used to refresh, i.e. force the renderer to reprocess graph data and render, but keep the state.

  • if a partialGraph is provided, we only reprocess those nodes & edges.
  • if schedule is TRUE, we schedule a render instead of sync render
  • if skipIndexation is TRUE, then labelGrid & program indexation are skipped (can be used if you haven't modify x, y, zIndex & size)

Parameters

opts?
partialGraph

{ edges: string[]; nodes: string[]; }

partialGraph.edges

string[]

partialGraph.nodes

string[]

schedule

boolean

skipIndexation

boolean

Returns

this


removeAllListeners()

removeAllListeners<Event>(type?): this

Defined in: sigma/src/types.ts:127

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type?

Event

Returns

this

Inherited from

TypedEventEmitter.removeAllListeners


removeListener()

removeListener<Event>(type, listener): this

Defined in: sigma/src/types.ts:125

Type Parameters

Event extends "clickStage" | "rightClickStage" | "doubleClickStage" | "wheelStage" | "downStage" | "upStage" | "leaveStage" | "enterStage" | "clickNode" | "rightClickNode" | "doubleClickNode" | "wheelNode" | "downNode" | "upNode" | "leaveNode" | "enterNode" | "clickEdge" | "rightClickEdge" | "doubleClickEdge" | "wheelEdge" | "downEdge" | "upEdge" | "leaveEdge" | "enterEdge" | keyof SigmaAdditionalEvents

Parameters

type

Event

listener

SigmaEvents[Event]

Returns

this

Inherited from

TypedEventEmitter.removeListener


resize()

resize(force?): this

Defined in: sigma/src/sigma.ts:1980

Method used to resize the renderer.

Parameters

force?

boolean

If true, then resize is processed even if size is unchanged (optional).

Returns

this


scaleSize()

scaleSize(size, cameraRatio): number

Defined in: sigma/src/sigma.ts:2428

Method used to scale the given size according to the camera's ratio, i.e. zooming state.

Parameters

size

number = 1

The size to scale (node size, edge thickness etc.).

cameraRatio

number = ...

A camera ratio (defaults to the actual camera ratio).

Returns

number

  • The scaled size.

scheduleRefresh()

scheduleRefresh(opts?): this

Defined in: sigma/src/sigma.ts:2152

Method used to schedule a refresh (i.e. fully reprocess graph data and render) at the next available frame. This method can be safely called on a same frame because it basically debounces refresh to the next frame.

Parameters

opts?
layoutUnchange

boolean

partialGraph

{ edges: string[]; nodes: string[]; }

partialGraph.edges

string[]

partialGraph.nodes

string[]

Returns

this


scheduleRender()

scheduleRender(): this

Defined in: sigma/src/sigma.ts:2134

Method used to schedule a render at the next available frame. This method can be safely called on a same frame because it basically debounces refresh to the next frame.

Returns

this


setCamera()

setCamera(camera): void

Defined in: sigma/src/sigma.ts:1769

Method setting the renderer's camera.

Parameters

camera

Camera

New camera.

Returns

void


setCustomBBox()

setCustomBBox(customBBox): this

Defined in: sigma/src/sigma.ts:2341

Method used to override the graph's bounding box with a custom one. Give null as the argument to stop overriding.

Parameters

customBBox

null | { x: Extent; y: Extent; }

Returns

this


setGraph()

setGraph(graph): void

Defined in: sigma/src/sigma.ts:1798

Method used to set the renderer's graph.

Parameters

graph

AbstractGraph<N, E, G>

Returns

void


setMaxListeners()

setMaxListeners(n): this

Defined in: sigma/src/types.ts:117

Parameters

n

number

Returns

this

Inherited from

TypedEventEmitter.setMaxListeners


setSetting()

setSetting<K>(key, value): this

Defined in: sigma/src/sigma.ts:1934

Method setting the value of a given setting key. Note that this will schedule a new render next frame.

Type Parameters

K extends keyof Settings<N, E, G>

Parameters

key

K

The setting key to set.

value

Settings<N, E, G>[K]

The value to set.

Returns

this


setSettings()

setSettings(settings): this

Defined in: sigma/src/sigma.ts:1965

Method setting multiple settings at once.

Parameters

settings

Partial<Settings<N, E, G>>

The settings to set.

Returns

this


updateSetting()

updateSetting<K>(key, updater): this

Defined in: sigma/src/sigma.ts:1951

Method updating the value of a given setting key using the provided function. Note that this will schedule a new render next frame.

Type Parameters

K extends keyof Settings<N, E, G>

Parameters

key

K

The setting key to set.

updater

(value) => Settings<N, E, G>[K]

The update function.

Returns

this


viewportToFramedGraph()

viewportToFramedGraph(coordinates, override): Coordinates

Defined in: sigma/src/sigma.ts:2249

Method returning the coordinates of a point from the viewport system to the framed graph system. It allows overriding anything that is used to get the translation matrix, or even the matrix itself.

Be careful if overriding dimensions, padding or cameraState, as the computation of the matrix is not the lightest of computations.

Parameters

coordinates

Coordinates

override

CoordinateConversionOverride = {}

Returns

Coordinates


viewportToGraph()

viewportToGraph(viewportPoint, override): Coordinates

Defined in: sigma/src/sigma.ts:2284

Method used to translate a point's coordinates from the viewport system (pixel distance from the top-left of the stage) to the graph system (the reference system of data as they are in the given graph instance).

This method accepts an optional camera which can be useful if you need to translate coordinates based on a different view than the one being currently being displayed on screen.

Parameters

viewportPoint

Coordinates

override

CoordinateConversionOverride = {}

Returns

Coordinates


viewRectangle()

viewRectangle(): object

Defined in: sigma/src/sigma.ts:2194

Method returning the abstract rectangle containing the graph according to the camera's state.

Returns

object

  • The view's rectangle.
height

height: number

x1

x1: number

x2

x2: number

y1

y1: number

y2

y2: number