MCPcopy Create free account
hub / github.com/cogentcore/core / TestBarChartErr

Function TestBarChartErr

plot/plots/plot_test.go:200–238  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

198}
199
200func 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
240func TestBarChartStack(t *testing.T) {
241 pt := plot.New()

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
SinFunction · 0.92
CosFunction · 0.92
UniformFunction · 0.92
AssertFunction · 0.92
NewBarChartFunction · 0.85
ErrorMethod · 0.65
AddMethod · 0.65
DrawMethod · 0.65
ResizeMethod · 0.45
UpdateRangeMethod · 0.45

Tested by

no test coverage detected