From d7cec61e837fcba0fa6a9973c7b06521c2804d06 Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Wed, 20 Oct 2021 10:04:01 +1100 Subject: [PATCH] When hidePortfolioBalances scale the chart to the maximum price; avoids issue with resampling and using the last value --- cointop/chart.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cointop/chart.go b/cointop/chart.go index dcca3f4..98ff63c 100644 --- a/cointop/chart.go +++ b/cointop/chart.go @@ -315,10 +315,15 @@ func (ct *Cointop) PortfolioChart() error { // Scale Portfolio Balances to hide value if ct.State.hidePortfolioBalances { - var lastPrice = data[len(data)-1] - if lastPrice > 0.0 { + scalePrice := 0.0 + for _, price := range data { + if price > scalePrice { + scalePrice = price + } + } + if scalePrice > 0.0 { for i, price := range data { - data[i] = 100 * price / lastPrice + data[i] = 100 * price / scalePrice } } }