X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/6a1c545f073430dd46bf5ad89b0450a16c659b00..1fcd2d064dfef0dff9b07a40d0f5d30e662d1d86:/app/controllers/graph_controller.rb diff --git a/app/controllers/graph_controller.rb b/app/controllers/graph_controller.rb index c72da85..69577c6 100644 --- a/app/controllers/graph_controller.rb +++ b/app/controllers/graph_controller.rb @@ -121,12 +121,21 @@ class GraphController < ApplicationController def plurality_pie @election = Election.find(params[:id]) + @election.results unless @election.plurality_result || @election.approval_result + votes = @election.votes.size + data = Hash.new + names = @election.names_by_id - - + @election.plurality_result.points.each do |candidate, votes| + data[names[candidate]] = votes + end + pie = GruffGraff.new ( :graph_type => Gruff::Pie, - :data => , - :title => "Percentage of First Plce Votes") + :title => "Percentage of First Place Votes", + :data => data) + send_data(*pie.output) + + end private def get_positions_info(election)