Begin work on getting the graph data prepared

This commit is contained in:
Oliver-Akins 2025-04-21 23:36:17 -06:00
parent 65856b650c
commit 3796687a72
3 changed files with 74 additions and 2 deletions

View file

@ -69,6 +69,10 @@ export class StatsViewer extends HandlebarsApplicationMixin(ApplicationV2) {
this.#prepareDataFiltersContext(ctx);
break;
};
case `graph`: {
this.#prepareGraphContext(ctx);
break;
};
};
if (import.meta.env.DEV) {
@ -120,6 +124,26 @@ export class StatsViewer extends HandlebarsApplicationMixin(ApplicationV2) {
};
};
_graphData = {};
async #prepareGraphContext(_ctx) {
const datasets = CONFIG.StatsDatabase.getRows(
`${this._selectedTable}/${this._selectedSubtable}`,
this._selectedUsers,
);
Logger.log(datasets);
const buckets = {};
for (const row of datasets[game.user.id] ?? []) {
buckets[row.value] ??= 0;
buckets[row.value] += 1;
};
const sorted = Object.entries(buckets).sort(([v1], [v2]) => Math.sign(v1 - v2));
Logger.log(sorted);
};
/**
* @param {Event} event
*/