Skip to content
sigma.js sigma.js
v4.0.6 Docs Examples GitHub 12.2K

defineSigmaOptions

defineSigmaOptions<P>(options): SigmaOptions<Attributes, Attributes, Attributes, { }, { }, { }, P>

Defined in: packages/sigma/src/types/options.ts:75

Factory function for creating type-safe sigma options.

Types the options from the primitives declaration, so that variables and depth layers declared in primitives are checked in styles.

P extends PrimitivesDeclaration

SigmaOptions<Attributes, Attributes, Attributes, { }, { }, { }, P>

SigmaOptions<Attributes, Attributes, Attributes, { }, { }, { }, P>

const options = defineSigmaOptions({
primitives: {
nodes: {
shapes: [sdfCircle(), sdfSquare()],
variables: {
borderSize: { type: "number", default: 2 },
borderColor: { type: "color", default: "#fff" },
},
layers: [layerFill()],
},
edges: { paths: [pathLine(), pathCurved()] },
},
styles: {
nodes: {
color: "#666",
shape: "circle",
borderSize: 2, // Inferred from variables
borderColor: "#fff",
},
},
});