HTMLGraph

Orthogonal Edge Shape

The Orthogonal edge shape can be configured by calling the setDefaults method on CanvasBuilder.

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

const canvas = new CanvasBuilder(element)
  .setDefaults({
    edges: {
      shape: {
        type: "orthogonal",
        hasTargetArrow: true,
      },
    },
  })
  .build();

  

Alternatively, you can create a Orthogonal shape by passing a factory function into the configuration.

    
import { OrthogonalEdgeShape } from "@html-graph/html-graph";

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

const canvas = new CanvasBuilder(element)
  .setDefaults({
    edges: {
      shape: (edgeId) => new OrthogonalEdgeShape({ hasTargetArrow: true })
    },
  })
  .build();

  

The following configuration options are available:

NameTypeDescriptionRequiredDefault
colorstringColor of the line and arrowsno"#777777"
widthnumberLine widthno1
arrowRendererArrowRendererArrow shapeno{}
arrowLengthnumberFull length of the arrowno20
arrowOffsetnumberOffset from the arrow to the edge bendno15
hasSourceArrowbooleanDraw an arrow near the source portnofalse
hasTargetArrowbooleanDraw an arrow near the target portnofalse
cycleSquareSidenumberPort cycle square side sizeno30
roundnessnumberRoundness of the line anglesno10
detourDistancenumberNode cycle detour distanceno100
midpointElementHTMLElement | SVGElementElement to place in the middlenoundefined
interactiveDistancenumberDistance of the interactive areano0

You can also apply the Orthogonal shape to a specific edge using the addEdge and updateEdge methods.

    
import { OrthogonalEdgeShape } from "@html-graph/html-graph";

canvas.addEdge({
  from: "port-1",
  to: "port-2",
  shape: new OrthogonalEdgeShape(),
});

  
    
canvas.updateEdge("edge-1", {
  shape: new OrthogonalEdgeShape(),
});