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.
This commit is contained in:
Wolvan 2022-01-30 19:54:16 +01:00
parent a1c4d06845
commit 8e8b263c62

View file

@ -28,7 +28,7 @@ function domLoaded() {
drawChart = data => { drawChart = data => {
chart.draw( chart.draw(
google.visualization.arrayToDataTable( google.visualization.arrayToDataTable(
[["Options", "Votes"]].concat(data) [["Options", "Votes"]].concat(data.sort((a, b) => b[1] - a[1]))
), chartOptions ), chartOptions
); );
chartEl.style.visibility = "visible"; chartEl.style.visibility = "visible";