projects
/
selectricity
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added Sparklines controller and dependency, see README. Created method and table...
[selectricity]
/
app
/
views
/
quickvote
/
_pref_table.rhtml
diff --git
a/app/views/quickvote/_pref_table.rhtml
b/app/views/quickvote/_pref_table.rhtml
index 32f5de4bc81254afef3a36fbae12a82ab331d21b..4576a0fafb8e7971af4499ba88b9501bacb1a2aa 100644
(file)
--- a/
app/views/quickvote/_pref_table.rhtml
+++ b/
app/views/quickvote/_pref_table.rhtml
@@
-1,4
+1,6
@@
<% candidates = @election.candidates.sort.collect {|candidate| candidate.id}-%>
<% candidates = @election.candidates.sort.collect {|candidate| candidate.id}-%>
+<% voters = @election.voters.size %>
+
<% names = Hash.new -%>
<% candidates.each do |candidate| -%>
<%names[candidate] = Candidate.find(candidate).name -%>
<% names = Hash.new -%>
<% candidates.each do |candidate| -%>
<%names[candidate] = Candidate.find(candidate).name -%>
@@
-16,7
+18,11
@@
<% if winner == loser -%>
<td> -- </td>
<% else %>
<% if winner == loser -%>
<td> -- </td>
<% else %>
- <td><%= @election.condorcet_result.matrix[winner][loser] %></td>
+ <td><% wins = @election.condorcet_result.matrix[winner][loser]%>
+ <%= wins %>
+ <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie',
+ :diameter => 25, :share_color => '#74ce00' %>
+ </td>
<% end -%>
<% end -%>
</tr>
<% end -%>
<% end -%>
</tr>
Benjamin Mako Hill
||
Want to submit a patch?