marcveens / react-drawio

React component for integrating the Diagrams (draw.io) embed iframe
MIT License
43 stars 8 forks source link

Programmatically Importing CSV into Draw.io via Component #33

Closed SasiDharan731 closed 1 month ago

SasiDharan731 commented 1 month ago

I have a CSV file that can be manually imported into Draw.io by navigating to Arrange > Insert > Advanced > CSV, which fills the editor with a diagram. I am interested in achieving similar functionality programmatically. Is it possible to pass the CSV file directly into a component, for example:

<DrawIoEmbed csv="path/to/csv"/>

Thank you.

marcveens commented 1 month ago

Thanks for the request. I just released a new version with csv support :)

For an example, see https://marcveens.github.io/react-drawio/?path=/story/components-drawioembed--with-remote-csv

And have a look at the code: https://github.com/marcveens/react-drawio/blob/d33d09155e33da98c9c6045dcc0c6902b202a68b/stories/DiagramsEmbed.stories.tsx#L85C1-L98C3

The csv property of the component expects the actual string from the csv file, so it's up to you how to load the file in your application. In the Storybook file I added an example of how you could do it.

SasiDharan731 commented 1 month ago

Thanks so much for the quick response and update! and I'm glad to hear that the new version includes support for CSV import. This is exactly what I was looking for, and I really appreciate your help!