Fix: show correct percentage icon and use BigNumber methods for maths
This commit is contained in:
parent
439bfb36a0
commit
ae4d557a9b
1 changed files with 10 additions and 11 deletions
|
|
@ -124,18 +124,17 @@ const SystemPerformance = () => {
|
|||
}
|
||||
|
||||
const getPercentChange = () => {
|
||||
const thisTimePeriodProfit = getProfit(transactionsToShow).toNumber()
|
||||
const previousTimePeriodProfit = getProfit(
|
||||
transactionsLastTimePeriod
|
||||
).toNumber()
|
||||
const thisTimePeriodProfit = getProfit(transactionsToShow)
|
||||
const previousTimePeriodProfit = getProfit(transactionsLastTimePeriod)
|
||||
|
||||
if (thisTimePeriodProfit === previousTimePeriodProfit) return 0
|
||||
if (previousTimePeriodProfit === 0) return 100
|
||||
if (thisTimePeriodProfit.eq(previousTimePeriodProfit)) return 0
|
||||
if (previousTimePeriodProfit.eq(0)) return 100
|
||||
|
||||
return new BigNumber(
|
||||
((thisTimePeriodProfit - previousTimePeriodProfit) * 100) /
|
||||
previousTimePeriodProfit
|
||||
).toFormat(2)
|
||||
return thisTimePeriodProfit
|
||||
.minus(previousTimePeriodProfit)
|
||||
.times(100)
|
||||
.div(previousTimePeriodProfit)
|
||||
.toNumber()
|
||||
}
|
||||
|
||||
const getDirectionPercent = () => {
|
||||
|
|
@ -211,7 +210,7 @@ const SystemPerformance = () => {
|
|||
</div>
|
||||
<div className={classnames(percentageClasses)}>
|
||||
{getPercentageIcon()}
|
||||
{`${percentChange}%`}
|
||||
{`${new BigNumber(percentChange).toFormat(2)}%`}
|
||||
</div>
|
||||
</div>
|
||||
<LineChart
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue