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:
man dia
One tip which at least I find very valuable is to enable the "Snap to grid" functionality, which makes it easier to align lines (I think I see a slightly misaligned line in Steve's diagram ;-) ).
Exporting to other formats directly from the command line is a great way of integrating Dia figures into the build processes for e.g., LaTeX documents, if you use Makefiles - this is another reason why I really, really like Dia.
// Simon
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Yes the snap to grid functionality is very nice - and you're right about misaligned things in that sample image. It was a quick job to update the diagram I had when the previous setup was replaced.
I'm very happy with dia - and the command line export is a wonderful addition to it. (I'll not tell anybody how long it took me to realise it was possible to use it that way ;)
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
I used them to create the diagram on my Linux clustering page and I'm pretty happy with the result. The icons are public domain, so hopefully they'll make their way into the main dia distribution soon.
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Good link - thanks for sharing.
It would be very nice to get some colour into the pictures :)
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
http://www.ipd.bth.se/ska/astar.pdf
where all animations (and all figures which are not simply screenshots) are created with Dia. For the animations, I use layers where the different steps are visible and then export EPS files with a subset of the layers visible.
The CVS version of Dia contains a --show-layers= option so that you can specify the layers on the command line (for integration into Makefiles), but personally I use the Debian package with local patches.
// Simon
[ Parent | Reply to this comment ]
I used to draw all of them with dia but after two or three months, little details irritated me.
I (re)discovered Inkscape and I now draw everything with it. It is a vectorial drawing editor I found excellent for all purposes. I agree it does not the same things as Dia and that it may be a "too much" if you just want to draw a quick diagram.
But I think it worths a try !
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Thanks for the recommendation - I've used inkscape in the past a few times, but I usually come back to dia for simple layouts.
As you say it's a different tool, and I can generally use dia to produce an image much quicker, so its something I recommend a lot.
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Probably not - they make me laugh!
I used to have a more coherant naming policy, which had sun, moon, earth, etc.
Then I retired machines and was left with mystery - because I decided I didn't want to continue the previous naming policy.
scratchy comes from my workplace, which previously had all machines named after characters from The Simpsons - it's been a name I've used a few times for "scratch" machines.
recurring is a literal name; the machine in question has been almost completely scrapped and rebuilt several times. That together with my almost complete abandonment of Windows at home, and the recent rebuild + installation of 2000 made the name recurring seem appropriate.
... if you look back over the much older articles you'll see a variety of different hostnames used in examples - most of them no longer used, but still remembered.
(My first Linux hostname was mice, I belive. Though it's been a long time ...)
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
My first linux box I named jacquard, becuase I had this idea at the time to make a loom and weave non-repeating patterns using fractal algorithms. (Maybe one day I'll still do that, but building a computerized loom is beyond me.)
jacquard eventually morphed into junkyard as it was old and slow to start with, and swapped in hard disks and things from other peoples' throwaway machines.
Then came garbarek, named after one of my favorite musicians, which is currently my mailserver.
My Mac OS X Powerbook is named banana, and I made my wife name her own machine (running the dreaded MS Windows OS), and she chose dragon.
So, I haven't been able to keep a "theme" going here either.
(BTW, Lappy and Recurring have the same IP address.)
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
Interesting question - mostly I've stuck with the ideas of RFC-1178: Choosing a name for your computer, that is a handy reminder when you have more than four or five machines to manage. But for my home I am more relaxed.
(BTW, Lappy and Recurring have the same IP address.)
True, and I never thought that was strange until you commented. They are never turned on on at the same time, so it works out OK for the moment .. probably should be fixed though.
Steve
-- Steve.org.uk
[ Parent | Reply to this comment ]
- hybris, fastest at home
- guinness, file/web-server
- evil, laptop
- baronbosse, retired gateway (name comes from a Swedish comic named "Assar")
- botong, Sparcstation2 (also name from "Assar")
- asimov, named 5 am
- ostron, (oyster) also named 5 am
- pingu
- ture, my (now dead) cat
- razor, SS5 at old workplace (also named from "Assar")
Ever noticed something? Unix comes with compilers. Windows comes with
Solitaire.
[ Parent | Reply to this comment ]
This is getting offtopic, but what are everyone else's hostnames?
I name mine with characters from the works of my favorite poet, William Blake, so they have names like vala, thel, edom, urizen.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
[ Parent | Reply to this comment ]