diff --git a/cmd/clitest/main.go b/cmd/clitest/main.go index 24c3b01..36738e4 100644 --- a/cmd/clitest/main.go +++ b/cmd/clitest/main.go @@ -144,9 +144,29 @@ func main() { } // /MODIFIERS - toChart := func(cumulative bool, display string, register ledger.Register) Chart { + dates := register.Dates() + names := register.Names() + for _, date := range predicted.Dates() { + found := false + for i := range dates { + found = found || dates[i] == date + } + if !found { + dates = append(dates, date) + } + } + for _, name := range predicted.Names() { + found := false + for i := range names { + found = found || names[i] == name + } + if !found { + names = append(names, name) + } + } + toChart := func(cumulative bool, display string, reg ledger.Register) Chart { nameCurrencyDateValue := map[string]map[ledger.Currency]map[string]float64{} - for date, balances := range register { + for date, balances := range reg { for name, balance := range balances { for currency, value := range balance { if _, ok := nameCurrencyDateValue[name]; !ok { @@ -165,8 +185,6 @@ func main() { chart = NewChart(v) } - dates := register.Dates() - names := register.Names() chart.AddX(dates) if cumulative { @@ -216,6 +234,7 @@ func main() { } primary := toChart(r.URL.Path == "/bal", r.URL.Query().Get("chart"), register) if len(predicted) > 0 { + log.Printf("overlapping predicted: %+v", predicted) primary.Overlap(toChart(r.URL.Path == "/bal", "line", predicted)) } if err := primary.Render(w); err != nil {