mirror of https://github.com/statping/statping
index chart fix
parent
ac2ce43499
commit
fc1fe03f89
|
@ -71,15 +71,17 @@ func renderServiceChartsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Cache-Control", "max-age=60")
|
w.Header().Set("Cache-Control", "max-age=60")
|
||||||
|
|
||||||
//var data []string
|
//var data []string
|
||||||
//end := now.EndOfDay().UTC()
|
end := time.Now().UTC()
|
||||||
//start := now.BeginningOfDay().UTC()
|
start := time.Now().Add((-24 * 7) * time.Hour).UTC()
|
||||||
var srvs []*core.Service
|
var srvs []*core.Service
|
||||||
for _, s := range services {
|
for _, s := range services {
|
||||||
srvs = append(srvs, s.(*core.Service))
|
srvs = append(srvs, s.(*core.Service))
|
||||||
}
|
}
|
||||||
out := struct {
|
out := struct {
|
||||||
Services []*core.Service
|
Services []*core.Service
|
||||||
}{srvs}
|
Start int64
|
||||||
|
End int64
|
||||||
|
}{srvs, start.Unix(), end.Unix()}
|
||||||
|
|
||||||
executeJSResponse(w, r, "charts.js", out)
|
executeJSResponse(w, r, "charts.js", out)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
{{define "charts"}}{{ range Services }}
|
{{define "charts"}}
|
||||||
|
{{$start := .Start}}
|
||||||
|
{{$end := .End}}
|
||||||
|
{{ range .Services }}
|
||||||
var ctx_{{js .Id}} = document.getElementById("service_{{js .Id}}").getContext('2d');
|
var ctx_{{js .Id}} = document.getElementById("service_{{js .Id}}").getContext('2d');
|
||||||
var chartdata_{{js .Id}} = new Chart(ctx_{{js .Id}}, {
|
var chartdata_{{js .Id}} = new Chart(ctx_{{js .Id}}, {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
|
@ -133,5 +136,5 @@ var chartdata_{{js .Id}} = new Chart(ctx_{{js .Id}}, {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AjaxChart(chartdata_{{js .Id}},{{js .Id}},0,99999999999,"hour");
|
AjaxChart(chartdata_{{js .Id}},{{js .Id}},{{$start}},{{$end}},"hour");
|
||||||
{{end}}{{end}}
|
{{end}}{{end}}
|
||||||
|
|
Loading…
Reference in New Issue