Articles in this section
Category / Section

How to load SVG file into JavaScript Diagram?

1 min read

You can load the SVG content diagram is achieved in application side. The addEventListener event in File Reader is used to get the SVG content. So, each group element in the SVG file can be added as an individual native node. 

A simple sample has been created for loading SVG file into the diagram. Please refer to the code example and sample as follows.

TS

reader.addEventListener("load", function (event) {
    var shape;
      var shapeContent = event.target.result;
      shape = { id: 'newflow' + id.toString(), shape: { type: 'Native', content: shapeContent }, offsetX: 150, offsetY: 150, height: 75, width: 75 };
      diagram.add(shape);
  });
  id++
  reader.readAsText(file);
 
  uploadObj.clearAll();
 
}

 

Sample link:

https://stackblitz.com/edit/5myckm-evlk4a?file=index.js


Conclusion

I hope you enjoyed learning about how to load SVG file into diagram.

You can refer to our JavaScript 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 JavaScript 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 forumsDirect-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
Please  to leave a comment
Access denied
Access denied