From 02a4fad443f27ded71e332b351c24f9dae88be32 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Sun, 21 May 2023 18:59:42 +0200 Subject: [PATCH] Refactor a bit the code that draws SVG polylines in circles --- pkg/dashboard.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/pkg/dashboard.go b/pkg/dashboard.go index 19d1f6e..b1ff83c 100644 --- a/pkg/dashboard.go +++ b/pkg/dashboard.go @@ -240,25 +240,24 @@ func buildDashboardChart(ctx context.Context, conn *Conn, company *Company, peri var sb strings.Builder sb.WriteString(fmt.Sprintf("", int(width)+20, int(height)+20)) sb.WriteString("") - sb.WriteString("") } - sb.WriteString("'/>") - sb.WriteString("", float64(i)/dataPoints*width, height-v/max*height)) } - sb.WriteString("'/>") - sb.WriteString("") - for i, v := range values { - sb.WriteString(fmt.Sprintf("", float64(i)/dataPoints*width, height-v.sales/max*height)) - sb.WriteString(fmt.Sprintf("", float64(i)/dataPoints*width, height-v.income/max*height)) - sb.WriteString(fmt.Sprintf("", float64(i)/dataPoints*width, height-v.expenses/max*height)) + writeCircle(i, v.sales) + writeCircle(i, v.income) + writeCircle(i, v.expenses) } sb.WriteString("") return template.HTML(sb.String())