# Gruff

**URL:** <https://www.ruby-forum.com/t/gruff/90851>\
**Category:** Rails\
**Created:** [April 2, 2007, 11:29am UTC](https://www.ruby-forum.com/t/gruff/90851 "2007-04-02T11:29:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![swanand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@swanand](https://www.ruby-forum.com/u/swanand)\
**Post date:** [April 2, 2007, 11:29am UTC](https://www.ruby-forum.com/t/gruff/90851/1 "2007-04-02T11:29:45Z")

</div>

Hi!  
I am using Gruff as per the directions of  
[http://nubyonrails.com/articles/2005/11/19/gruff-with-rails-typo-rewrite](http://nubyonrails.com/articles/2005/11/19/gruff-with-rails-typo-rewrite)  
but  
it doesn’y show me the Graph. It only shows me the background image of  
that  
graph.  
Here is the controller method for it:

def bar\_graph\_report  
built\_array = []  
g = Gruff::Pie.new(400)  
g.title = “Optionwise polling”  
g.font = File.expand\_path(‘artwork/fonts/Vera.ttf’, RAILS\_ROOT)  
g.labels = { 0 =\> ‘Mon’, 2 =\> ‘Wed’, 4 =\> ‘Fri’, 6 =\> ‘Sun’ }

@poll = Poll.find(params[:id])  
@total\_votes = (@poll.option\_one\_count) + (@poll.option\_two\_count) +  
(@  
poll.option\_three\_count)  
built\_array[0] = ((@poll.option\_one\_count)/@total\_votes) \* 100  
built\_array[1] = ((@poll.option\_two\_count)/@total\_votes) \* 100  
built\_array[2] = ((@poll.option\_three\_count)/@total\_votes) \* 100  
g.data(‘option wise voting’, built\_array)

send\_data(g.to\_blob,  
:disposition =\> ‘inline’,  
:type =\> ‘image/png’,  
:filename =\> “bart\_scores.png”)  
end

What could be the problem?  
Thanks and regards,  
Swanand

---

<div class="post-metadata">

**Author:** ![swanand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@swanand](https://www.ruby-forum.com/u/swanand)\
**Post date:** [April 2, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/gruff/90851/2 "2007-04-02T16:17:38Z")

</div>

Its been a while since I’ve looked at the docs for it. One thing is  
dont worry about calculating total votes.  
Also try feeding g.data one option at a time like so  
@poll.options do |option|  
g.data(option.name, option.votes)  
end  
Hope this helps.

- Richard
