diff --git a/controller/helpers.go b/controller/helpers.go index ab88cda..06b15a4 100644 --- a/controller/helpers.go +++ b/controller/helpers.go @@ -2,10 +2,11 @@ package controller import ( "fmt" - "github.com/gorilla/mux" "net/http" "regexp" "time" + + "github.com/gorilla/mux" ) const ( diff --git a/controller/repositories.go b/controller/repositories.go index 5d151cc..854bc93 100644 --- a/controller/repositories.go +++ b/controller/repositories.go @@ -2,13 +2,14 @@ package controller import ( "fmt" + "html/template" + "io/fs" + "net/http" + "github.com/caarlos0/httperr" "github.com/caarlos0/starcharts/internal/cache" "github.com/caarlos0/starcharts/internal/github" "github.com/gorilla/mux" - "html/template" - "io/fs" - "net/http" ) const ( diff --git a/internal/chart/font.go b/internal/chart/font.go index d1d4cd9..b8e5c7c 100644 --- a/internal/chart/font.go +++ b/internal/chart/font.go @@ -2,8 +2,9 @@ package chart import ( _ "embed" - "github.com/golang/freetype/truetype" "sync" + + "github.com/golang/freetype/truetype" ) var ( diff --git a/internal/chart/helpers.go b/internal/chart/helpers.go index e8b6f2e..825612f 100644 --- a/internal/chart/helpers.go +++ b/internal/chart/helpers.go @@ -2,10 +2,11 @@ package chart import ( "fmt" + "time" + "github.com/caarlos0/starcharts/internal/chart/svg" "github.com/golang/freetype/truetype" "golang.org/x/image/font" - "time" ) func measureText(body string, size float64) Box { diff --git a/internal/chart/render.go b/internal/chart/render.go index 1244ae6..a0b00ec 100644 --- a/internal/chart/render.go +++ b/internal/chart/render.go @@ -57,8 +57,8 @@ func (c *Chart) Render(w io.Writer) { } func (c *Chart) getRanges(canvas *Box) (*Range, *Range) { - var minX, maxX = math.MaxFloat64, -math.MaxFloat64 - var minY, maxY = math.MaxFloat64, -math.MaxFloat64 + minX, maxX := math.MaxFloat64, -math.MaxFloat64 + minY, maxY := math.MaxFloat64, -math.MaxFloat64 seriesLength := c.Series.Len() for index := 0; index < seriesLength; index++ { diff --git a/internal/chart/series.go b/internal/chart/series.go index a4898fd..94e28f9 100644 --- a/internal/chart/series.go +++ b/internal/chart/series.go @@ -1,9 +1,10 @@ package chart import ( - "github.com/caarlos0/starcharts/internal/chart/svg" "io" "time" + + "github.com/caarlos0/starcharts/internal/chart/svg" ) type Series struct { @@ -16,6 +17,7 @@ type Series struct { func (ts *Series) Len() int { return len(ts.XValues) } + func (ts *Series) GetValues(index int) (x, y float64) { x = toFloat64(ts.XValues[index]) y = ts.YValues[index] diff --git a/internal/chart/x_axis.go b/internal/chart/x_axis.go index c83ac3e..7c3c3e2 100644 --- a/internal/chart/x_axis.go +++ b/internal/chart/x_axis.go @@ -1,9 +1,10 @@ package chart import ( - "github.com/caarlos0/starcharts/internal/chart/svg" "io" "math" + + "github.com/caarlos0/starcharts/internal/chart/svg" ) type XAxis struct { @@ -15,7 +16,7 @@ type XAxis struct { func (xa *XAxis) Measure(canvas *Box, ra *Range, ticks []Tick) *Box { var ltx, rtx int var tx, ty int - var left, right, bottom = math.MaxInt32, 0, 0 + left, right, bottom := math.MaxInt32, 0, 0 for _, t := range ticks { v := t.Value tb := measureText(t.Label, AxisFontSize) diff --git a/internal/chart/y_axis.go b/internal/chart/y_axis.go index 17a6cc8..729bfce 100644 --- a/internal/chart/y_axis.go +++ b/internal/chart/y_axis.go @@ -1,9 +1,10 @@ package chart import ( - "github.com/caarlos0/starcharts/internal/chart/svg" "io" "math" + + "github.com/caarlos0/starcharts/internal/chart/svg" ) type YAxis struct {