Skip to content

Commit

Permalink
fix: avoid alone point on assets curve.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardo2016x committed May 7, 2024
1 parent e844186 commit 8ce2a6c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/ui/views/Dashboard/components/BalanceView/useCurve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ export const formChartData = (
if (isMeaningfulNumber(realtimeNetWorth) && realtimeTimestamp) {
const realtimeChange = realtimeNetWorth - startUsdValue;

list.push({
value: realtimeNetWorth || 0,
netWorth: realtimeNetWorth
? `$${formatUsdValue(realtimeNetWorth)}`
: '$0',
change: `${formatUsdValue(Math.abs(realtimeChange))}`,
isLoss: realtimeChange < 0,
changePercent:
startUsdValue === 0
? `${realtimeNetWorth === 0 ? '0' : '100.00'}%`
: `${(Math.abs(realtimeChange * 100) / startUsdValue).toFixed(2)}%`,
timestamp: Math.floor(realtimeTimestamp / 1000),
});
if (list.length) {
list.push({
value: realtimeNetWorth || 0,
netWorth: realtimeNetWorth
? `$${formatUsdValue(realtimeNetWorth)}`
: '$0',
change: `${formatUsdValue(Math.abs(realtimeChange))}`,
isLoss: realtimeChange < 0,
changePercent:
startUsdValue === 0
? `${realtimeNetWorth === 0 ? '0' : '100.00'}%`
: `${(Math.abs(realtimeChange * 100) / startUsdValue).toFixed(2)}%`,
timestamp: Math.floor(realtimeTimestamp / 1000),
});
}
}

const endNetWorth = list?.length
Expand Down

0 comments on commit 8ce2a6c

Please sign in to comment.