<% @election.results! %> <% candidates = @election.ssd_result.ranked_candidates.flatten -%> <% voters = @election.voters.size %> <% matrix = @election.ssd_result.matrix %> <% victories = @election.ssd_result.victories_and_ties %> <% @names = @election.names_by_id %>

Each number in the table below shows how many times the candidate on the left beat the matching candidate on the top. The winner is on the top of the left column.

<% candidates.each do |candidate| -%> <% end -%> <% candidates.each do |winner| -%> <% candidates.each do |loser| -%> <% if winner == loser -%> <% else %> <% end -%> <% end -%> <% end -%>
<%= white_list(@names[candidate]) -%>
<%= white_list(@names[winner]) %> -- <% wins = matrix[winner][loser] unless matrix[winner].nil?%> <%= wins %> <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie', :diameter => 25, :share_color => '#74ce00' %>

A simplification of the above data. The winner is on the left; each cell names the defeated candidate and the magnitude of the victory in parenthesis.

<% candidates.each do |victor| %> <% sorted = victories[victor].sort { |first,second| first[1] <=> second[1] }%> <% sorted.each do |loserpair| %> <% end -%> <% end -%>
<%= white_list(@names[victor]) %> <%= white_list(@names[loserpair[0]]) %> <% if loserpair[1] == 0%> Tied! <% else -%> (<%= loserpair[1] %>) <% end -%>