get last 30 days
continuous-integration/drone/push Build is passing Details

master
dustoair 3 years ago
parent 4f60ab046e
commit a175f800cc

@ -25,10 +25,10 @@ func getRand(len int) []float64 {
func Draw() {
values := [][]float64{
getRand(7),
getRand(7),
getRand(7),
getRand(7),
getRand(30),
getRand(30),
getRand(30),
getRand(30),
}
p, err := charts.LineRender(
values,
@ -37,7 +37,7 @@ func Draw() {
charts.WidthOptionFunc(720),
charts.HeightOptionFunc(1280),
charts.TitleTextOptionFunc("symbol price"),
charts.XAxisDataOptionFunc(getLastDays()),
charts.XAxisDataOptionFunc(getLastDays(30)),
charts.LegendLabelsOptionFunc([]string{
"BTC",
"ETH",
@ -68,18 +68,14 @@ func Draw() {
}
}
func getLastDays() []string {
func getLastDays(len int) []string {
now := time.Now()
getDay := func(t time.Time, dif int) string {
return t.AddDate(0, 0, dif).Format("01/02")
}
return []string{
getDay(now, -6),
getDay(now, -5),
getDay(now, -4),
getDay(now, -3),
getDay(now, -2),
getDay(now, -1),
getDay(now, 0),
var res []string
for i := 1; i <= len; i++ {
res = append(res, getDay(now, i-len))
}
return res
}

Loading…
Cancel
Save