A few days ago, I researched mermaid. Functionally, mermaid has more built-in types, but that’s not the main point. What I want to say is that I find the default flowchart theme of mermaid very comfortable to look at, with automatic coloring. Therefore, I am somewhat curious if Graphviz has a similar theme package feature that allows specifying a theme to automatically apply it to the images.
Since it is possible to specify the properties of a node-edge graph in the command line, can we directly store these properties in a file, and then simply read from this same file each time to maintain a consistent configuration?
Short answer: no. There are several current requests, but they are not being worked on (at least not publicly)
Longer mumble: There are several ways to approach this capability. But most are OS dependant and somewhat fiddly
- command line specification (your idea):
- fairly easy w/ Linux (& MACOS?), not sure on Windows
- e.g. dot -Tpng $(cat myconfig1.txt) myfile.gv …
- only allows one theme for all nodes and one for all edges
- use cpp (the c preprocessor / macro language), m4 another macro language, python, gawk, or … to include multiple config files throughout your .gv file
- e.g. #include myconfig.txt
- must have the desired program installed on your computer
- maybe more challenging on Windows
- it works
- only allows one set of node/edge configs at-a-time
- same as above, but add macro expansion to define multiple node / edge types
- all the benefits of the above
- supports multiple definitions at the same time
- starts to approach the complexity of programming in this second language
- like so:
command line: cpp -include "stylesheet0.cpp" stylesheetTest0.gv | dot ...
stylesheetTest0.gv:
graph test{
them [TeamA]
others [TeamB]
us [TeamA]
us -- them [EdgeYes]
us -- others [EdgeNo]
}
stylesheet0.cpp:
#define TeamA shape=circle style=filled fillcolor=lightblue color=red fontname=arial
#define TeamB shape=square style=filled fillcolor=pink
#define EdgeYes color=green penwidth=2
#define EdgeNo color=orange style=dashed penwidth=3
Giving:
Surprised, it can actually be used this way to generate a dot file using the cpp command. This should mean that it only utilizes the macro definition feature of cpp.
In that case, would it be more reasonable to use a gvpr file as the theme file and apply the theme by running gvpr once?
