Merge pull request #286 from blockworks-foundation/clarkeni/performance_per_token

Minor changes - normalize charts to start from 0 (except for account …
This commit is contained in:
tjshipe 2022-05-24 15:28:01 -04:00 committed by GitHub
commit 77e2f5c9d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -181,6 +181,18 @@ const AccountPerformance = () => {
}
})
// Normalise chart to start from 0 (except for account value)
if (parseInt(performanceRange) !== 90 && chartToShow !== 'account-value') {
const startValues = Object.assign({}, stats[0]);
for (let i = 0; i < stats.length; i++ ) {
for (const key in stats[i]) {
if (key !== 'time') {
stats[i][key] = stats[i][key] - startValues[key];
}
}
}
}
setChartData(stats)
setChartToShow(chartToShow)
}
@ -342,7 +354,7 @@ const AccountPerformance = () => {
<div className="flex flex-col pb-4 sm:flex-row sm:items-center sm:justify-between">
<h3 className="mb-4 sm:mb-0">{`${t(
`account-performance:${chartToShow}`
)} ${t('account-performance:vs-time')}`}</h3>
)}`}</h3>
<div className="w-full sm:ml-auto sm:w-56">
<ButtonGroup
activeValue={performanceRange}