projects
/
selectricity
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Put in a pie graph for Plurality votes. ALso slimmed down victories_and_ties method...
[selectricity]
/
app
/
controllers
/
graph_controller.rb
diff --git
a/app/controllers/graph_controller.rb
b/app/controllers/graph_controller.rb
index c72da85a6dea19732d070710ff42fb330fbc2c1a..69577c6df84e1cf80566748993209eb145965027 100644
(file)
--- 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])
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,
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)
private
def get_positions_info(election)
Benjamin Mako Hill
||
Want to submit a patch?