diff --git a/static_files/vote_chart.js b/static_files/vote_chart.js index 8dd6869..09850d4 100644 --- a/static_files/vote_chart.js +++ b/static_files/vote_chart.js @@ -1,5 +1,5 @@ const limit_ratio = 1.3 - +const colors = ['#b6b8fc', '#b6f4fc', '#fcb6cc', '#e0fcb6', '#fcdcb6', '#b6fcc8', '#f0b6fc'] async function main() { const vote_response = await fetch(document.URL+"/votes"); if (!vote_response.ok) { @@ -23,8 +23,12 @@ async function main() { return; } + // Sort by label to maintain the same graph order, as it goes through a hash map in the backend. datasets.sort((a, b) => a.label > b.label) + for (let i = 0; i < datasets.length; i++) { + datasets[i].backgroundColor = colors[i % colors.length] + } const chart_canvas = document.getElementById("vote_chart") let chart