Finished organzing preferential vote tables into one partial. Also changed RubyVote...
[selectricity] / app / views / quickvote / _pref_tables.rhtml
1 <% candidates = @election.condorcet_result.ranked_candidates.flatten -%>
2 <% voters = @election.voters.size %>
3 <% matrix = @election.condorcet_result.matrix %>
4 <% victories = @election.condorcet_result.victories_and_ties %>
5 <% names = @election.names_by_id %>
6
7
8 <!-- This table shows how many times each choice was ranked above the other, 
9         with percentages-->
10 <table class="voterbox">
11   <tr>
12         <td> </td>
13         <% candidates.each do |candidate| -%>
14           <th><%=h names[candidate] -%></th>
15   <% end -%>
16  </tr>
17
18 <% candidates.each do |winner| -%>
19   <tr>
20         <th><%=h names[winner] %></th>
21   <% candidates.each do |loser| -%> 
22     <% if winner == loser -%>
23       <td> -- </td>
24     <% else %>        
25       <td><% wins = matrix[winner][loser] unless matrix[winner].nil?%>
26           <%= wins %>
27               <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie', 
28                                  :diameter => 25, :share_color => '#74ce00' %>
29           </td>
30     <% end -%>
31   <% end -%>
32  </tr>
33 <% end -%>
34 </table>
35
36 <!-- This table generates a margin of victory -->
37 <table class="voterbox">
38   <% candidates.each do |victor| %>
39   <tr>
40     <th><%=h names[victor] %></th>
41         <% victories[victor].keys.each do |loser| %>
42         <% margin = victories[victor][loser]%>
43         <td><%=h names[loser] %> 
44             <% if margin == 0%>
45                   Tied!
46                 <% else -%>
47                   (<%= margin%>)
48                 <% end -%>
49                   </td>
50         <% end -%>
51   </tr>
52   <% end -%>
53 </table>
54

Benjamin Mako Hill || Want to submit a patch?