| 198 | } |
| 199 | |
| 200 | func TestBarChartErr(t *testing.T) { |
| 201 | pt := plot.New() |
| 202 | pt.Title.Text = "Test Bar Chart Errors" |
| 203 | pt.X.Label.Text = "X Axis" |
| 204 | pt.Y.Min = 0 |
| 205 | pt.Y.Max = 100 |
| 206 | pt.Y.Label.Text = "Y Axis" |
| 207 | |
| 208 | data := make(plot.Values, 21) |
| 209 | for i := range data { |
| 210 | x := float32(i % 21) |
| 211 | data[i] = float32(50) + 40*math32.Sin((x/8)*math32.Pi) |
| 212 | } |
| 213 | |
| 214 | cos := make(plot.Values, 21) |
| 215 | for i := range data { |
| 216 | x := float32(i % 21) |
| 217 | cos[i] = float32(5) + 4*math32.Cos((x/8)*math32.Pi) |
| 218 | } |
| 219 | |
| 220 | l1, err := NewBarChart(data, cos) |
| 221 | if err != nil { |
| 222 | t.Error(err.Error()) |
| 223 | } |
| 224 | l1.Color = colors.Uniform(colors.Red) |
| 225 | pt.Add(l1) |
| 226 | pt.Legend.Add("Sine", l1) |
| 227 | |
| 228 | pt.Resize(image.Point{640, 480}) |
| 229 | pt.Draw() |
| 230 | imagex.Assert(t, pt.Pixels, "bar-err.png") |
| 231 | |
| 232 | l1.Horizontal = true |
| 233 | pt.UpdateRange() |
| 234 | pt.X.Min = 0 |
| 235 | pt.X.Max = 100 |
| 236 | pt.Draw() |
| 237 | imagex.Assert(t, pt.Pixels, "bar-err-horiz.png") |
| 238 | } |
| 239 | |
| 240 | func TestBarChartStack(t *testing.T) { |
| 241 | pt := plot.New() |