interfaces: refactor

This commit is contained in:
Inanc Gumus
2019-08-19 10:21:11 +03:00
parent b95be49711
commit 158f475a2d
89 changed files with 784 additions and 2 deletions

View File

@ -0,0 +1,42 @@
package main
import (
"os"
"strconv"
c "github.com/wcharczuk/go-chart"
)
type chartSummary struct {
title string
width, height int
}
func (s *chartSummary) summarize(results iterator) error {
w := os.Stdout
donut := c.DonutChart{
Title: s.title,
TitleStyle: c.Style{
FontSize: 35,
Show: true,
FontColor: c.ColorAlternateGreen,
},
Width: s.width,
Height: s.height,
}
results.each(func(r result) {
v := c.Value{
Label: r.domain + r.page + ": " + strconv.Itoa(r.visits),
Value: float64(r.visits),
Style: c.Style{
FontSize: 14,
},
}
donut.Values = append(donut.Values, v)
})
return donut.Render(c.SVG, w)
}