convert expanded mem widget to mbarchart, add innerlabel

This commit is contained in:
Bradley Cicenas
2017-03-06 23:58:04 +00:00
parent d94aed1531
commit 8e995a37c6
4 changed files with 97 additions and 44 deletions

View File

@@ -4,25 +4,31 @@ import (
ui "github.com/gizak/termui"
)
type ExpandedCpu struct {
type Cpu struct {
*ui.LineChart
hist FloatHist
}
func NewExpandedCpu() *ExpandedCpu {
cpu := &ExpandedCpu{ui.NewLineChart(), NewFloatHist(60)}
func NewCpu() *Cpu {
cpu := &Cpu{ui.NewLineChart(), NewFloatHist(55)}
cpu.Mode = "dot"
cpu.BorderLabel = "CPU"
cpu.Height = 10
cpu.Height = 12
cpu.Width = colWidth[0]
cpu.X = 0
cpu.Y = 6
cpu.Data = cpu.hist.Data
cpu.DataLabels = cpu.hist.Labels
cpu.AxesColor = ui.ColorDefault
cpu.LineColor = ui.ColorGreen
// hack to force the default minY scale to 0
tmpData := []float64{20}
cpu.Data = tmpData
_ = cpu.Buffer()
cpu.Data = cpu.hist.Data
return cpu
}
func (w *ExpandedCpu) Update(val int) {
func (w *Cpu) Update(val int) {
w.hist.Append(float64(val))
}