Skip to content

Custom Edge

This example demonstrates how to create custom edges in ngDiagram with unique visual styles and interactive elements. It showcases three different edge types:

  1. Default Edge:

    • a standard edge parametrized through model data
    • enhanced with a custom circular arrowhead marker defined in SVG
  2. Labeled Edge:

    • a custom edge with adjusted stroke width dynamically changing on selection
    • features interactive button label positioned at its midpoint
  3. Sinusoid Edge:

    • a custom wave-shaped edge with adjusted stroke color
    • renders a sinusoidal curve between nodes

The example illustrates key concepts including:

  • Creating custom edge components that implement NgDiagramEdgeTemplate
  • Adjusting parameters of NgDiagramBaseEdgeComponent in custom edges
  • Registering edge types using the edgeTemplateMap
  • Defining custom SVG markers for arrowheads
  • Adding interactive elements with BaseEdgeLabelComponent
  • Generating complex path calculations for non-standard edge shapes
import { Component } from '@angular/core';
@Component({
selector: 'circle-arrowhead',
template: `
<svg height="0" width="0">
<defs>
<marker
id="circle-arrowhead"
markerWidth="10"
markerHeight="10"
refX="8"
refY="5"
orient="auto"
>
<circle cx="5" cy="5" r="4" fill="red" />
</marker>
</defs>
</svg>
`,
})
export class CircleArrowheadComponent {}