wip pretty
parent
2dbe5fa0fe
commit
35011bc005
|
|
@ -144,9 +144,29 @@ func main() {
|
||||||
}
|
}
|
||||||
// /MODIFIERS
|
// /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{}
|
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 name, balance := range balances {
|
||||||
for currency, value := range balance {
|
for currency, value := range balance {
|
||||||
if _, ok := nameCurrencyDateValue[name]; !ok {
|
if _, ok := nameCurrencyDateValue[name]; !ok {
|
||||||
|
|
@ -165,8 +185,6 @@ func main() {
|
||||||
chart = NewChart(v)
|
chart = NewChart(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
dates := register.Dates()
|
|
||||||
names := register.Names()
|
|
||||||
chart.AddX(dates)
|
chart.AddX(dates)
|
||||||
|
|
||||||
if cumulative {
|
if cumulative {
|
||||||
|
|
@ -216,6 +234,7 @@ func main() {
|
||||||
}
|
}
|
||||||
primary := toChart(r.URL.Path == "/bal", r.URL.Query().Get("chart"), register)
|
primary := toChart(r.URL.Path == "/bal", r.URL.Query().Get("chart"), register)
|
||||||
if len(predicted) > 0 {
|
if len(predicted) > 0 {
|
||||||
|
log.Printf("overlapping predicted: %+v", predicted)
|
||||||
primary.Overlap(toChart(r.URL.Path == "/bal", "line", predicted))
|
primary.Overlap(toChart(r.URL.Path == "/bal", "line", predicted))
|
||||||
}
|
}
|
||||||
if err := primary.Render(w); err != nil {
|
if err := primary.Render(w); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue