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
On Apr 2, 2:28 am, "swanand deodhar"
<swanand.b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi!
> I am using Gruff as per the directions
ofhttp://nubyonrails.com/articles/2005/11/19/gruff-with-rails-typo-rewritebut
> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---