termui/_examples/barchart.go

33 lines
772 B
Go
Raw Normal View History

2017-01-14 14:07:43 +08:00
// Copyright 2017 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
2018-09-07 05:48:09 +08:00
import ui "github.com/gizak/termui"
func main() {
2018-09-07 05:48:09 +08:00
ui.Init()
defer ui.Close()
bc := ui.NewBarChart()
bc.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}
bc.DataLabels = []string{"S0", "S1", "S2", "S3", "S4", "S5"}
2015-10-09 10:11:26 +08:00
bc.BorderLabel = "Bar Chart"
bc.Width = 26
bc.Height = 10
2018-09-07 05:48:09 +08:00
bc.TextColor = ui.ColorGreen
bc.BarColor = ui.ColorRed
bc.NumColor = ui.ColorYellow
2018-09-07 05:48:09 +08:00
ui.Render(bc)
ui.Handle("q", "<Insert>", func(ui.Event) {
2018-09-07 05:48:09 +08:00
ui.StopLoop()
2015-10-09 10:11:26 +08:00
})
2018-09-07 05:48:09 +08:00
ui.Loop()
}