summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ab1f53c)
raw | patch | inline | side by side (parent: ab1f53c)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 25 Apr 2015 12:34:31 +0000 (14:34 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 25 Apr 2015 12:34:31 +0000 (14:34 +0200) |
This is the new, official fork of code.google.com/p/plotinum.
server/graph.go | patch | blob | history |
diff --git a/server/graph.go b/server/graph.go
index 5134ed6659f2ed5bd8539efe9d1580def3c4aec0..11254d6081526e60db2482dea11a1282982a566d 100644 (file)
--- a/server/graph.go
+++ b/server/graph.go
"net/http"
"time"
- "code.google.com/p/plotinum/plot"
- "code.google.com/p/plotinum/plotter"
- "code.google.com/p/plotinum/plotutil"
- "code.google.com/p/plotinum/vg"
- "code.google.com/p/plotinum/vg/vgsvg"
+ "github.com/gonum/plot"
+ "github.com/gonum/plot/plotter"
+ "github.com/gonum/plot/plotutil"
+ "github.com/gonum/plot/vg"
"github.com/sysdb/go/sysdb"
)
return
}
p.Add(plotter.NewGrid())
- p.X.Tick.Marker = dateTicks
+ p.X.Tick.Marker = dateTicks{}
var i int
for name, data := range ts.Data {
i++
}
- c := vgsvg.New(vg.Length(500), vg.Length(200))
- p.Draw(plot.MakeDrawArea(c))
+ pw, err := p.WriterTo(vg.Length(500), vg.Length(200), "svg")
+ if err != nil {
+ s.internal(w, fmt.Errorf("Failed to write plot: %v", err))
+ return
+ }
var buf bytes.Buffer
- if _, err := c.WriteTo(&buf); err != nil {
+ if _, err := pw.WriteTo(&buf); err != nil {
s.internal(w, fmt.Errorf("Failed to write plot: %v", err))
return
}
io.Copy(w, &buf)
}
-func dateTicks(min, max float64) []plot.Tick {
+type dateTicks struct{}
+
+func (dateTicks) Ticks(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)
+ ticks := plot.DefaultTicks{}.Ticks(min, max)
for i, t := range ticks {
if t.Label == "" {
// Skip minor ticks.