2017-01-14 06:07:43 +00:00
|
|
|
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
2015-04-17 22:03:22 +00: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-06 21:48:09 +00:00
|
|
|
import ui "github.com/gizak/termui"
|
2015-04-17 22:03:22 +00:00
|
|
|
|
|
|
|
func main() {
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.Init()
|
|
|
|
defer ui.Close()
|
2015-04-17 22:03:22 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
bc := ui.NewMBarChart()
|
2015-04-28 00:27:11 +00:00
|
|
|
math := []int{90, 85, 90, 80}
|
|
|
|
english := []int{70, 85, 75, 60}
|
|
|
|
science := []int{75, 60, 80, 85}
|
|
|
|
compsci := []int{100, 100, 100, 100}
|
2015-04-17 22:03:22 +00:00
|
|
|
bc.Data[0] = math
|
|
|
|
bc.Data[1] = english
|
|
|
|
bc.Data[2] = science
|
|
|
|
bc.Data[3] = compsci
|
|
|
|
studentsName := []string{"Ken", "Rob", "Dennis", "Linus"}
|
2015-10-09 02:11:26 +00:00
|
|
|
bc.BorderLabel = "Student's Marks X-Axis=Name Y-Axis=Marks[Math,English,Science,ComputerScience] in %"
|
2015-04-17 22:03:22 +00:00
|
|
|
bc.Width = 100
|
2015-10-09 02:11:26 +00:00
|
|
|
bc.Height = 30
|
|
|
|
bc.Y = 0
|
2015-04-17 22:03:22 +00:00
|
|
|
bc.BarWidth = 10
|
|
|
|
bc.DataLabels = studentsName
|
2015-04-28 00:27:11 +00:00
|
|
|
bc.ShowScale = true //Show y_axis scale value (min and max)
|
|
|
|
bc.SetMax(400)
|
2015-04-17 22:03:22 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
bc.TextColor = ui.ColorGreen //this is color for label (x-axis)
|
|
|
|
bc.BarColor[3] = ui.ColorGreen //BarColor for computerscience
|
|
|
|
bc.BarColor[1] = ui.ColorYellow //Bar Color for english
|
|
|
|
bc.NumColor[3] = ui.ColorRed // Num color for computerscience
|
|
|
|
bc.NumColor[1] = ui.ColorRed // num color for english
|
2015-04-17 22:03:22 +00:00
|
|
|
|
|
|
|
//Other colors are automatically populated, btw All the students seems do well in computerscience. :p
|
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.Render(bc)
|
2015-04-17 22:03:22 +00:00
|
|
|
|
2018-09-06 23:36:14 +00:00
|
|
|
ui.Handle("q", func(ui.Event) {
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.StopLoop()
|
2015-10-09 02:11:26 +00:00
|
|
|
})
|
2018-09-06 21:48:09 +00:00
|
|
|
|
|
|
|
ui.Loop()
|
2015-10-09 02:11:26 +00:00
|
|
|
|
2015-04-17 22:03:22 +00:00
|
|
|
}
|