Parcourir la source

feat: sort so failure before success in chart

tags/v0.3.3
bertieb il y a 3 ans
Parent
révision
af2fd9ed19
1 fichiers modifiés avec 12 ajouts et 4 suppressions
  1. +12
    -4
      src/ts/frontend.ts

+ 12
- 4
src/ts/frontend.ts Voir le fichier

@@ -235,14 +235,22 @@ function generateCharts(resultProperties: ResultProperties): void {
* Outcomes
*/

// sort so we have failure before success
let oc = resultProperties.rollstats.outcomeCounts;
let okeys = Object.keys(oc).sort();
let ovalues = [];
for (let i = 0; i < okeys.length; i++) {
ovalues.push(oc[okeys[i] as Outcomes]);
}

let outcomesCanvas: any = $(`#${outcomesChartId}`);
let outcomesChart = new Chart(outcomesCanvas, {
type: "bar",
data: {
labels: Object.keys(resultProperties.rollstats.outcomeCounts),
labels: okeys,
datasets: [{
label: "Outcome Counts",
data: Object.values(resultProperties.rollstats.outcomeCounts),
data: ovalues,
backgroundColor: hexColours(Object.values(resultProperties.rollstats.outcomeCounts).length),
}],
},
@@ -259,7 +267,7 @@ function generateCharts(resultProperties: ResultProperties): void {
// sort values too
let values = [];
for (let i = 0; i < keys.length; i++) {
values.push(resultProperties.rollstats.balanceCounts[keys[i]]);
values.push(bc[keys[i]]);
}

let balanceCanvas: any = $(`#${balanceChartId}`);
@@ -291,7 +299,7 @@ function generateTables(resultProperties: ResultProperties): void {
let outcomesTableId = `outcomesTable-${itemId}`;

let oc = resultProperties.rollstats.outcomeCounts;
let okeys = Object.keys(oc);
let okeys = Object.keys(oc).sort();
for (var i = 0; i < okeys.length; i++) {
let tb = $(`#${outcomesTableId}`).find("tbody");
let outcome: Outcomes = okeys[i] as Outcomes;


Chargement…
Annuler
Enregistrer