[Catalyst] Charting data

Nigel Metheringham nigel.metheringham at dev.intechnology.co.uk
Mon Apr 30 17:21:23 GMT 2007


Having posted the original request I thought I had better follow up  
with what I actually did...

It looked like plotkit would do what I want, and was easy to generate  
data for within the main web page (so don't need 2 http round trips  
and carrying state between them).  However plotkit does not support  
legends on graphs - and since I was generating some with lots of  
lines, this was pretty much a must have.

I found that WebFX Chart ( http://webfx.eae.net/dhtml/chart/ 
chart.html ) had support for a legend.  It generally works well  
although a few things are a bit "lumpy" - handling of axes etc.

The implementation is a little bit of a hack, but basically I have a  
graph method in each of the graphable controllers, this passes a  
DBIx::Class resultset to a build_graph method in a common superclass,  
which pushes a graph structure into the stash (containing a set of  
lines, each with an array of values, a min and a max value).  A TT  
fragment in the view converts this into a set of js calls for WebFX  
Chart.

This works acceptably - it has a few performance issues for large  
graphs, which appear to be down to the overhead in pulling out and  
building into objects the several hundred rows of data - I suspect  
that if I just took the values from a dbh rather than letting DBIC  
create a new row object the whole thing would speed up rather  
dramatically.

	Nigel.
--
[ Nigel Metheringham           Nigel.Metheringham at InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]







More information about the Catalyst mailing list