Articles in this section

How to change the font formatting of annotations at runtime in Angular diagram

This article explains how to change the font formatting of annotations at runtime in Angular Diagram. An Annotation is a text label that appears on a node or connector in an Angular Diagram, allowing you to describe or label the object. Annotation is used to textually represent an object with a string that can be edited at runtime.

You can easily customize annotations by adjusting font properties such as bold, italic, underline, size, text color, and background color, enhancing the clarity and appearance of your diagram.

Below is a code example demonstrating how to set the initial font formatting for annotations on nodes and connectors:

//initializes diagram with node and connector
 <ejs-diagram #diagram id="diagram" width="100%" height="580px" [getNodeDefaults] ='getNodeDefaults'>
       <e-nodes>
           <e-node id='node1' [offsetX]=250 [offsetY]=250>
               <e-node-annotations>
                   <e-node-annotation id="label1" content="Annotation Text" [style]="style">
                   </e-node-annotation>
               </e-node-annotations>
           </e-node>
       </e-nodes>
       <e-connectors>
           <e-connector id='connector' type='Straight' [sourcePoint]='sourcePoint' [targetPoint]='targetPoint'>
           <e-connector-annotations>
                   <e-connector-annotation id="label" content="Annotation Text" [style]="style">
                   </e-connector-annotation>
               </e-connector-annotations>
           </e-connector>
       </e-connectors> 
   </ejs-diagram> 

The code snippet below illustrates how to updates the annotation font formats for a node and a connector, followed by updating the diagram to reflect the changes:

Bold() {
       (((this.diagram as Diagram).nodes[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).bold = true;
       (((this.diagram as Diagram).connectors[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).bold = true;
   }
   Italic() {
       (((this.diagram as Diagram).nodes[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).italic = true;
       (((this.diagram as Diagram).connectors[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).italic = true;
   }
   Underline() {
       (((this.diagram as Diagram).nodes[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).textDecoration = 'Underline';
       (((this.diagram as Diagram).connectors[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).textDecoration = 'Underline';
   }
   Size(args: any) {
       (((this.diagram as Diagram).nodes[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).fontSize = Number(args.target.value);
       (((this.diagram as Diagram).connectors[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).fontSize = Number(args.target.value);
       (this.diagram as any).dataBind();
   }
   applyColor(args: any) {
       (((this.diagram as Diagram).nodes[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).color = args.target.value;
       (((this.diagram as Diagram).connectors[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).color = args.target.value;
       this.diagram?.dataBind();
   }
   applybgColor(args: any) {
       (((this.diagram as Diagram).nodes[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).fill = args.target.value;
       (((this.diagram as Diagram).connectors[0].annotations as ShapeAnnotationModel[])[0].style as TextStyleModel).fill = args.target.value;
       this.diagram?.dataBind();

   }

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

Conclusion

We hope you enjoyed learning on how to add custom icons to floating labels in Angular ComboBox.

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

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out 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