termui/_example/barchart.go

37 lines
886 B
Go
Raw Normal View History

2016-11-11 12:25:53 +08:00
// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
2015-03-21 04:21:50 +08:00
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
// +build ignore
package main
import "github.com/gizak/termui"
func main() {
2015-10-29 09:19:35 +08:00
if err := termui.Init(); err != nil {
panic(err)
}
defer termui.Close()
bc := termui.NewBarChart()
data := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6}
bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"}
2015-10-09 10:11:26 +08:00
bc.BorderLabel = "Bar Chart"
bc.Data = data
bc.Width = 26
bc.Height = 10
bc.DataLabels = bclabels
bc.TextColor = termui.ColorGreen
bc.BarColor = termui.ColorRed
bc.NumColor = termui.ColorYellow
termui.Render(bc)
2015-10-09 10:11:26 +08:00
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}