vote_chart: sort parsed votes
The SQL query retrieving the votes is deterministicly sorted, but goes through a HashMap, for ease of processing and transfer, which does not maintaing order. Sort the resulting object in the Javascript to keep a consistent order in the graph.
This commit is contained in:
parent
8547312a78
commit
982a7ffd65
2 changed files with 6 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue