Skip to content

Commit 0cdedd1

Browse files
committed
Fix diff calculation
1 parent 1b0f177 commit 0cdedd1

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

components/modules/stats/ChartCardPreview.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ const currentData = ref([])
2727
const prevData = ref([])
2828
const currentTotal = ref(0)
2929
const prevTotal = ref(0)
30+
const dataLoaded = ref(false)
3031
const diff = computed(() => {
31-
if (!prevTotal.value) return undefined
32+
if (!dataLoaded.value) return undefined
3233
33-
return (((currentTotal.value - prevTotal.value) / prevTotal.value) * 100).toFixed(1)
34+
const res = prevTotal.value ? ((currentTotal.value - prevTotal.value) / prevTotal.value) : 1
35+
return (res * 100).toFixed(1)
3436
})
3537
const chartEl = ref()
3638
const chartElPrev = ref()
@@ -95,7 +97,7 @@ const getSeries = async () => {
9597
9698
prevTotal.value = prevData.value.reduce((sum, el) => {
9799
return sum + +el.value;
98-
}, 0);
100+
}, 0);
99101
} else {
100102
currentTotal.value = currentData.value.slice(-1)[0].value
101103
prevTotal.value = prevData.value.slice(-1)[0].value
@@ -105,6 +107,8 @@ const getSeries = async () => {
105107
prevTotal.value = prevTotal.value / prevData.value.length
106108
currentTotal.value = currentTotal.value / currentData.value.length
107109
}
110+
111+
dataLoaded.value = true
108112
}
109113
110114
const buildChart = (chart, data, color) => {

components/modules/stats/DiffChip.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const styles = computed(() => {
5252
}
5353
}
5454
})
55-
5655
</script>
5756

5857
<template>

components/modules/stats/tabs/GeneralTab.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ const highlights = computed(() => {
3434
name: 'txs',
3535
title: 'Transactions',
3636
value: lastHead.value.total_tx,
37-
diff: diffs24h.value.tx_count_24h,
37+
diff: diffs24h.value.tx_count_24h * 100,
3838
},
3939
{
4040
name: 'blobs_size',
4141
title: 'Blobs Size',
4242
units: 'bytes',
4343
value: lastHead.value.total_blobs_size,
44-
diff: diffs24h.value.blobs_size_24h,
44+
diff: diffs24h.value.blobs_size_24h * 100,
4545
},
4646
{
4747
name: 'fee',
4848
title: 'Total Fees',
4949
units: 'utia',
5050
value: lastHead.value.total_fee,
51-
diff: diffs24h.value.fee_24h,
51+
diff: diffs24h.value.fee_24h * 100,
5252
},
5353
]
5454
})

0 commit comments

Comments
 (0)