-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensors_pie.go
42 lines (33 loc) · 861 Bytes
/
sensors_pie.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// --------------------------------------------
//
// --------------------------------------------
package main
import (
"log"
"net/http"
"strconv"
)
/*---------------------
*/
func HandlerPIE(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/pie" {
http.NotFound(w, r)
return
}
var pp PieData
pp.ChartType = "pie"
pp.Title = "Sensors activities 2016"
pp.SubTitle = "GCP sample test"
pp.SeriesName = "Sensors"
// Prepare the data array (label/value)
//[[lab1, val1],[lab2, val2],...] !!! text/html
pp.DataArray = "["
for i := range TagsList {
pp.DataArray = pp.DataArray + "['" + TagsList[i].TagId + "' , " + strconv.Itoa(TagsList[i].Count) + "],"
}
pp.DataArray = pp.DataArray + "]"
/*----- */
if err := tpl.ExecuteTemplate(w, "pie.html", pp); err != nil {
log.Printf("Could not execute template: %v", err)
}
}