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 getPercentChange = () => {
|
||||||
const thisTimePeriodProfit = getProfit(transactionsToShow).toNumber()
|
const thisTimePeriodProfit = getProfit(transactionsToShow)
|
||||||
const previousTimePeriodProfit = getProfit(
|
const previousTimePeriodProfit = getProfit(transactionsLastTimePeriod)
|
||||||
transactionsLastTimePeriod
|
|
||||||
).toNumber()
|
|
||||||
|
|
||||||
if (thisTimePeriodProfit === previousTimePeriodProfit) return 0
|
if (thisTimePeriodProfit.eq(previousTimePeriodProfit)) return 0
|
||||||
if (previousTimePeriodProfit === 0) return 100
|
if (previousTimePeriodProfit.eq(0)) return 100
|
||||||
|
|
||||||
return new BigNumber(
|
return thisTimePeriodProfit
|
||||||
((thisTimePeriodProfit - previousTimePeriodProfit) * 100) /
|
.minus(previousTimePeriodProfit)
|
||||||
previousTimePeriodProfit
|
.times(100)
|
||||||
).toFormat(2)
|
.div(previousTimePeriodProfit)
|
||||||
|
.toNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDirectionPercent = () => {
|
const getDirectionPercent = () => {
|
||||||
|
|
@ -211,7 +210,7 @@ const SystemPerformance = () => {
|
||||||
</div>
|
</div>
|
||||||
<div className={classnames(percentageClasses)}>
|
<div className={classnames(percentageClasses)}>
|
||||||
{getPercentageIcon()}
|
{getPercentageIcon()}
|
||||||
{`${percentChange}%`}
|
{`${new BigNumber(percentChange).toFormat(2)}%`}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<LineChart
|
<LineChart
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue