2017-01-14 06:07:43 +00:00
|
|
|
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
2015-03-20 20:21:50 +00:00
|
|
|
// Use of this source code is governed by a MIT license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
|
|
|
// +build ignore
|
|
|
|
|
2015-03-13 17:20:17 +00:00
|
|
|
package main
|
|
|
|
|
2019-01-24 04:12:10 +00:00
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2019-03-07 10:50:20 +00:00
|
|
|
ui "github.com/gizak/termui/v3"
|
|
|
|
"github.com/gizak/termui/v3/widgets"
|
2019-01-24 04:12:10 +00:00
|
|
|
)
|
2015-03-13 17:20:17 +00:00
|
|
|
|
|
|
|
func main() {
|
2019-01-24 04:12:10 +00:00
|
|
|
if err := ui.Init(); err != nil {
|
|
|
|
log.Fatalf("failed to initialize termui: %v", err)
|
2018-09-07 01:22:04 +00:00
|
|
|
}
|
2018-09-06 21:48:09 +00:00
|
|
|
defer ui.Close()
|
|
|
|
|
2019-01-24 04:12:10 +00:00
|
|
|
bc := widgets.NewBarChart()
|
|
|
|
bc.Data = []float64{3, 2, 5, 3, 9, 3}
|
|
|
|
bc.Labels = []string{"S0", "S1", "S2", "S3", "S4", "S5"}
|
|
|
|
bc.Title = "Bar Chart"
|
|
|
|
bc.SetRect(5, 5, 100, 25)
|
|
|
|
bc.BarWidth = 5
|
|
|
|
bc.BarColors = []ui.Color{ui.ColorRed, ui.ColorGreen}
|
|
|
|
bc.LabelStyles = []ui.Style{ui.NewStyle(ui.ColorBlue)}
|
|
|
|
bc.NumStyles = []ui.Style{ui.NewStyle(ui.ColorYellow)}
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.Render(bc)
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2018-11-29 23:32:42 +00:00
|
|
|
uiEvents := ui.PollEvents()
|
2018-11-29 02:19:34 +00:00
|
|
|
for {
|
2018-11-29 23:32:42 +00:00
|
|
|
e := <-uiEvents
|
2018-11-29 02:19:34 +00:00
|
|
|
switch e.ID {
|
|
|
|
case "q", "<C-c>":
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2015-03-13 17:20:17 +00:00
|
|
|
}
|