From 8e8b263c625d483e629922dee5aea243cb969b61 Mon Sep 17 00:00:00 2001 From: Wolvan Date: Sun, 30 Jan 2022 19:54:16 +0100 Subject: [PATCH] Sort data in pie chart Due to the nature of redrawing, the biggest piece of the pie chart will always be the first one. Locations are not static. --- frontend/static/js/result.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/static/js/result.js b/frontend/static/js/result.js index 6fb9684..b69b820 100644 --- a/frontend/static/js/result.js +++ b/frontend/static/js/result.js @@ -28,7 +28,7 @@ function domLoaded() { drawChart = data => { chart.draw( google.visualization.arrayToDataTable( - [["Options", "Votes"]].concat(data) + [["Options", "Votes"]].concat(data.sort((a, b) => b[1] - a[1])) ), chartOptions ); chartEl.style.visibility = "visible";