JavaScript is required

Link Data (RGLink)

RGLink is a runtime-derived, read-only relationship object.

It is generated from line data and provides convenient access to both endpoints plus render-related metadata.

1. Key Characteristics

  • You do not create RGLink directly.
  • You cannot update RGLink directly.
  • Update line/node data, then link data is recalculated automatically.

2. How to Get RGLink

const links = graphInstance.getLinks();
const link = graphInstance.getLinkByLineId('line-a-b');

3. Core Fields

  • lineId: string
  • line: RGLine
  • fromNode: RGNode
  • toNode: RGNode
  • totalLinesBetweenNodes: number
  • currentLineIndex: number
  • rgShouldRender?: boolean
  • rgCalcedVisibility?: boolean

4. Why RGLink Is Useful

RGLink is ideal when handling line events or building analysis logic:

  • find both endpoint node objects quickly
  • understand multi-line ordering between same node pair
  • read runtime visibility/render status

Example in line click event:

const onLineClick = (lineObject, linkObject, event) => {
  console.log('from:', linkObject.fromNode.id);
  console.log('to:', linkObject.toNode.id);
  console.log('index:', linkObject.currentLineIndex, '/', linkObject.totalLinesBetweenNodes);
};

5. Read-Only Data Flow

Correct update path:

  1. update RGLine / node data
  2. engine recalculates relation runtime state
  3. RGLink reflects latest state

6. Practical Notes

  • Treat RGLink as computed relationship context.
  • For persistence/export, save node/line/fakeLine data, not RGLink.
  • Use RGLink primarily in event handlers, inspectors, and runtime analysis tools.

7. Next Reading