Articles in this section

how to upload /add image in symbol palette in Angular Diagram?

This article provides an explanation of how to upload and add an image to the symbol palette using the uploader component in the Syncfusion® Angular Diagram Component. In the provided example, we demonstrate how to add a button to facilitate importing an image from the local system. When the button is clicked, it triggers a file selection dialog that allows users to choose an image from their local storage.

       document.getElementById('browse').onclick = () => {
           document.getElementsByClassName('e-file-select-wrap')[0].querySelector('button').click();
           return false;
       }; 

Once an image is selected, the application processes the upload, and upon successful completion, the onUploadSuccess method is invoked. This method is responsible for updating the symbol palette by adding the newly uploaded image as a node.

public onUploadSuccess(arg: any): void {
       let file1: any = arg.file;
       let file: any = file1.rawFile;
       let reader: FileReader = new FileReader();
       reader.addEventListener('load', (event: any): void => {
           let shape: NodeModel;
           let shapeContent: string = event.target.result;
           shape = { id: 'newshape' + this.id.toString(), shape: { type: 'Image', source: shapeContent } };
           this.palete.addPaletteItem('network', shape);
       });
       this.id++;
       reader.readAsDataURL(file);
       this.uploadObj.clearAll();
   } 

After the image is added to the symbol palette, it becomes available for use. You can drag the image from the palette and drop it onto the diagram canvas, seamlessly integrating it into your workflow. This feature enhances the user experience by allowing dynamic updates to the palette and enabling users to personalize their diagrams with custom images.

Please refer to the working sample for reference.
Sample

Conclusion
I hope you enjoyed learning how to upload /add image in symbol palette in Angular Diagram.

You can refer to our Angular Diagram 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 Diagram 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, Direct-Trac, 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