Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I export the elkt generated diagram to svg or png? #1101

Open
parrotcar00 opened this issue Dec 12, 2024 · 6 comments
Open

How do I export the elkt generated diagram to svg or png? #1101

parrotcar00 opened this issue Dec 12, 2024 · 6 comments
Labels
question Request for support in using ELK.

Comments

@parrotcar00
Copy link

How do I export a elk diagram that I created in the interactive editor, to svg, png or some other file format?

I tried searching in the repo but couldn't find anything.

@parrotcar00 parrotcar00 added the question Request for support in using ELK. label Dec 12, 2024
@soerendomroes
Copy link
Contributor

Well, you cannot. At least not directly, since it was not made for this. However, elk-cli does exactly that.

@parrotcar00
Copy link
Author

I see that elk-cli expects json input. Is there anyway I can supply elkt and get the output? Or some cli way to convert elkt to json so that I can use elk-cli?

@Eddykasp
Copy link
Contributor

The elk live demonstrator has a converter tool that you can use.

@parrotcar00
Copy link
Author

Thanks that works!
This means if I wanted to generate diagrams from elkt source in a headless fashion, the best way to do this right now would be:
elkt source -> use docker elk-live image to convert to json format -> elk-cli -> svg output.
Let me know if there is a better way overall.

@Eddykasp
Copy link
Contributor

Eddykasp commented Dec 13, 2024

The ELK tools don't really provide a better way since it isn't intended to be used for rendering. There is a PR in elkjs which might be interesting for you to look into.

To draw elkt graphs you may also want to look at klighd-vscode which has a vscode extension and a cli tool that can create renderings of elkt graphs and can also save these as svgs. I'm not sure there is currently an option to directly create svgs with only a command line invocation, but that is a functionality that I could imagine being built at some point if there is interest.

@parrotcar00
Copy link
Author

I think eclipse ELK is a fantastic DSL and should be used more often by people :)
One of the things that can be improved is having a cli version of the dsl.
Some advantages:

  1. Easier to run in a headless fashion
  2. Compilation errors are immediately seen on the terminal when the cli is invoked.

In my view the cli should allow either elkt or json input and output the svg/png file that we see in the interactive editor.
Since elk is written in java, maybe the cli should be a thin wrapper around the elk java library? This would make it the authoritative source of truth for parsing all elk sources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Request for support in using ELK.
Projects
None yet
Development

No branches or pull requests

3 participants