X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/62d55f6e7b7a956714166a5ed409368937218997..277d9e323c1c9c525c1cea4590dc71bc56aeed06:/app/controllers/graphs_controller.rb diff --git a/app/controllers/graphs_controller.rb b/app/controllers/graphs_controller.rb index c810853..101dc6d 100644 --- a/app/controllers/graphs_controller.rb +++ b/app/controllers/graphs_controller.rb @@ -29,15 +29,15 @@ class GraphsController < ApplicationController 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" @@ -50,22 +50,18 @@ class GraphsController < ApplicationController 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) } @@ -81,7 +77,7 @@ class GraphsController < ApplicationController return { "voters_per_day" => voters_per_day, "days_hash" => days_hash } end - #end copy/pasted section + #end section end