From 6bc1cd369a7e4c778835893d2e944bd66e459fc8 Mon Sep 17 00:00:00 2001 From: Nicholas Clarke Date: Mon, 23 May 2022 11:08:29 -0700 Subject: [PATCH] Minor changes - normalize charts to start from 0 (except for account value) and remove vs-time in chart legends. --- .../account_page/AccountPerformancePerToken.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/account_page/AccountPerformancePerToken.tsx b/components/account_page/AccountPerformancePerToken.tsx index db2a558a..e583a401 100644 --- a/components/account_page/AccountPerformancePerToken.tsx +++ b/components/account_page/AccountPerformancePerToken.tsx @@ -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 = () => {

{`${t( `account-performance:${chartToShow}` - )} ${t('account-performance:vs-time')}`}

+ )}`}