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

Function TestBarChartStack

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

Source from the content-addressed store, hash-verified

238}
239
240func TestBarChartStack(t *testing.T) {
241 pt := plot.New()
242 pt.Title.Text = "Test Bar Chart Stacked"
243 pt.X.Label.Text = "X Axis"
244 pt.Y.Min = 0
245 pt.Y.Max = 100
246 pt.Y.Label.Text = "Y Axis"
247
248 data := make(plot.Values, 21)
249 for i := range data {
250 x := float32(i % 21)
251 data[i] = float32(50) + 40*math32.Sin((x/8)*math32.Pi)
252 }
253
254 cos := make(plot.Values, 21)
255 for i := range data {
256 x := float32(i % 21)
257 cos[i] = float32(5) + 4*math32.Cos((x/8)*math32.Pi)
258 }
259
260 l1, err := NewBarChart(data, nil)
261 if err != nil {
262 t.Error(err.Error())
263 }
264 l1.Color = colors.Uniform(colors.Red)
265 pt.Add(l1)
266 pt.Legend.Add("Sine", l1)
267
268 l2, err := NewBarChart(cos, nil)
269 if err != nil {
270 t.Error(err.Error())
271 }
272 l2.Color = colors.Uniform(colors.Blue)
273 l2.StackedOn = l1
274 pt.Add(l2)
275 pt.Legend.Add("Cos", l2)
276
277 pt.Resize(image.Point{640, 480})
278 pt.Draw()
279 imagex.Assert(t, pt.Pixels, "bar-stacked.png")
280}
281
282type XYErr struct {
283 plot.XYs

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected