send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
end
- #The following section has been pasted directly fromworking pollarize graphs
- #and hasn't been adopted to fit Selectricity yet
-
+ #I've started to modify the following section to fit Selectricity, still
+ #desn't seem towork, issue seems tobe realted to path
def day_votes
- @poll = Poll.find(params[:id])
+
+ @election = Election.find(params[:id])
line = Gruff::Line.new
line.title = "Voters Per Day"
line.font = File.expand_path('/usr/X11R6/lib/X11/fonts/TTF/Vera.ttf', RAILS_ROOT)
- line.data("#{@poll.name}", voter_days["voters_per_day"] )
+ line.data("#{@election.name}", voter_days["voters_per_day"] )
line.labels = voter_days["days_hash"]
line.x_axis_label = "Date"
line.y_axis_label = "Number of Votes"
end
def voter_days
- @poll = Poll.find(params[:id])
+ @election = Election.find(params[:id])
voter_times = Array.new
unique_days = Array.new
voters_per_day = Array.new
days_hash = Hash.new
- @poll.questions.each do |qstn|
- qstn.votes.each do |vote|
+ @election.votes.each do |vote|
voter_times << vote.time unless voter_times.any? {|utime| utime == vote.time}
- end
end
+
voter_times.sort!
- #find all times in voter_times with the same date, and then concatenate
- #that number onto votes_per_day
- #
- #doesn't work jsut yet
+
voter_times.each_with_index do |time, index|
count = 1
unless unique_days.any? { |d1| d1.eql?(time.mon.to_s+"/"+time.day.to_s) }
return { "voters_per_day" => voters_per_day, "days_hash" => days_hash }
end
- #end copy/pasted section
+ #end section
end