Quellcode durchsuchen

Sort outcome balance data for chart

tags/v0.1.3
bertieb vor 3 Jahren
Ursprung
Commit
ef598d2c98
1 geänderte Dateien mit 12 neuen und 3 gelöschten Zeilen
  1. +12
    -3
      src/ts/frontend.ts

+ 12
- 3
src/ts/frontend.ts Datei anzeigen

@@ -118,7 +118,7 @@ function outcomesReport(rollstats: RollStats): string {
}

function outcomeBalancesReport(rollstats: RollStats): string {
let output = subTitle("Outcome Balancess");
let output = subTitle("Outcome Balances");
// Preamble

// Chart
@@ -185,14 +185,23 @@ function generateCharts(rollstats: RollStats): void {
* Outcome Balances
*/

let bc = rollstats.balanceCounts;
let keys = Object.keys(bc);
keys.sort(function(a: string, b: string){return Number(a) - Number(b)});
// sort values too
let values = [];
for (let i = 0; i < keys.length; i++) {
values.push(rollstats.balanceCounts[keys[i]]);
}

let balanceCanvas: any = $("#balanceChart");
let balanceChart = new Chart(balanceCanvas, {
type: "bar",
data: {
labels: Object.keys(rollstats.balanceCounts),
labels: keys,
datasets: [{
label: "Outcome Balance Counts",
data: Object.values(rollstats.balanceCounts),
data: values,
backgroundColor: hexColours(Object.values(rollstats.balanceCounts).length),
}],
},


Laden…
Abbrechen
Speichern