Graphs and Plots in Rails

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?

http://code.google.com/apis/chart/

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?

Ah! You're on Rails 1.2.x, right? See that '.png' at the end, you
don't want that. Unless you actually depend on rails tacking that on
for you, go to vendor/rails/actionpack/lib/action_view/helpers/
asset_tag_helper.rb and change image_path to be:

       def image_path(source)
         # unless (source.split("/").last || source).include?
(".") || source.blank?
         # ActiveSupport::Deprecation.warn(
         # "You've called image_path with a source that
doesn't include an extension. " +
         # "In Rails 2.0, that will not result in .png
automatically being appended. " +
         # "So you should call image_path('#{source}.png')
instead", caller
         # )
         # end

         compute_public_path(source, 'images')
       end

and all should be OK. (the &'s are already escaped)

You probably also want to provide your own :alt => "description of the
chart" so it makes sense if Google doesn't return an image (or just
takes a while).

-Rob

Yes, I am...should I upgrade?

If I modify the asset_tag_helper, would this have any negative affect
on anything else?

Ok, I commented out the warning and restarted the server...still no
image.

And I missed updating the compute_public_path(source, 'images') line,
now that is up-to-date and I get an error ("wrong number of arguments
(2 for 3)") for this:

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