TypeScript Types
This page summarizes the core type system in relation-graph so you can work confidently across data, options, events, and UI components.
1. Type Map
The most important types are grouped into 6 categories:
- Graph data:
JsonNode,JsonLine,RGNode,RGLine,RGLink - Options/config:
RGOptions,RGOptionsFull,RGLayoutOptions - Interaction/events:
RGListeners,RGEventNames,RGUserEvent - Coordinates/layout math:
RGCoordinate,RGPosition,RGNodesRectBox - Component props:
RelationGraphProps,RGToolBarProps,RGMiniViewProps - Runtime state:
RGCreatingLine,RGEditingNodes,RGCheckedItem, etc.
2. Data Model Types
JsonNode / RGNode
JsonNode: input/persistence node shapeRGNode: runtime node object (includes rendering/runtime fields)
Common fields:
- identity/text:
id,text,type - geometry:
x,y,width,height - style:
color,borderColor,fontSize,nodeShape - business extension:
data
JsonLine / RGLine / RGLink
JsonLine: input/persistence line shapeRGLine: runtime line objectRGLink: relation object between two nodes (multiple lines may map to one node pair)
Common fields:
- endpoints:
from,to - text/style:
text,color,lineWidth,lineShape - advanced junctions:
fromJunctionPoint,toJunctionPoint - business extension:
data
3. Enums and Base Types
High-frequency base types:
RGNodeShape:circle/rectRGLineShape:StandardCurve,StandardOrthogonal, etc.RGJunctionPoint:left/right/top/bottom/border/ltrb/tb/lrRGWidgetPosition:top/right/bottom/left/tl/tr/bl/brRGEventTargetType:'canvas' | 'node' | 'line'RGUserEvent:MouseEvent | TouchEvent
4. Option Types
RGOptions (user-configurable)
Typical fields:
- interaction:
wheelEventAction,dragEventAction - visibility:
showToolBar,backgroundColor - default style:
defaultNodeColor,defaultLineColor,defaultLineShape - layout:
layout(RGLayoutOptions) - zoom limits:
minCanvasZoom,maxCanvasZoom
RGOptionsFull (runtime full options)
RGOptionsFull extends RGOptions with runtime state (current zoom, canvasOffset, editing state, etc.).
It is usually not meant for direct manual construction or persistence.
5. Layout Types
RGLayoutOptions is a union type. Common variants:
RGForceLayoutOptionsRGCenterLayoutOptionsRGTreeLayoutOptions
Shared/common fields:
layoutNamelayoutDirectionfixedRootNode- alignment options:
alignItemsX,alignItemsY
6. Event Types
RGListeners
Event contract for <RelationGraph />, covering:
- lifecycle (
onReady) - click/drag (
onNodeClick,onNodeDragging, etc.) - zoom/scroll (
beforeZoomStart,beforeScrollStart) - editing lifecycle (
beforeCreateLine,onLineBeCreated, etc.)
RGEventNames
Enum of event names, useful for event buses and unified telemetry/logging.
7. Component Prop Types
RelationGraphProps = RGListeners & { options: RGOptions; ... }RGToolBarProps: toolbar direction and alignmentRGMiniViewProps: minimap position, size, and styleRGEditingLineControllerProps:textEditable,pathEditable, line-edit callbacks
8. Coordinate and Geometry Types
RGCoordinate:{ x, y }RGPosition: same shape as coordinate, used semantically for positionsRGNodesRectBox: bounding box (minX/maxX/minY/maxY/width/height)RGSelectionView: rectangle-selection area
9. Import Example
import type {
RGOptions,
RGLayoutOptions,
JsonNode,
JsonLine,
RGNode,
RGLine,
RGLink,
RGListeners
} from "@relation-graph/vue3";
For React / Vue2 / Svelte, import from the corresponding package name.
10. Practical Advice
- Use
JsonNode/JsonLinefor persistence,RGNode/RGLinefor runtime rendering logic. - Put business payload in
datainstead of scattering top-level fields. - Define project-level extensions (
MyNodeData,MyLineData) early. - Prefer exposing
Json*types in service boundaries to avoid runtime-field coupling.