2016-08-06 03:26:17 -04:00
|
|
|
package chart
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
2024-10-27 22:52:38 -04:00
|
|
|
"git.smarteching.com/zeni/go-chart/v2/testutil"
|
2016-08-06 03:26:17 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestLegend(t *testing.T) {
|
2020-11-22 19:45:10 -05:00
|
|
|
// replaced new assertions helper
|
2016-08-06 03:26:17 -04:00
|
|
|
|
|
|
|
graph := Chart{
|
|
|
|
Series: []Series{
|
|
|
|
ContinuousSeries{
|
|
|
|
Name: "A test series",
|
|
|
|
XValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
|
|
|
|
YValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
//note we have to do this as a separate step because we need a reference to graph
|
|
|
|
graph.Elements = []Renderable{
|
|
|
|
Legend(&graph),
|
|
|
|
}
|
|
|
|
buf := bytes.NewBuffer([]byte{})
|
|
|
|
err := graph.Render(PNG, buf)
|
2020-11-22 19:45:10 -05:00
|
|
|
testutil.AssertNil(t, err)
|
|
|
|
testutil.AssertNotZero(t, buf.Len())
|
2016-08-06 03:26:17 -04:00
|
|
|
}
|