Class PathAnnotation
Represents a PathAnnotation that displays text content along or over a connector path in a diagram.
Inherited Members
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class PathAnnotation : Annotation, IDiagramObject, ICloneable
Remarks
The PathAnnotation class provides functionality to add textual annotations to connectors, allowing text to be positioned and displayed along the connector's path or at specific locations relative to the connector.
Examples
Connector connector = new Connector()
{
Annotations = new DiagramObjectCollection<PathAnnotation>()
{
new PathAnnotation
{
Content = "Connector",
Offset = 0,
ID = "Annotation",
}
},
};
Constructors
PathAnnotation()
Initializes a new instance of the PathAnnotation.
Declaration
public PathAnnotation()
PathAnnotation(PathAnnotation)
Initializes a new instance of the PathAnnotation class by copying properties from an existing PathAnnotation instance.
Declaration
public PathAnnotation(PathAnnotation src)
Parameters
Type | Name | Description |
---|---|---|
PathAnnotation | src | The source PathAnnotation instance to copy from. |
Properties
Alignment
Gets or sets the alignment of a PathAnnotation along a Connector segment.
Declaration
public AnnotationAlignment Alignment { get; set; }
Property Value
Type | Description |
---|---|
AnnotationAlignment | An AnnotationAlignment specifying how the annotation is positioned relative to the connector segment. The default value is Center. |
Remarks
The following alignment options are available:
- Center - Annotation is placed directly on the connector segment
- Before - Annotation is positioned above or to the left of the connector segment
- After - Annotation is positioned below or to the right of the connector segment
The actual visual positioning (above/below or left/right) depends on the connector's orientation and direction.
Examples
The following example demonstrates how to set the alignment of a PathAnnotation on a connector.
Connector connector = new Connector()
{
Annotations = new DiagramObjectCollection<PathAnnotation>()
{
new PathAnnotation
{
Content = "Connector",
Alignment = AnnotationAlignment.After,
ID = "Annotation",
}
},
};
Displacement
Gets or sets the displacement (margin) of a PathAnnotation from its actual position along the Connector path.
Declaration
public DiagramPoint Displacement { get; set; }
Property Value
Type | Description |
---|---|
DiagramPoint | A DiagramPoint representing the X and Y offset values that displace the annotation from its calculated position on the connector. The default value is null. |
Remarks
When null, no displacement is applied and the annotation appears at its calculated position. Positive X values move the annotation to the right, negative values to the left. Positive Y values move the annotation down, negative values move it up.
Examples
The following example demonstrates how to set the displacement of a PathAnnotation to offset it from the connector path.
Connector connector = new Connector()
{
Annotations = new DiagramObjectCollection<PathAnnotation>()
{
new PathAnnotation
{
Content = "Connector",
Offset = 0,
Displacement = new DiagramPoint() { X = 100, Y = 100 },
ID = "Annotation",
}
},
};
Offset
Gets or sets the offset of an annotation along the Connector path.
Declaration
public double Offset { get; set; }
Property Value
Type | Description |
---|---|
System.Double | A System.Double representing the position of the annotation along the connector path. The default value is |
Remarks
The offset value determines where the annotation is positioned along the connector's path. A value of 0 places the annotation at the source node, 0.5 at the midpoint, and 1 at the target node.
Examples
The following example demonstrates how to set the offset of a PathAnnotation on a connector.
Connector connector = new Connector()
{
Annotations = new DiagramObjectCollection<PathAnnotation>()
{
new PathAnnotation
{
Content = "Connector",
Offset = 0,
ID = "Annotation",
}
},
};
SegmentAngle
Gets or sets a value indicating whether the PathAnnotation should be rotated based on the connector segment direction.
Declaration
public bool SegmentAngle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A System.Boolean indicating the rotation behavior of the annotation. The default value is false. |
Remarks
The segment angle property controls how the annotation is oriented relative to the connector's path. When set to false, the annotation follows the natural curve or angle of the connector path.
When set to true, the annotation's rotation is calculated based on the specific segment of the connector where it is positioned
Examples
The following example demonstrates how to set the segment angle behavior of a PathAnnotation on a connector.
Connector connector = new Connector()
{
SourcePoint = new DiagramPoint() { X = 300, Y = 100 },
TargetPoint = new DiagramPoint() { X = 400, Y = 200 },
// Initialize annotation collection
Annotations = new DiagramObjectCollection<PathAnnotation>()
{
new PathAnnotation
{
Content = "Connector",
Offset = 0,
Alignment = AnnotationAlignment.After,
SegmentAngle = true,
ID = "Annotation",
}
},
};
Methods
Clone()
Creates a new PathAnnotation that is a copy of the current annotation.
Declaration
public override object Clone()
Returns
Type | Description |
---|---|
System.Object | A new PathAnnotation object that is a deep copy of the current instance, containing identical property values and configuration settings. |