1 <% candidates = @election.ssd_result.ranked_candidates.flatten -%>
2 <% voters = @election.voters.size %>
3 <% matrix = @election.ssd_result.matrix %>
4 <% victories = @election.ssd_result.victories_and_ties %>
5 <p>Each number in the table below shows how many times the candidate on
6 the left beat the matching candidate on the top. The winner is on the
7 top of the left column.</p>
9 <!-- This table shows how many times each choice was ranked above the other,
11 <div class="result_table">
12 <table class="preftable">
15 <% candidates.each do |candidate| -%>
16 <th><%= white_list(@names[candidate]) -%></th>
20 <% candidates.each do |winner| -%>
22 <th><%= white_list(@names[winner]) %></th>
23 <% candidates.each do |loser| -%>
24 <% if winner == loser -%>
27 <td><% wins = matrix[winner][loser] unless matrix[winner].nil?%>
29 <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie',
30 :diameter => 25, :share_color => '#74ce00' %>
38 <!-- This table generates a margin of victory -->
40 <p>A simplification of the above data. The winner is on the left; each
41 cell names the defeated candidate and the magnitude of the victory in
44 <div class="result_table">
45 <table class="preftable">
46 <% candidates.each do |victor| %>
48 <th><%= white_list(@names[victor]) %></th>
49 <!-- This is a pretty logic heavy section - think about trying to move it to
50 backend eventually. Change the order of first and second to change the order
51 that things are sorted in. -->
52 <% sorted = victories[victor].sort { |first,second| first[1] <=> second[1] }%>
53 <% sorted.each do |loserpair| %>
54 <td><%= white_list(@names[loserpair[0]]) %>
55 <% if loserpair[1] == 0%>