summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 16dddfc)
raw | patch | inline | side by side (parent: 16dddfc)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 21 Nov 2014 20:36:21 +0000 (21:36 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 21 Nov 2014 20:37:06 +0000 (21:37 +0100) |
This is a very basic implementation which is not well suited for all time
ranges but it's good enough to get started.
ranges but it's good enough to get started.
server/graph.go | patch | blob | history |
diff --git a/server/graph.go b/server/graph.go
index 054fe8eac4a18827b82bfe6c8f84519493d1f705..11b55b84fef483d16ff545bf50894444fdd58576 100644 (file)
--- a/server/graph.go
+++ b/server/graph.go
return
}
p.Add(plotter.NewGrid())
+ p.X.Tick.Marker = dateTicks
var i int
for name, data := range ts.Data {
io.Copy(w, &buf)
}
+func dateTicks(min, max float64) []plot.Tick {
+ // TODO: this is surely not the best we can do
+ // but it'll distribute ticks evenly.
+ ticks := plot.DefaultTicks(min, max)
+ for i, t := range ticks {
+ if t.Label == "" {
+ // Skip minor ticks.
+ continue
+ }
+ ticks[i].Label = time.Unix(0, int64(t.Value)).Format(time.RFC822)
+ }
+ return ticks
+}
+
// vim: set tw=78 sw=4 sw=4 noexpandtab :