diff --git a/elections/templates/elections/results/rank.html b/elections/templates/elections/results/rank.html
index 73ccbb8..0c65c57 100644
--- a/elections/templates/elections/results/rank.html
+++ b/elections/templates/elections/results/rank.html
@@ -35,8 +35,8 @@
- {% for cell in line %}
-
{{ cell }} |
+ {% for cell, class in line %}
+ {{ cell }} |
{% endfor %}
{% endwith %}
diff --git a/elections/utils.py b/elections/utils.py
index 9e04a87..373dea1 100644
--- a/elections/utils.py
+++ b/elections/utils.py
@@ -249,11 +249,21 @@ class ResultsData:
options = list(question.options.all())
n = len(options)
- matrix = np.zeros((n, n), dtype=int)
+ _matrix = np.zeros((n, n), dtype=int)
+ matrix = np.zeros((n, n), dtype=tuple)
for d in duels:
i, j = options.index(d.loser), options.index(d.winner)
- matrix[i, j] = d.amount
+ _matrix[i, j] = d.amount
+
+ for i in range(n):
+ for j in range(n):
+ if _matrix[i, j] > _matrix[j, i]:
+ matrix[i, j] = (_matrix[i, j], "is-success")
+ elif _matrix[i, j] < _matrix[j, i]:
+ matrix[i, j] = (_matrix[i, j], "is-danger")
+ else:
+ matrix[i, j] = (_matrix[i, j], "")
return render_to_string(
"elections/results/rank.html",