From eb47988464084b0a72619ba5fa90353d4a580fe1 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Sun, 21 May 2023 00:14:48 +0200 Subject: [PATCH] Add a background rectangle to the chart and fix NaN when max = 0 --- pkg/dashboard.go | 19 ++++++------------- web/static/numerus.css | 4 ++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pkg/dashboard.go b/pkg/dashboard.go index 8b9173b..19d1f6e 100644 --- a/pkg/dashboard.go +++ b/pkg/dashboard.go @@ -227,15 +227,19 @@ func buildDashboardChart(ctx context.Context, conn *Conn, company *Company, peri max = math.Max(v.income, max) max = math.Max(v.expenses, max) } + if max == 0 { + max = 1 + } if rows.Err() != nil { panic(rows.Err()) } width := 1024. - height := 300. - dataPoints := float64(len(values)) + height := 256. + dataPoints := float64(len(values)) - 1 var sb strings.Builder sb.WriteString(fmt.Sprintf("", int(width)+20, int(height)+20)) + sb.WriteString("") sb.WriteString("