Preserve shortage signals during global pause (Refs #137)
CI / checks (push) Successful in 4m47s
CI / checks (push) Successful in 4m47s
This commit is contained in:
@@ -38,6 +38,22 @@ export function metricAverageLobbies(lobbyHours: number, capturedHours: number):
|
||||
return lobbyHours / capturedHours;
|
||||
}
|
||||
|
||||
/** Use up to four whole-lobby intervals while retaining fractional averages in the data. */
|
||||
export function metricLobbyAxis(maximumLobbies: number) {
|
||||
const maximum = Number.isFinite(maximumLobbies) ? Math.max(1, maximumLobbies) : 1;
|
||||
const targetStep = Math.max(1, maximum / 4);
|
||||
const magnitude = 10 ** Math.floor(Math.log10(targetStep));
|
||||
const step =
|
||||
[1, 2, 5, 10]
|
||||
.map((multiple) => multiple * magnitude)
|
||||
.find((value) => value >= targetStep) ?? 10 * magnitude;
|
||||
const intervals = Math.ceil(maximum / step);
|
||||
return {
|
||||
ceiling: intervals * step,
|
||||
ticks: Array.from({ length: intervals + 1 }, (_, index) => (intervals - index) * step)
|
||||
};
|
||||
}
|
||||
|
||||
export function metricPercent(value: number, total: number): string {
|
||||
if (!Number.isFinite(value) || !Number.isFinite(total) || total <= 0) return '—';
|
||||
const percent = (100 * value) / total;
|
||||
|
||||
Reference in New Issue
Block a user