[mod_python] does a mod_python handler exist to generate charts/graphs? (png images)

David Fraser davidf at sjsoft.com
Thu Sep 18 22:45:25 EST 2003


perry.tew at cibavision.novartis.com wrote:

>>perry.tew at cibavision.novartis.com wrote:
>>
>>>Hello everyone,
>>>  I was about the go down the road of developing a handler to generate 
>>>charts,
>>>similar to the mod_perl Apache::GD::Graph.  I wanted to make sure 
>>>something doesn't exist
>>>before I reinvent the wheel.  Does anyone know of such a thing yet?  If 
>>>so, would you please
>>>provide a url?
>>>
>>>Thanks,
>>>Perry Tew
>>
>> There are several Python graphing packages which you could use towards
>>
>>this end, the question is how nicely will they plug into a web 
>>environment.
>>I am not aware of any that are set up to do this using mod_python.
>>I'm also busy looking at the problem, for an application we are 
>>currently converting to be web based, so discuss plans / things you find 
>>here and I will to and hopefully we can come up with a nice solution...
>>
>>Thanks,
>>David
>>
>
>David,
>  Thanks for the information.  I was looking at using pygdchart2 from 
>nullcube.  I was pleased with the interface they've written.  Have you any 
>experience with them?  I figured it shouldn't be technically difficult to 
>create an interface of parameters that mapped to chart settings.
>  
>
I haven't had, but will look at it, do you have a URL?

>The only concern I have so far is the method of outputting the chart once 
>rendered.  The examples use the draw method:
>"""
> chart.draw(filespec)
>Draw the graph to the specified file. If the filespec argument is a 
>string, it will be treated as the path to a file. Otherwise, filespec is 
>assumed to be a Python file object.
>"""
>
>I'm new to mod_python, so I'm not sure how to pass the output stream of 
>the request object to the draw() method.  If you know, I'm be grateful. If 
>not, I'll work at it.  I haven't really dug yet.
>  
>
This kind of thing is pretty simple, you can either create a 
StringIO.StringIO object (standard Python) which is a pseudo-file that 
you can get the contents out of using a string, or you could try passing 
the request object (at the appropriate time) and see if it will work 
writing to that.
Another option (assuming the project is open source) is to alter the 
program to support returning the data in a string.
I got the reportlab guys to do this - their project is mainly focussed 
on Reports and PDF, but it also has charting capabilities I haven't 
investigated.
The other charting toolkit I am aware of is Chaco.

I think it would be good to investigate all of them and at least draw up 
a list of their strengths/weaknesses for use in a web server context, 
that might be helpful to other users. Would be good to have a list of 
requirements to evaluate these packages by e.g. how big the package is, 
able to produce different image formats, etc.

>btw,   I saw your post earlier about your wiki.  While cruising your site 
>I found a MLM I was in need for.  Thanks!
>  
>
Sure, but I think it was somebody else replying to my message, I don't 
have a wiki...

>Perry Tew
>  
>
David

PS hope you don't mind me rearranging your post, bottom-posting makes 
the flow easier to see.



More information about the Mod_python mailing list