Class ShapeAnnotation
Represents a textual annotation that can be displayed over nodes and connectors in a diagram.
Inherited Members
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class ShapeAnnotation : Annotation, IDiagramObject, ICloneable
Remarks
The ShapeAnnotation class provides functionality to add descriptive text to diagram elements with customizable positioning, styling, and content formatting.
Annotations are positioned relative to their parent node or connector using offset values, and support various text formatting options including font styling, alignment, and wrapping behaviors.
Examples
The following example demonstrates how to create a node with a shape annotation:
Node node = new Node()
{
OffsetX = 250,
OffsetY = 250,
Width = 100,
Height = 100,
// Initialize the annotation collection
Annotations = new DiagramObjectCollection<ShapeAnnotation>()
{
new ShapeAnnotation
{
Content = "Node",
Offset = new DiagramPoint() { X = 0, Y = 0 }
}
},
};
Constructors
ShapeAnnotation()
Initializes a new instance of the ShapeAnnotation.
Declaration
public ShapeAnnotation()
ShapeAnnotation(ShapeAnnotation)
Creates a new instance of the ShapeAnnotation from the given ShapeAnnotation.
Declaration
public ShapeAnnotation(ShapeAnnotation src)
Parameters
Type | Name | Description |
---|---|---|
ShapeAnnotation | src | ShapeAnnotation |
Properties
Offset
Gets or sets the position of the annotation relative to its parent bounds.
Declaration
public DiagramPoint Offset { get; set; }
Property Value
Type | Description |
---|---|
DiagramPoint | A DiagramPoint representing the relative position of the annotation within its parent element's bounds.
The default value is |
Remarks
The Offset property determines where the annotation appears relative to its parent node or connector. The values are normalized coordinates where (0,0) represents the top-left corner and (1,1) represents the bottom-right corner of the parent bounds.
Examples
The following example demonstrates how to position an annotation at different locations:
Node node = new Node()
{
Annotations = new DiagramObjectCollection<ShapeAnnotation>()
{
new ShapeAnnotation
{
Content = "Node",
Offset = new DiagramPoint() { X = 0, Y = 0 } // Top-left corner
}
},
};
RotationReference
Gets or sets a value that indicates whether the annotation rotates along with its parent node or remains fixed relative to the page.
Declaration
public AnnotationRotationReference RotationReference { get; set; }
Property Value
Type | Description |
---|---|
AnnotationRotationReference | An AnnotationRotationReference specifying the rotation behavior of the annotation. The default value is Parent. |
Remarks
The RotationReference property controls how the annotation behaves when its parent node is rotated. When set to Parent, the annotation rotates along with the node, maintaining its relative position and orientation.
When set to Page, the annotation maintains its absolute orientation relative to the page, regardless of the parent node's rotation angle.
Examples
The following example demonstrates how to set an annotation to maintain its page orientation:
Node node = new Node()
{
Annotations = new DiagramObjectCollection<ShapeAnnotation>()
{
new ShapeAnnotation
{
Content = "Node",
ID = "Annotation",
RotationReference = AnnotationRotationReference.Page,
}
},
};
Methods
Clone()
Creates a new ShapeAnnotation that is a copy of the current annotation.
Declaration
public override object Clone()
Returns
Type | Description |
---|---|
System.Object | A new ShapeAnnotation object that is a deep copy of the current instance, containing identical property values and configuration settings. |