Diagrams: Open-Source Alternative to Lucidchart
diagrams.net
diagrams.net
var editorUi;
Draw.loadPlugin(app => editorUi = app)
var editor = editorUi.editor
var graph = editor.graph
... then you can automate changes to the diagram using mxGraph's api [1] on the `graph' variable from the console.Around this plugin mechanism I wrote some dirty hacks for personal use to make the editor behave more to my likings [2] (some features stopped working with recent versions of the desktop app), and an even dirtier Emacs mode for editing labels and having the js REPL available directly from Emacs when I need to run some code to fix my diagrams programmatically [3] (based on Indium [4] + the fact that electron apps can be launched with --remote-debugging-port=...). It's not pretty, but works enough for me, and it's only thanks to the customizability that diagrams.net allows.
[1] https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGr...
[2] https://gitlab.com/spellcard199/drawio-plugin-eight-droves-o...
Since it may be of interest I'll add some notes.
You can get a console also in the desktop app if you launch it from a terminal adding --remote-debugging-port=..., then opening http://127.0.0.1:<port> from a chromium-based web browser.
A couple of useful functions that allow to listen to events are graph.model.addListener and graph.selectionModel.addListener. They are documented in the mxGraph api page.
You can make your functions persistent between sessions by putting your code in a javascript file, clicking from the desktop app on Extras > Plugins > Add > Select File... Then restart the app. In the web app "Select File..." is replaced by "Custom..." and the file should be some reacheable url. The javascript file can contain arbitrary javascript code, doesn't need to have a specific format.
Finally, to customize the ui actions, keybindings and menus without touching the various event listeners, this answer on stackexchange [1] from user holroy is what initially guided me in the right direction.
Then (a) no need for an automation to generate the image; (b) any image or svg is directly editable.
Do an 'Open from' > 'URL...' and paste in http://shagie.net/wp-content/uploads/2015/05/Untitled-Diagra... (an example diagram I made several years ago) - its a png itself and you can open that up as a png, but I also exported it with the drawing embedded.
So when you open that up in the app, you'll get the drawing - not the raster version.
Also consider that I created that png 7 years ago - other drawing document formats have been less stable over that timeframe. I'm quite impressed with it.
As you would expect, it has its pros and its cons. As diagrams get bigger and more complex, mermaid's auto-layout gets more and more challenged and more and more acres of white space start to appear. Of course drawing those same large diagrams manually would be a bitch too.
At small scale, auto-layout is a no-brainer, but the jury is still out for us on large, real world diagrams.
The guy that makes it is super helpful on twitter as well.
Ah, I've just realised, the article above pointed to a quote by Simon Brown - he is the Structurizr guy :-)
I've generally always found it difficult to find something in this space that produces a layout that's easy to follow, and easy to experiment with.
I think I'd like something that had: - layout constraints similar to the android relative layout - something like excalidraw that could dump the hand drawn diagram out to code for a bit of cleanup before going into VCS
I'm imagining you could solve the ability to inject new sections with the constraints relatively easily but still retain a good amount of creative control to better tell the story.
Any suggestions for tools to checkout?
Ideally, I want diagrams-as-code with a supporting layout-as-code document for fine-tuning the presentation and a wysiwyg tool for manipulating that layout-as-code document.
But I understand why none of this exists: the MVP is too big.
and of course, it's totally free unless you want its paid Apps+cloud version, which in my case I don't.
[1] https://marketplace.visualstudio.com/items?itemName=hediet.v...
I think they're sending me an SVG that my browser renders poorly, but that's a horrible first impression.
That said, the tool itself looks pretty solid, much better than the only other open source alternative I know (dia). Like many open source tools the UI design looks a bit old and it's chock full of advanced features that make the basic ones hard to find/use, but it's certainly usable.
And it's browser based, which means it runs anywhere, including Chromebooks.
Shit deal.
Not a flaw of diagrams.bet per se, but something to keep in mind before you decide to deploy it.
I was looking for something like this for a while, OneNote works but it's quite tedious. Just a canvas for mindmaps/diagrams/ideas.
This is one of the reasons I keep coming here, to discover new, useful software. Google is rather bad for that these days.
Thank you very much!
I'll see if I can contribute anything.
So kudos for that!
Great for flowcharts, at least that's my use