Overview
TheCanvasEdgeData interface represents a connection (edge) between two nodes in an Obsidian canvas. Edges define relationships and visual connections, including which sides of nodes they connect to, their appearance, and optional labels.
Interface
Properties
The unique identifier for this edge. Must be unique within the canvas.
The ID of the node where this edge starts. Must match the
id of an existing node in the canvas.The side of the source node where this edge connects. Determines the visual attachment point.Possible values:
"top"- Connect to the top side"right"- Connect to the right side"bottom"- Connect to the bottom side"left"- Connect to the left side
What to display at the starting end of the edge. Defaults to
"none".Possible values:"none"- No decoration at the start"arrow"- Display an arrow at the start
The ID of the node where this edge ends. Must match the
id of an existing node in the canvas.The side of the destination node where this edge connects. Determines the visual attachment point.Possible values:
"top"- Connect to the top side"right"- Connect to the right side"bottom"- Connect to the bottom side"left"- Connect to the left side
What to display at the ending end of the edge. Defaults to
"arrow".Possible values:"none"- No decoration at the end"arrow"- Display an arrow at the end
The color of this edge. Can be a number (like
"1") representing one of the currently 6 supported colors, or a custom color using the hex format "#FFFFFF".An optional text label to display on the edge. Useful for describing the relationship between connected nodes.
Supports arbitrary additional keys for forward compatibility. This allows edges to contain custom properties that may be used by future versions or plugins.
Related Types
NodeSide
Defines which side of a node an edge connects to:EdgeEnd
Defines what decoration appears at the end of an edge:CanvasColor
A string representing a color, either as a number or hex code:Examples
Basic Edge
A simple edge connecting two nodes with default settings:node-a to node-b with:
- Automatically determined connection sides
- No decoration at the start (
fromEnddefaults to"none") - An arrow at the end (
toEnddefaults to"arrow")
Bidirectional Edge
An edge with arrows on both ends:Labeled Edge
An edge with a descriptive label:Precise Connection Points
An edge with explicitly defined connection sides:Line Without Arrows
A simple connecting line with no arrows:Usage Example
Working with Edges
Finding Edges for a Node
Validating Edge Connections
Finding Connected Nodes
Best Practices
- Unique IDs: Always ensure edge IDs are unique within the canvas
- Valid References: Verify that
fromNodeandtoNodereference existing nodes - Meaningful Labels: Use labels to clarify relationships when the connection isn’t obvious
- Color Consistency: Use consistent colors to represent similar types of relationships
- Avoid Cycles: Be mindful of creating circular dependencies that might confuse users
Related Types
- CanvasData - The top-level canvas file structure
- CanvasNodeData - Interfaces for canvas nodes
NodeSide- Type for node connection sidesEdgeEnd- Type for edge end decorationsCanvasColor- Type for color encoding