From 9838ef334e24b8f5894d277d04ec2b3306614403 Mon Sep 17 00:00:00 2001 From: Mathis HAMMEL Date: Sat, 12 Aug 2017 20:45:17 +0100 Subject: [PATCH] Sort scoregraph labels by score (#349) * Added label sort by position in the plotly chart --- CTFd/themes/original/static/js/scoreboard.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CTFd/themes/original/static/js/scoreboard.js b/CTFd/themes/original/static/js/scoreboard.js index c0cc0b6f..e8b8c976 100644 --- a/CTFd/themes/original/static/js/scoreboard.js +++ b/CTFd/themes/original/static/js/scoreboard.js @@ -50,6 +50,14 @@ function scoregraph () { traces.push(trace); } + traces.sort(function(a, b) { + var scorediff = b['y'][b['y'].length - 1] - a['y'][a['y'].length - 1]; + if(!scorediff) { + return a['x'][a['x'].length - 1] - b['x'][b['x'].length - 1]; + } + return scorediff; + }); + var layout = { title: 'Top 10 Teams', paper_bgcolor: 'rgba(0,0,0,0)',