wip pretty

main
bel 2023-10-27 09:21:52 -06:00
parent 2dbe5fa0fe
commit 35011bc005
1 changed files with 23 additions and 4 deletions

View File

@ -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 {