Exemplo n.º 1
0
func main() {
	width := 1200
	height := 300

	bgColor := util.Color{
		R: 1,
		G: 1,
		B: 1,
	}

	window := inertia.NewWindow(width, height, "my window", bgColor, 60)
	window.Show()

	ch, err := window.NewChart("my chart 1")
	if err != nil {
		log.Fatal(err)
	}
	ch.SetColor(util.GetRandomColor())
	ch.SetLineWidth(3)

	ch2, err := window.NewChart("my chart 2")
	if err != nil {
		log.Fatal(err)
	}
	ch2.SetColor(util.GetRandomColor())
	ch2.SetLineWidth(2)

	ch3, err := window.NewChart("my chart 3")
	if err != nil {
		log.Fatal(err)
	}
	ch3.SetColor(util.GetRandomColor())
	ch3.SetLineWidth(2)

	fillChart := func(c *chart.Chart, minY, maxY, minDur, maxDur int) {
		for {
			c.Push(util.GetRandom(minY, maxY))
			time.Sleep(time.Duration(util.GetRandom(minDur, maxDur)) * time.Millisecond)
		}
	}

	go fillChart(ch, 0, height/3, 50, 500)
	go fillChart(ch2, height/3, height/3*2, 40, 70)
	go fillChart(ch3, height/3*2, height, 50, 1500)

	select {}
}
Exemplo n.º 2
0
func main() {
	width := 1200
	height := 300

	bgColor := util.Color{
		R: 1,
		G: 1,
		B: 1,
	}

	window := inertia.NewWindow(width, height, "my window", bgColor, 60)
	window.Show()

	ch, err := window.NewChart("my chart 1")
	if err != nil {
		log.Fatal(err)
	}

	for {
		ch.Push(util.GetRandom(0, height))
		time.Sleep(time.Duration(util.GetRandom(100, 300)) * time.Millisecond)
	}
}