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
|
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
import ui "github.com/gizak/termui"
|
2015-03-13 17:20:17 +00:00
|
|
|
|
|
|
|
func main() {
|
2018-09-07 01:22:04 +00:00
|
|
|
err := ui.Init()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-09-06 21:48:09 +00:00
|
|
|
defer ui.Close()
|
2015-03-13 17:20:17 +00:00
|
|
|
|
|
|
|
data := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6}
|
2018-09-06 21:48:09 +00:00
|
|
|
spl0 := ui.NewSparkline()
|
2015-03-13 17:20:17 +00:00
|
|
|
spl0.Data = data[3:]
|
|
|
|
spl0.Title = "Sparkline 0"
|
2018-09-06 21:48:09 +00:00
|
|
|
spl0.LineColor = ui.ColorGreen
|
2015-03-13 17:20:17 +00:00
|
|
|
|
|
|
|
// single
|
2018-09-06 21:48:09 +00:00
|
|
|
spls0 := ui.NewSparklines(spl0)
|
2015-03-13 17:20:17 +00:00
|
|
|
spls0.Height = 2
|
|
|
|
spls0.Width = 20
|
2015-10-09 02:11:26 +00:00
|
|
|
spls0.Border = false
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
spl1 := ui.NewSparkline()
|
2015-03-13 17:20:17 +00:00
|
|
|
spl1.Data = data
|
|
|
|
spl1.Title = "Sparkline 1"
|
2018-09-06 21:48:09 +00:00
|
|
|
spl1.LineColor = ui.ColorRed
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
spl2 := ui.NewSparkline()
|
2015-03-13 17:20:17 +00:00
|
|
|
spl2.Data = data[5:]
|
|
|
|
spl2.Title = "Sparkline 2"
|
2018-09-06 21:48:09 +00:00
|
|
|
spl2.LineColor = ui.ColorMagenta
|
2015-03-13 17:20:17 +00:00
|
|
|
|
|
|
|
// group
|
2018-09-06 21:48:09 +00:00
|
|
|
spls1 := ui.NewSparklines(spl0, spl1, spl2)
|
2015-03-13 17:20:17 +00:00
|
|
|
spls1.Height = 8
|
|
|
|
spls1.Width = 20
|
|
|
|
spls1.Y = 3
|
2015-10-09 02:11:26 +00:00
|
|
|
spls1.BorderLabel = "Group Sparklines"
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
spl3 := ui.NewSparkline()
|
2015-03-13 17:20:17 +00:00
|
|
|
spl3.Data = data
|
|
|
|
spl3.Title = "Enlarged Sparkline"
|
|
|
|
spl3.Height = 8
|
2018-09-06 21:48:09 +00:00
|
|
|
spl3.LineColor = ui.ColorYellow
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
spls2 := ui.NewSparklines(spl3)
|
2015-03-13 17:20:17 +00:00
|
|
|
spls2.Height = 11
|
|
|
|
spls2.Width = 30
|
2018-09-06 21:48:09 +00:00
|
|
|
spls2.BorderFg = ui.ColorCyan
|
2015-03-13 17:20:17 +00:00
|
|
|
spls2.X = 21
|
2015-10-09 02:11:26 +00:00
|
|
|
spls2.BorderLabel = "Tweeked Sparkline"
|
2015-03-13 17:20:17 +00:00
|
|
|
|
2018-09-06 21:48:09 +00:00
|
|
|
ui.Render(spls0, spls1, spls2)
|
2015-03-13 17:20:17 +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-03-13 17:20:17 +00:00
|
|
|
}
|