2016-07-07 03:54:00 +02:00
|
|
|
package chart
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/blendlabs/go-assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestChartSingleSeries(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
now := time.Now()
|
|
|
|
c := Chart{
|
|
|
|
Title: "Hello!",
|
|
|
|
Width: 1024,
|
|
|
|
Height: 400,
|
2016-07-07 23:44:03 +02:00
|
|
|
YRange: Range{
|
|
|
|
Min: 0.0,
|
|
|
|
Max: 4.0,
|
|
|
|
},
|
2016-07-07 03:54:00 +02:00
|
|
|
Series: []Series{
|
|
|
|
TimeSeries{
|
2016-07-07 23:44:03 +02:00
|
|
|
Name: "goog",
|
2016-07-07 03:54:00 +02:00
|
|
|
XValues: []time.Time{now.AddDate(0, 0, -3), now.AddDate(0, 0, -2), now.AddDate(0, 0, -1)},
|
|
|
|
YValues: []float64{1.0, 2.0, 3.0},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer := bytes.NewBuffer([]byte{})
|
|
|
|
c.Render(PNG, buffer)
|
|
|
|
assert.NotEmpty(buffer.Bytes())
|
|
|
|
}
|