2016-01-26 18:45:18 -07:00
|
|
|
// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
|
2015-04-17 16:03:22 -06: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() {
|
|
|
|
err := termui.Init()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer termui.Close()
|
|
|
|
|
2015-10-08 20:11:26 -06:00
|
|
|
//termui.UseTheme("helloworld")
|
2015-04-17 16:03:22 -06:00
|
|
|
|
|
|
|
bc := termui.NewMBarChart()
|
2015-04-27 18:27:11 -06: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 16:03:22 -06: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-08 20:11:26 -06:00
|
|
|
bc.BorderLabel = "Student's Marks X-Axis=Name Y-Axis=Marks[Math,English,Science,ComputerScience] in %"
|
2015-04-17 16:03:22 -06:00
|
|
|
bc.Width = 100
|
2015-10-08 20:11:26 -06:00
|
|
|
bc.Height = 30
|
|
|
|
bc.Y = 0
|
2015-04-17 16:03:22 -06:00
|
|
|
bc.BarWidth = 10
|
|
|
|
bc.DataLabels = studentsName
|
2015-04-27 18:27:11 -06:00
|
|
|
bc.ShowScale = true //Show y_axis scale value (min and max)
|
|
|
|
bc.SetMax(400)
|
2015-04-17 16:03:22 -06:00
|
|
|
|
|
|
|
bc.TextColor = termui.ColorGreen //this is color for label (x-axis)
|
|
|
|
bc.BarColor[3] = termui.ColorGreen //BarColor for computerscience
|
|
|
|
bc.BarColor[1] = termui.ColorYellow //Bar Color for english
|
|
|
|
bc.NumColor[3] = termui.ColorRed // Num color for computerscience
|
|
|
|
bc.NumColor[1] = termui.ColorRed // num color for english
|
|
|
|
|
|
|
|
//Other colors are automatically populated, btw All the students seems do well in computerscience. :p
|
|
|
|
|
|
|
|
termui.Render(bc)
|
|
|
|
|
2015-10-08 20:11:26 -06:00
|
|
|
termui.Handle("/sys/kbd/q", func(termui.Event) {
|
|
|
|
termui.StopLoop()
|
|
|
|
})
|
|
|
|
termui.Loop()
|
|
|
|
|
2015-04-17 16:03:22 -06:00
|
|
|
}
|