-
Notifications
You must be signed in to change notification settings - Fork 10
/
flot_test.go
42 lines (32 loc) · 913 Bytes
/
flot_test.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 lttb
import (
"bytes"
"html/template"
)
var reportTmpl = template.Must(template.New("report").Parse(`
<html>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.time.min.js"></script>
<script type="text/javascript">
var data = {{ . }};
$(document).ready(function() {
$.plot($("#placeholder"), [data], {
lines: { show: true },
points: { show: true, fillColor: false },
})
})
</script>
<body>
<div id="placeholder" style="width:900px; height:300px"></div>
</body>
</html>
`))
func flot(data [][2]float64) ([]byte, error) {
var b bytes.Buffer
err := reportTmpl.Execute(&b, data)
if err != nil {
return nil, err
}
return b.Bytes(), nil
}