Selaa lähdekoodia

Sort outcome balance data for chart

tags/v0.1.3
bertieb 3 vuotta sitten
vanhempi
commit
ef598d2c98
1 muutettua tiedostoa jossa 12 lisäystä ja 3 poistoa
  1. +12
    -3
      src/ts/frontend.ts

+ 12
- 3
src/ts/frontend.ts Näytä tiedosto

@@ -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),
}],
},


Ladataan…
Peruuta
Tallenna