Looking for tools outputting DOT files

I am looking for (software architecture) tools outputting DOT files.

GraphViz is very flexible, but this comes at a cost: E.g. using HTML tables to write nodes with a simple Above-and-below-a-line label

Text Above Line
---------------------
Text Below Line

is pretty cumbersome.

Are there (preprocessor) tools known which make this and other things (like defining and using variables for colors, styles, etc) easier?

Don’t recall any general-purpose dot (DOT Language | Graphviz) translators or style-sheet systems.
But you can create dot filues using python, C, java, … interfaces and gvpr .
For that matter, dot is a text-based language, so nearly any programming language can easily produce it.

There are outstanding requests for a style-sheet addition, but to my knowledge no one is working on it. Some folks use M4 or cpp as pre-processors.

Note that you might not need an HTML-node to create text above & below a line, depending upon your specific formatting needs.

graph tlt {

  rankdir=LR
  
  a[label="1 text\n____\nmore text"]
  b[label="2 text\n------\nmore text"]
  c[label=<<U>3 text</U><BR/>more text>]
  d[label=<4 text<BR/>---------<br/>more text>]  
  /*  or create labels elsewhere and insert as images  */
}

textLineText

1 Like

If you don’t mind a random yaml format, I made https://azriel.im/dot_ix

The node_descs: key automatically inserts newlines according to the newlines in the string; and there is some styling support.

The generated dot file is in the second tab, but styles are generated on the page so you need tailwind plus some other processing to get the colors.

Otherwise, the generated svg is copied to clipboard when you click the second button from the top right when hovering over the diagram, which contains the styles inlined into the svg.

1 Like

Have a look at this post.

And the answer @jjlong has posted refering to the excel to graphviz tool. https://exceltographviz.com/

I am using it for archtectural drawings using osage layouts for consistency of layering etc, see Top Rank Node is not center aligned over some subgraphs

1 Like

Thanks for all the answers!

That’s what I’m doing at the moment: Python and mustache templating. Works but feels very one-off-ish.

gvpr looks very powerful, though rather intimidating. Are there examples beyond the extensive man page?

Thanks for the link. This gives great options to create the node shapes I am looking for.

The other thing I really would like are variables (for colours, etc) I can define and use in multiple places.

Maybe one day, when I have time (= never?) I write a little preprocessor in my new love child Scala 3. This preprocessor should do some form of:

  • “node expansion” to define nodes with HTML-like labels in a simpler way.
  • variable definition and use

You can find a set of smaller gvpr programs here
and a set of larger gvpr programs here

Here is a hardcoded gvpr stylesheet:

BEG_G{
}
N{
  $.color="#4271C6";  // default
}
N[_type=="process"] {
  $.shape="Mrecord";
  $.style="filled";
  $.fillcolor="#E1F4FF";
  // maybe redo $.label
}
N[_type=="subprocess"] {
  $.shape="record";
  $.style="filled";
  $.color="#FFFFFF";
  $.fillcolor="#A5A5A5";
  $.label=sprintf("|%s|", $.label);  // embed in pipes
}
N[_type=="database"] {
  $.shape="cylinder";
  $.color="#18589A";
}
N[_type=="inputoutput"] {
  $.shape="polygon";
  $.style='filled';
  $.fontcolor="white",
  $.ixedsize="true";
  $.skew="0.3";
  $.margin="0";
  $.width="2";
}
N[_type=="file"] {
  $.shape="folder";
}
N[_type=="external"] {
  $.shape="box3d";
}

And an accompanying .gv file

digraph pre{
  a [_type=process label="{1. Process\l | Something}"]
  b [_type=process label="{2. Process\l | Something else}"]
  c [_type=subprocess label="do it"]
  d [_type=database label="lots of data"]
  e [_type=database label="a bit of data"]
  f [_type=inputoutput label="inOut"]
  g [_type=file label="nail file"]
  h [_type=external label="outside"]  

 a->b->c->d->e->f->g->h
}

The trick is to generate the “stylesheet” real-time. Doable, but I could never come up with reasonable requirements.

1 Like

Thanks for these! From the 2nd set of examples I can conclude that you are quite a gvpr wiz!