File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,12 @@ const currentData = ref([])
2727const prevData = ref ([])
2828const currentTotal = ref (0 )
2929const prevTotal = ref (0 )
30+ const dataLoaded = ref (false )
3031const 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})
3537const chartEl = ref ()
3638const 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
110114const buildChart = (chart , data , color ) => {
Original file line number Diff line number Diff line change @@ -52,7 +52,6 @@ const styles = computed(() => {
5252 }
5353 }
5454})
55-
5655 </script >
5756
5857<template >
Original file line number Diff line number Diff 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})
You can’t perform that action at this time.
0 commit comments