Creating network diagrams with dia
Posted by Steve on Mon 25 Jul 2005 at 13:16
There are many times when you'll want to create network diagrams, or other simple diagrams using a combination of linked images and straight lines. The dia application is perfect for this.
dia describes itself as an editor for diagrams, graphics, and charts. That's pretty much what it is, a simple layout and diagram generator stocked with a collection of themed image sets.
When installed you're presented with a toolbox containing the image sets, along with a blank canvas to start drawing with.
It's operation is very intuitive. As expected simply selecting one of the tools upon the toolbox allows you to drop it upon the canvas with a simple click. Moving objects once they are in place is likewise supported, as are the other common operations such as multiple selection, copying and pasting.
In addition to the collections of images, you also have a variety of line drawing tools, which can be anchored to images - so when the image moves the line does too.
When you've finished producing your masterpiece you can save it as a .dia file, (which is really a compressed XML document), or you can use the "Export" option to export the diagram into other formats.
Available output formats include, .png, .svg, and formats relating to editing with other packages.
dia can also be used upon Microsoft Windows, if you need to allow other people to edit your work - or if you have a mixed environment. A binary distribution allows simple installation, along with all dependencies for Windows.
To install it upon Debian you can use apt-get as root, by running:
apt-get install dia
As a sample of the kind of images you can produce here's a copy of my current home setup:
Because the .dia files are nothing more than simple XML files which have been compressed with the standard gzip encoding you can generate them programmatically if you wish.
Generating programmatic input is very useful when combined with the scriptable output dia supports. The conversion of an input file to an output file can be generated using some of the optional command line options.
For example we can take a previously drawn file and convert this to a .png file with the following example command line:
dia --export=blah.png -t png -s 200x600 Diagram1.dia
Here we have exported the input file Diagram1.dia to an output file blah.png using the png format (which was set with "-t png"). The image output size was set to 200x600 pixels with the -s flag.
The command line generation doesn't require the use of a valid X11 display - although if you do run it without X11 you'll get a warning:
could not import gtkcons.py
This warning appears to be harmless.
For a description of the available command line options, and the format strings to pass to the -t option please consult the man page via: