summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Roberts <lyricnz@gmail.com>2021-10-20 10:04:01 +1100
committerSimon Roberts <lyricnz@gmail.com>2021-10-20 10:04:01 +1100
commitd7cec61e837fcba0fa6a9973c7b06521c2804d06 (patch)
treee6ac115bcd8ff21bc4bbeb81d4b962d994d1004b
parent30fa30c057cfd3f8e7741e82c99f31feb1dccf4a (diff)
When hidePortfolioBalances scale the chart to the maximum price; avoids issue with resampling and using the last value
-rw-r--r--cointop/chart.go11
1 files 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
}
}
}