HTMLGraph

Defaults Configuration

Use the setDefaults method of CanvasBuilder to establish base visualization settings. These defaults apply to all graph entities (nodes, ports, and edges) when no explicit values are provided.

    
const element = document.getElementById('canvas');

const canvas = new CanvasBuilder()
  .setElement(element)
  .setDefaults({
    nodes: {
      centerFn: (w, h) => ({ x: w / 2, y: h / 2 }),
      priority: 10,
    },
    ports: {
      direction: -Math.PI / 2,
    },
    edges: {
      shape: {
        type: "vertical",
        hasTargetArrow: true,
      },
      priority: 5,
    },
  })
  .build();

  

Configuration Parameters

SectionTypeDescriptionRequired
nodesNodesConfigConfiguration for nodesNo
portsPortsConfigConfiguration for portsNo
edgesEdgesConfigConfiguration for edgesNo