Articles in this section

How to limit the text length of a node or connector annotation in Angular Diagram?

This article explains how to limit the text length of a node or connector annotation in Angular Diagram. To limit the text length of node or connector annotations in Syncfusion® Angular Diagram, follow these steps:

KeyUp Event:

• Handle the KeyUp event, which is triggered when editing the text of a node or connector annotation.
• In this event, define a variable maxLength to specify the maximum number of characters allowed for the annotation.

Length Validation:

• Compare the length of the entered text with the maxLength value.
• If the text length exceeds the maxLength, truncate the text using the slice method in JavaScript.
• Update the content property of the annotation by assigning the truncated text to args.label.content.
• Finally, call the endEdit() method to conclude the editing mode of the node or connector annotation.

<ejs-diagram
     #diagram
     id="diagram"
     width="100%"
     height="1000px"
     [connectors]="connectors"
     (keyUp)="keyUp($event)"
     (textEdit)="textEdit($event)"
>
</ejs-diagram>
 public keyUp(args: IKeyEventArgs) {
   let maxLength: number = 20;
   if (args.text.length > maxLength) {
     args.text = args.text.slice(0, maxLength);
     (args.label as AnnotationModel).content = args.text;
     this.diagram.endEdit();
   }
 }

Refer to the working sample for additional details and implementation:Sample

Conclusion

We hope you enjoyed learning about how to limit the text length of a node or connector annotation in Angular Diagram.

You can refer to our Angular Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our Angular Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components on the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied