OK, I admit I was wrong - charting in Rails Redux
After messing around with the Google Charts API for a good 12 hours or so, I realised very quickly the limitations of the solution. Although this system does have its positive aspects, there were a few omissions that resulted in us moving way from Google Charts.
- Inability to handle negative numbers
- Axes labels that are set based upon spacing (i.e. at the bottom, half way up, at the top), not the data it represents
- Inflexibility when it comes to tooltips / displaying the values at a particular point
This first of these can be worked around with a hack which can be seen here, however although this works well for relatively stable, administrator created graphs, it gets a bit hairier when we are graphing user data. And offsetting data just to get it to display correctly is just, well, painful (despite the fact that I had some pretty nifty calculations happening to find the zero-point line on a scale of 0% to 100% between the maximum and minimum values to be graphed - not that this helped at all or anything).
The second is a bit of show-stopper - basically you define where the axes are placed but the number of items that you provide Google. This means that giving it (0, 50, 100) would set 0 at the bottom, 50 half way up and 100 at the top. (0, 25, 50, 75, 100) would break the axes into five regions. Ugly.
The third… well. I was hoping to get at least a little bit of the way towards really nice Google Analytics type graphing interaction, but no dice, not here.
So I went back out onto the market as it were to find other alternatives that would not add additional strain onto the server. Flash based chart tools best fit into this category, and boy did I luck out.
I found the Open Flash Chart project, which is damn near perfect for what we require. All processing is done on the user’s machine through the embedded flash file, which gets passed data from our Ruby on Rails application.
A nice little plugin / Rails wrapper for Open Flash Chart is provided by the good people at PullMonkey, who ported the PHP wrapper to Rails. This means that we now have graphs the handle negative numbers, have automatic axes label generation, and little tooltips showing the specific value of a day on hover. So basically we now have graphs that a much more user-friendly, being generated by the wonders of Flash.
So the lesson I have learned - dig a bit deeper before deciding on a solution!
Tags: charts, development, Ruby on Rails
July 18th, 2008 at 3:40 am
Hey, thanks for the link
the other nice point about OFC vs Google Charts is that no one snoops your data, it’s all held on your server or the clients box. With Google you need to send your data to them which is a bit icky.
monk.e.boy
July 22nd, 2008 at 3:18 am
I’ve been in the same boat about 3 months ago. The biggest graphing for me barrier is that I did not want to install ImageMagick. OFC has done me well! The only problem I have had is that the documentation on the OFC website is lacking, and support for the Rails plug-in is not great. But I’ve been able to hack my way through it.
July 22nd, 2008 at 12:22 pm
@ monk.e.boy - no problems; that is very true about the data; makes me feel a bit more comfortable with the solution.
@ Karl - yeah the documentation is lacking a bit, and the rails plugin is a bit bare at this stage, however it has worked for us in the simplistic / proof of concept form that we are currently using it in. If only I could find a way to add a zero-line! And yes, ImageMagick is a pain to install