Graphs and Plots in Rails

Hi-

I did a search and found some old posts on the subject, however since these things change so rapidly, I'm wondering what the best options are for creating charts and plots in a Rails app?

I saw sparklines in the Rails Cookbook and this seems sufficient, has anyone ever used this?

Thanks for your feedback!

Sparklines are a very particular form of graph intended to be used like a "word" of text. If you're intentions fit well within the restrictions, they can work very well. I actually contributed to Geoffery's sparkline gem.

Sparklines: theory and practice: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR&topic_id=1

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com

I see, so they are typically small graphs? Actually, I think this will work really well for some of my other pages however I will need something to create larger "excel-like" charts.

Any other suggestions?

Anyone used Gruff?

Yes, we use Gruff for our charts on SugarStats.com for the last few months but we're about to update and move to a flash based graphing system (amCharts or FusionCharts).

Gruff has been great for basic things. Another would be Scruffy which is similar to gruff but seems a bit easier and more flexible to work with. It also has graph combining options. Both use ImageMagick/ RMagick so they do server side proccess and take up resources. ImageMagick/RMagick from what I see/hear is notorious for leaking memory. I also think both solutions are a bit rigid in the amount of visual customization you can do with the graphs without extending each library and customizing to your own needs.

Sparklines looks cool for its specific purpose, I'mma have to check it out.

Hmm, do you have to install Image/RMagick to make Gruff, or Scruffy work?

Thanks for your response.

Hmm, do you have to install Image/RMagick to make Gruff, or Scruffy work?

Yes.

I had a heck of a time getting RMagick to work on my Windows box. Does anyone know an easy way of installing this on RedHat Linux?

Hi,

I use gruff quite a bit. There wasn't too much to the install. On Ubuntu 7.10 I have the following packages installed

imagemagick libmagick9 libmagick9-dev librmagick-ruby1.8

I'm sure I'm missing something but it isn't too hard to get it running.

Chris

You guys need to check my site and let me know if you like any of those graphs

http://jackster.mobi

Chris Mccauley wrote:

Why not use the Google Chart API?

Nice, I like the Google Charts. I think I'll try this, along with Scruff...if I can ever get RMagick running :slight_smile:

Thanks everyone for your inputs!

One last question to get me running...

I tried testing this after I installed the plugin...

In view and then controller and nothing rendered? I also restarted the server...

GoogleChart.pie(10,20,40,30).to_url

What did I miss here?

You left all this info (see bellow) intentionally?

Cheers, Sazima

params | session | env | request

I'm guessing that you need:

<%= image_tag GoogleChart.pie(10,20,40,30).to_url %>

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com

I don't think I understand what you mean?

Interesting, it looks like if I use image_tag, it creates a blank space where the chart should be, but there is nothing there?

pete wrote:

One last question to get me running...

I tried testing this after I installed the plugin...

In view and then controller and nothing rendered? I also restarted the server...

GoogleChart.pie(10,20,40,30).to_url

What did I miss here?

I found the same issue when testing Google Charts on Rails, which is why I liked GoogleCharts better.

What does the page source look like? Does the URL for the image src look OK? Does it need to have &'s escaped to &amp;'s?

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com

<img alt="Chart?chs=200x200&amp;cht=p&amp;chd=t:10,20,40,30" src="http://chart.apis.google.com/chart? chs=200x200&amp;cht=p&amp;chd=t:10,20,40,30.png" />

Looks like it needs to be escaped?