drawing diagrams in django?

94 views
Skip to first unread message

Alistair Marshall

unread,
Jan 10, 2009, 3:41:19 PM1/10/09
to Django users
hi folks,

I am currently trying to create an app which allows the user to
generate flowsheets (of a chemical plant)

So far I have created all the basics and allow the user to enter
information about the individual unitsw chemicals etc and the user can
even run a simulation.

what I now want to do is create a graphical overview of the process. I
want to be able to draw out the flowsheet to an image and perhaps even
allow the user to click on areas of the image to be linked to that
section of the process.

Currently I have a very rough function that generates x,y coardanites
of each unit (though this could be improved greatly). All I really
need is a simple method of drawing lines (or arrows), saving them to a
png, and returning the saved location.

I was wondering if anyone else had a simalar drawing requirement and
to ask what they use

Thanks
Alistair

Jeff Hammerbacher

unread,
Jan 10, 2009, 3:58:15 PM1/10/09
to django...@googlegroups.com
Hey Alistair,

For static image generation, I've used pygraphviz (http://networkx.lanl.gov/pygraphviz/), a Python interface to AT&T's graphviz library.

Regards,
Jeff

aastrand

unread,
Jan 10, 2009, 7:03:41 PM1/10/09
to Django users


On Jan 10, 9:41 pm, Alistair Marshall <runninga...@googlemail.com>
wrote:
For high-quality graphics, you should really aim at producing svg-
files ( http://www.w3.org/Graphics/SVG/ ). Last time I looked for it,
I only found early attempts of a python library for drawing svg
figures, but perhaps this one has become good enough: http://codeboje.de/pysvg/

Cheers,

Per-Olof

Malcolm Tredinnick

unread,
Jan 11, 2009, 2:30:09 AM1/11/09
to django...@googlegroups.com
On Sat, 2009-01-10 at 12:58 -0800, Jeff Hammerbacher wrote:
> Hey Alistair,
>
> For static image generation, I've used pygraphviz
> (http://networkx.lanl.gov/pygraphviz/), a Python interface to AT&T's
> graphviz library.

pydot is another Python library for working with Graphviz. Whichever one
you might prefer (and I found them to be fairly similar, although I've
probably used pydot a little more just because an old client used it),
it's certainly a good approach for things like flowchart processes,
since they are pretty easily expressible as graphs.

Somebody else in the thread mentioned SVG, which is also a possibility.
You'll have more control over the fine details of the results, at the
cost of having to do more work to actually produce things. SVG being a
low-level drawing API, Graphviz's dot language being a higher-level API
for specifying graph-like structures. Probably the nicest svg bindings
these days are the rsvg ones (Python bindings for the C-library
librsvg). They use cairo as the output library, which gives very nice
results.

If it was me, I'd start by looking at the graphviz approach, since it
fits the problem description most naturally.

Regards,
Malcolm


Reply all
Reply to author
Forward
0 new messages