2017-01-13 23:07:43 -07:00
|
|
|
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
|
2015-03-20 14:21:50 -06: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 11:20:17 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
ui "github.com/gizak/termui"
|
2015-03-13 11:20:17 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-09-06 15:48:09 -06:00
|
|
|
err := ui.Init()
|
|
|
|
defer ui.Close()
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-08-16 18:40:32 -06:00
|
|
|
sinps := (func() map[string][]float64 {
|
2015-03-13 11:20:17 -06:00
|
|
|
n := 220
|
2018-08-16 18:40:32 -06:00
|
|
|
ps := make(map[string][]float64)
|
|
|
|
ps["first"] = make([]float64, n)
|
|
|
|
ps["second"] = make([]float64, n)
|
|
|
|
for i := 0; i < n; i++ {
|
|
|
|
ps["first"][i] = 1 + math.Sin(float64(i)/5)
|
|
|
|
ps["second"][i] = 1 + math.Cos(float64(i)/5)
|
2015-03-13 11:20:17 -06:00
|
|
|
}
|
|
|
|
return ps
|
|
|
|
})()
|
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
lc0 := ui.NewLineChart()
|
2015-10-08 20:11:26 -06:00
|
|
|
lc0.BorderLabel = "braille-mode Line Chart"
|
2015-03-13 11:20:17 -06:00
|
|
|
lc0.Data = sinps
|
|
|
|
lc0.Width = 50
|
|
|
|
lc0.Height = 12
|
|
|
|
lc0.X = 0
|
|
|
|
lc0.Y = 0
|
2018-09-06 15:48:09 -06:00
|
|
|
lc0.AxesColor = ui.ColorWhite
|
|
|
|
lc0.LineColor["first"] = ui.ColorGreen | ui.AttrBold
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
lc1 := ui.NewLineChart()
|
2015-10-08 20:11:26 -06:00
|
|
|
lc1.BorderLabel = "dot-mode Line Chart"
|
2015-03-13 11:20:17 -06:00
|
|
|
lc1.Mode = "dot"
|
|
|
|
lc1.Data = sinps
|
|
|
|
lc1.Width = 26
|
|
|
|
lc1.Height = 12
|
|
|
|
lc1.X = 51
|
|
|
|
lc1.DotStyle = '+'
|
2018-09-06 15:48:09 -06:00
|
|
|
lc1.AxesColor = ui.ColorWhite
|
|
|
|
lc1.LineColor["first"] = ui.ColorYellow | ui.AttrBold
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
lc2 := ui.NewLineChart()
|
2015-10-08 20:11:26 -06:00
|
|
|
lc2.BorderLabel = "dot-mode Line Chart"
|
2015-03-13 11:20:17 -06:00
|
|
|
lc2.Mode = "dot"
|
2018-08-16 18:40:32 -06:00
|
|
|
lc2.Data["first"] = sinps["first"][4:]
|
|
|
|
lc2.Data["second"] = sinps["second"][4:]
|
2015-03-13 11:20:17 -06:00
|
|
|
lc2.Width = 77
|
|
|
|
lc2.Height = 16
|
|
|
|
lc2.X = 0
|
|
|
|
lc2.Y = 12
|
2018-09-06 15:48:09 -06:00
|
|
|
lc2.AxesColor = ui.ColorWhite
|
|
|
|
lc2.LineColor["first"] = ui.ColorCyan | ui.AttrBold
|
|
|
|
|
|
|
|
ui.Render(lc0, lc1, lc2)
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.Handle("/sys/kbd/q", func(ui.Event) {
|
|
|
|
ui.StopLoop()
|
2015-10-08 20:11:26 -06:00
|
|
|
})
|
2015-03-13 11:20:17 -06:00
|
|
|
|
2018-09-06 15:48:09 -06:00
|
|
|
ui.Loop()
|
2015-03-13 11:20:17 -06:00
|
|
|
}
|