<div id="sigma-container"></div>
import Graph from "graphology";
import Sigma, { DEFAULT_STYLES } from "sigma";
} from "sigma/rendering";
const container = document.getElementById("sigma-container") as HTMLElement;
const SOURCE_COLOR = "#7E3D9C";
const TARGET_COLOR = "#ED8666";
// Each row has its own path:
const PATHS = ["straight", "curved", "stepCurved", "curvedS"] as const;
// Each column shows edges fillings and extremities in its own way:
{ head: "arrow", tail: "arrow", useGradient: true },
{ dashSize: 5, dashColor: "#ffffff99" },
{ head: "arrow", dashSize: 10, dashColor: "#ffffff99", useGradient: true },
const graph = new Graph();
PATHS.forEach((path, row) => {
COLUMNS.forEach((config, col) => {
const [x, y] = [col * 120, -row * 80];
const source = graph.addNode(`${path}-${col}-source`, { x: x - 30, y, color: SOURCE_COLOR });
const target = graph.addNode(`${path}-${col}-target`, {
graph.addEdge(source, target, { size: 6, path, curvature: path === "curved" ? 0.3 : 0, ...config });
new Sigma(graph, container, {
shapes: [sdfCircle(), sdfTriangle()],
dashColor: { type: "color", default: "#000" },
dashSize: { type: "number", default: 0 },
useGradient: { type: "boolean", default: false },
paths: [pathLine(), pathCurved(), pathStepCurved(), pathCurvedS()],
extremities: [extremityArrow()],
layerPlain({ color: { node: "source" } }),
stops: [{ node: "source" }, { node: "target" }],
enabled: { attribute: "useGradient" },
dashColor: { attribute: "dashColor" },
dashSize: { attribute: "dashSize" },
nodes: [DEFAULT_STYLES.nodes, { size: 12, shape: { attribute: "shape" } }],
{ path: { attribute: "path" }, head: { attribute: "head" }, tail: { attribute: "tail" } },
itemSizesReference: "positions",