remove: gochart go mod incompatible

This commit is contained in:
Inanc Gumus
2019-08-26 17:55:46 +03:00
parent 1299552d88
commit 7e82a94bae
2 changed files with 59 additions and 74 deletions

View File

@ -1,46 +1,38 @@
package main package main
import ( // func chartWriter(w io.Writer) outputFn {
"io" // return func(res []result) error {
"sort" // return chartWrite(w, res)
"strconv" // }
// }
"github.com/wcharczuk/go-chart" // func chartWrite(w io.Writer, res []result) error {
) // sort.Slice(res, func(i, j int) bool {
// return res[i].domain > res[j].domain
// })
func chartWriter(w io.Writer) outputFn { // donut := chart.DonutChart{
return func(res []result) error { // Title: "Total Visits Per Domain",
return chartWrite(w, res) // TitleStyle: chart.Style{
} // FontSize: 35,
} // Show: true,
// FontColor: chart.ColorAlternateGreen,
// },
// Width: 1920,
// Height: 800,
// }
func chartWrite(w io.Writer, res []result) error { // for _, r := range res {
sort.Slice(res, func(i, j int) bool { // v := chart.Value{
return res[i].domain > res[j].domain // Label: r.domain + r.page + ": " + strconv.Itoa(r.visits),
}) // Value: float64(r.visits),
// Style: chart.Style{
// FontSize: 14,
// },
// }
donut := chart.DonutChart{ // donut.Values = append(donut.Values, v)
Title: "Total Visits Per Domain", // }
TitleStyle: chart.Style{
FontSize: 35,
Show: true,
FontColor: chart.ColorAlternateGreen,
},
Width: 1920,
Height: 800,
}
for _, r := range res { // return donut.Render(chart.SVG, w)
v := chart.Value{ // }
Label: r.domain + r.page + ": " + strconv.Itoa(r.visits),
Value: float64(r.visits),
Style: chart.Style{
FontSize: 14,
},
}
donut.Values = append(donut.Values, v)
}
return donut.Render(chart.SVG, w)
}

View File

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