Dave's Brain

Browse - Programming Tips - Products like Dia and Visio are great but I want to keep the

Date: 2013aug6
Product: Graphviz

Q.  Products like Dia and Visio are great but I want to keep the
description of the diagram in a text file -- like source code -- so its
easy to update.

How do I convert a text description of a relationship into a graphic image?

Is there a command-line equivalent of Dia/Visio?

A.  The solution I found is Graphviz.
On Fedora do this:

dnf install graphviz
This installs a program called "dot" (and others). Make a new folder:
mkdir /usr/local/src/mydiagram cd /usr/local/src/mydiagram
Make a new file in that folder called "mydiagram.dot" and put this in it (from the dot man page):
digraph test123 { a->b->c; a->{xy}; b[shape=box]; c[label="hellonworld",color=blue,fontsize=24, fontname="Palatino-Italic",fontcolor=red,style=filled]; a->z[label="hi",weight=100]; x->z[label="multi-linenlabel"]; edge[style=dashed,color=red]; b->x; {rank=same;bx} }
Turn that code into a diagram:
dot -Tpng mydiagram.dot -o mydiagram.png
Take a look at mydiagram.png You can work this into your Makefile. More info http://www.graphviz.org

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.