| 1 |
package chart |
| 2 |
|
| 3 |
import ( |
| 4 |
"bytes" |
| 5 |
"testing" |
| 6 |
|
| 7 |
"github.com/wcharczuk/go-chart/v2/testutil" |
| 8 |
) |
| 9 |
|
| 10 |
func TestLegend(t *testing.T) { |
| 11 |
|
| 12 |
|
| 13 |
graph := Chart{ |
| 14 |
Series: []Series{ |
| 15 |
ContinuousSeries{ |
| 16 |
Name: "A test series", |
| 17 |
XValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0}, |
| 18 |
YValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0}, |
| 19 |
}, |
| 20 |
}, |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
graph.Elements = []Renderable{ |
| 25 |
Legend(&graph), |
| 26 |
} |
| 27 |
buf := bytes.NewBuffer([]byte{}) |
| 28 |
err := graph.Render(PNG, buf) |
| 29 |
testutil.AssertNil(t, err) |
| 30 |
testutil.AssertNotZero(t, buf.Len()) |
| 31 |
} |