diff --git a/src/vote.rs b/src/vote.rs index 09239f6..d4e5d42 100644 --- a/src/vote.rs +++ b/src/vote.rs @@ -115,6 +115,8 @@ pub async fn fetch_vote_data(week: u8, mut db: Connection) -> Opti } + // The hash map makes storing and retrieving the data really easy, *but* + // it does lose the order of the original array (which is sorted via the SQL). let mut vote_data = HashMap::>::new(); let mut next_truth_number = 1; for raw_vote in raw_votes { diff --git a/static_files/vote_chart.js b/static_files/vote_chart.js index 7bdae87..45b3ab2 100644 --- a/static_files/vote_chart.js +++ b/static_files/vote_chart.js @@ -32,11 +32,15 @@ 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) + const chart_canvas = document.getElementById("vote_chart") let chart function create_chart(keys, data) { let main_axis; let aspect_ratio; + // TODO: Move to the event, to check and not re-create for no reason. if (window.innerWidth > window.innerHeight) { main_axis = 'x' aspect_ratio = 2