fix dashboard cards

This commit is contained in:
Emily
2024-07-02 17:28:29 +02:00
parent 237dccad8f
commit 6b97b4f49d
3 changed files with 12 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ const props = defineProps<{
</div>
<div class="flex flex-col grow">
<div class="flex items-end gap-2">
<div class="brockmann text-text-dirty text-[1.6rem] 2xl:text-[2rem]"> {{ value }} </div>
<div class="brockmann text-text-dirty text-[1.6rem] 2xl:text-[1.9rem]"> {{ value }} </div>
<div class="poppins text-text-sub text-[.7rem] 2xl:text-[.85rem] mb-2"> {{ avg }} </div>
</div>
<div class="poppins text-text-sub text-[.9rem] 2xl:text-base"> {{ text }} </div>

View File

@@ -72,9 +72,11 @@ async function loadData(timelineEndpointName: string, target: Data) {
const pool = [...response.map(e => e.count)];
pool.pop();
const avg = pool.reduce((a, e) => a + e, 0) / pool.length;
const diffPercent = (100 / avg * (response.at(-1)?.count || 0)) - 100;
target.trend = diffPercent;
const diffPercent: number = (100 / avg * (response.at(-1)?.count || 0)) - 100;
target.trend = Math.max(Math.min(diffPercent, 99), -99);
target.ready = true;
}