Live data from Hacker News

Create diagrams with code using Graphviz

ncona.com

91–100 of 221 posts

Re: Create diagrams with code using Graphviz

#91

I'm going to hijack this thread to ask if anyone knows of a library that creates "hand drawn"-style sequence diagrams from code? I basically want this: https://bramp.github.io/js-sequence-diagrams/ -- but sadly, this one only seems to run inside a browser.

there must be away to run it in a headless browser en screencapture and parse the output as png

Actually, it's pretty simple, just include https://github.com/markushedvall/plantuml-encoder and call

    "https://www.plantuml.com/plantuml/img/" + encode(text);
    
That's what I did on collabuml.

Re: Create diagrams with code using Graphviz

#92
I like Graphviz, but it's sad that we get such a tiny selection of graph-drawing algorithms to go with it. For instance, I don't see a way to draw a force-directed layout that also tries to account for edge direction, like a more flexible version of dot.

Re: Create diagrams with code using Graphviz

#93
Can anyone recommend a resource for learning how to diagram?

Notably, I don't want to free-design directional relationships that are counter intuitive to what people expect. Eg, if Service A calls Service B, does the arrow go to Service B? What about the response? I imagine there are a ton of little questions like this and I'd like to learn to write what people expect to see.

Re: Create diagrams with code using Graphviz

#94
post #88

I've gotten a lot of mileage from Graphviz over the years. As an example outside of work, I wanted a way to depict parse trees for an article I was writing. So, after I wrote an EBNF parser generator (great fun!), I wrote a little utility to apply a grammar to stdin and emit to stdout a JSON representation of the resulting parse tree; another utility handles converting the JSON to dot, which I can plot at my leisure.…

I was writing a parser recently, and I was fed up with having to look at a textual tree output. I did a bit of Googling, found Graphviz, and I had the whole thing working in like 15 minutes. I think it's absolutely essential to me now anytime I work with trees/graphs that I need to visualize.

Re: Create diagrams with code using Graphviz

#95
post #54

There seems to be somewhat of a myth that it's hard to get GraphViz diagrams to "look nice". I (obviously biased) feel that the diagrams I generated for my reference implementation of RETE look quite clean: https://github.com/bollu/rete#example-rete-diagrams-to-learn...

The instant place to look for graphviz issues is a distance between arrow head/tail to node. But yes your diagrams are very clean indeed!

Re: Create diagrams with code using Graphviz

#96
I love generating DOT from my Java programs. I recently implemented a query explainer that would output the query plan as DOT.

Btw. For those working with DOT I've always found it great to be able to copy-paste it right onto a webpage and see the results. My current favourite tool: https://dreampuf.github.io/GraphvizOnline/

Re: Create diagrams with code using Graphviz

#97
post #48

I found a great use for Graphviz recently. I needed to implement a model that was created by a scientist with no programming experience outside of a Fortran class in the early 1980s. Meanwhile, I didn't have much knowledge of the subject matter or terminology. The model was described in a multipage Excel file and an accompanying PDF and I implemented it in Clojure. In order to help us communicate, I wrote a script th…

I have used rather nice clojure library that also uses graphviz under the bonnet, with great success: https://github.com/Engelberg/ubergraph Did you use something similar or roll your own? In any case, your project sounds great and I am glad it was a success.

I used Rhizome[1]. (It looks like it is no longer being maintained, but I didn't run into any issues.)

1. https://github.com/ztellman/rhizome

Re: Create diagrams with code using Graphviz

#98
post #13

As much as I like Graphviz (and I've been using it for ages) I keep looking for an equivalent with two features: - Nicer, more modern looks (the original is too... LaTeX-y for my tastes) - A different layout engine that uses straight arrows and 90 degree turns So far I haven't been able to find any good replacements, although a few JS libraries come reasonably close.

It has been over a decade since I did this regularly, but I would import my Graphviz files into the excellent OmniGraffle (macOS) to provide what ever styling I wanted, and use a variety of highly configurable layout engines. Almost certain that the "straight arrows and 90 degree turns" layout is in there.

OmniGraffle is one of the best commercial software packages every developed. Well worth a look if you are on macOS

Re: Create diagrams with code using Graphviz

#100
post #34

A couple of important tips that the article omits: 1. For manual editing, dot -Tx11 foo.dot displays the graph in a window and updates it automatically whenever you save . So you can have an editor window open and the dot window and see the results of every tweak. For automatically generated graphs, this provides you with a window that you can update by overwriting a file with a new graph description. 2. Although HTM…

I used xdot in Ubuntu earlier this week and it crashed my Gnome session. Beware!
Post reply on HN