Generating graphs from db data and displaying results using Django?

886 views
Skip to first unread message

Chris Rich

unread,
Jul 10, 2007, 6:03:28 PM7/10/07
to Django users
Hey all,
So, I'm a beginner here with Django/webdesign/database stuff/all the
rest of it and I may be getting ahead of myself. I am currently
getting my feet wet in the Django environment, but I eventually want
to graph/calculate averages on some of the values in my database. I
would like to display the results in my Django page and maybe even
make it so I could change some of the graph parameters using some
simple Django forms. Any ideas on the best way to go about this?
Thanks in advance.

Chris

gw...@recordernews.com

unread,
Jul 10, 2007, 6:26:43 PM7/10/07
to Django users

flo...@gmail.com

unread,
Jul 11, 2007, 12:56:03 PM7/11/07
to Django users
I would actually suggest using Django to create a web service to get
the data, and a JavaScript charting library to do the drawing client-
side. A great one is PlotKit (http://www.liquidx.net/plotkit/)

A (very) simple example of how this could look is on my personal
website http://www.eflorenzano.com/runs/

Note that PlotKit has many methods for dynamically updating the
graph. I really think that this route is the way to go.

Forest Bond

unread,
Jul 11, 2007, 1:06:16 PM7/11/07
to django...@googlegroups.com
On Wed, Jul 11, 2007 at 04:56:03PM -0000, flo...@gmail.com wrote:
>
> I would actually suggest using Django to create a web service to get
> the data, and a JavaScript charting library to do the drawing client-
> side.

Why not create the graphs on the server?

-Forest

signature.asc

Vincent Nijs

unread,
Jul 11, 2007, 1:12:06 PM7/11/07
to django...@googlegroups.com

Toby Dylan Hocking

unread,
Jul 11, 2007, 8:24:29 PM7/11/07
to django...@googlegroups.com
You guys should definitely check my new framework for making data-driven
plots with Django (installation instructions in INSTALL.txt):

http://www.ocf.berkeley.edu/~tdhock/dataplot-0.2.tgz

So far django.contrib.dataplot only uses the R programming language to
generate images server-side, but the great part (as yet undocumented) is
that it is compatible general enough to handle several different backend
plotting languages, such as matplotlib, pil, octave, etc.

Sincerely,
Toby Dylan Hocking
http://www.ocf.berkeley.edu/~tdhock

Jeremy Dunck

unread,
Jul 11, 2007, 8:36:04 PM7/11/07
to django...@googlegroups.com
On 7/11/07, Toby Dylan Hocking <tdh...@ocf.berkeley.edu> wrote:
> general enough to handle several different backend
> plotting languages, such as matplotlib, pil, octave,

How hard would it be to depend on PIL rather than ImageMagick? I'm
asking because Django already requires PIL if you want ImageField, and
it's a shame to depend on both.

(I know there are different features in each and you may have a good
reason for choosing Magick.)

nick feng

unread,
Jul 11, 2007, 9:15:51 PM7/11/07
to django...@googlegroups.com
Which database is better for django, PostgreSQL or MYSQL?

Toby Dylan Hocking

unread,
Jul 11, 2007, 9:50:25 PM7/11/07
to django...@googlegroups.com
Thanks for the input, Jeremy. I'd definitely be open to using PIL instead
of ImageMagick. django.contrib.dataplot use of ImageMagick is relatively
simple: taking vector PDFs drawn in R and converting them to fullscreen
and thumbnail raster PNGs.

Do you know of a way that PIL can be used to convert PDF to PNG? A quick
google search reveals this pdf
(http://www.pythonware.com/media/data/pil-handbook.pdf) which suggests
that PIL is only capable of writing PDFs (p69).

What I meant by


>> general enough to handle several different backend
>> plotting languages, such as matplotlib, pil, octave,

was that if a Django app wanted to use pil to draw the initial PDF (rather
than R), then the django.contrib.dataplot framework is perfectly
extensible for that purpose (not with current 0.2 release, but these
generalized plotting backends are a planned feature for my next release,
0.3).

Sincerely,
Toby Dylan Hocking
http://www.ocf.berkeley.edu/~tdhock

Kenneth Gonsalves

unread,
Jul 11, 2007, 10:32:26 PM7/11/07
to django...@googlegroups.com

On 12-Jul-07, at 6:45 AM, nick feng wrote:

> Which database is better for django, PostgreSQL or MYSQL?

postgresql - general, not for django in particular

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/


Michael Radziej

unread,
Jul 12, 2007, 12:58:59 AM7/12/07
to django...@googlegroups.com
On Thu, Jul 12, Kenneth Gonsalves wrote:

>
>
> On 12-Jul-07, at 6:45 AM, nick feng wrote:
>
> > Which database is better for django, PostgreSQL or MYSQL?
>
> postgresql - general, not for django in particular

mysql does not support django fixtures (unless you use the ISAM storage
engine in mysql, and then you don't have transactions).

Michael

Frank Tegtmeyer

unread,
Jul 12, 2007, 5:57:52 AM7/12/07
to django...@googlegroups.com
Toby Dylan Hocking <tdh...@OCF.Berkeley.EDU> writes:

> Thanks for the input, Jeremy. I'd definitely be open to using PIL instead
> of ImageMagick.

> Do you know of a way that PIL can be used to convert PDF to PNG? A quick

> google search reveals this pdf

Wouldn't it be possible to adapt ZSVG_Graph to Django?

Link: http://www.zope.org/Members/aho/ZSVG_Graph

Regards, Frank

Silas

unread,
Jul 12, 2007, 8:31:07 AM7/12/07
to Django users

If it is a personal site take a look at http://www.maani.us/xml_charts/
they have some really nice charts that are flash based.
All the data is sent via xml.

Toby Dylan Hocking

unread,
Jul 12, 2007, 10:10:45 AM7/12/07
to Django users
Hi Silas,

> If it is a personal site take a look at http://www.maani.us/xml_charts/
> they have some really nice charts that are flash based.
> All the data is sent via xml.

Thanks for your input. However, I don't like the idea of forcing people to
use flash to look at plots, since (unlike Django, R, Python, and RPy)
Flash is not free software. Furthermore, it seems that there are no
advanced statistical capabilities available with the XML/SWF Charts
package, locking you into the particular charts and data analysis methods
that the package author has written.

One of the major benefits to using R is that it is a programming language
with many extension packages for different types of data analysis. It's
really easy to do simple statistical tests and more advanced statistical
modeling in R, and have the results displayed on your plot (or returned
back to Python). Furthermore, the modes of plotting are much more
customizable, i.e.

http://www.ocf.berkeley.edu/~tdhock/plot-history/
http://www.r-project.org/screenshots/screenshots.html

The idea with django.contrib.dataplot is that it provides the framework
for interfacing with Django, and some default generic plot types (Scatter,
TimeSeries, etc. similar to XML/SWF Charts), but you can pop in your own
plotting code and have a totally custom plot too, if you need to.

Sincerely,
Toby Dylan Hocking
http://www.ocf.berkeley.edu/~tdhock

Toby Dylan Hocking

unread,
Jul 12, 2007, 11:06:29 AM7/12/07
to django...@googlegroups.com
Hi Frank,

> Wouldn't it be possible to adapt ZSVG_Graph to Django?

Thanks for the suggestion. In fact, I was already considering SVG output
as one of the modes of django.contrib.dataplot. One of the cool things
about django.contrib.dataplot is its extensibility -- getting a new type
of plot, say an SVG scatterplot with id number labels and hyperlinks to
the related detail pages, is as easy as writing a new plotting function in
R. To that end, an SVG driver for R exists already:

http://www.stat.auckland.ac.nz/~paul/Talks/gridSVG/slide1.html

So I was planning on using R and the gridSVG package for SVG output
functionality. I don't know how useful a contribution ZSVG_Graph would be
to our Django community, since it seems that its last update was over 2
years ago:

http://sourceforge.net/project/showfiles.php?group_id=9295&package_id=92256

Sincerely,
Toby Dylan Hocking
http://www.ocf.berkeley.edu/~tdhock

On Thu, 12 Jul 2007, Frank Tegtmeyer wrote:

>
> Toby Dylan Hocking <tdh...@OCF.Berkeley.EDU> writes:
>
>> Thanks for the input, Jeremy. I'd definitely be open to using PIL instead
>> of ImageMagick.
>
>> Do you know of a way that PIL can be used to convert PDF to PNG? A quick
>> google search reveals this pdf
>
>

Frank Tegtmeyer

unread,
Jul 13, 2007, 5:35:06 AM7/13/07
to django...@googlegroups.com
Toby Dylan Hocking <tdh...@OCF.Berkeley.EDU> writes:

> TimeSeries, etc. similar to XML/SWF Charts), but you can pop in your own
> plotting code and have a totally custom plot too, if you need to.

Such flexibility is great. I suggest to support "common" tasks too
by providing an additional "simple" interface (if it is not already
there, I didn't have a look at your package yet). Something like Tex
and LaTeX, the one for total control, the other for common tasks.

Regards, Frank

Reply all
Reply to author
Forward
0 new messages