ctop/widgets/expanded_cpu.go

29 lines
504 B
Go
Raw Normal View History

2017-01-06 19:46:30 +00:00
package widgets
import (
ui "github.com/gizak/termui"
)
type ExpandedCpu struct {
2017-01-07 20:37:11 +00:00
*ui.LineChart
2017-01-12 15:06:35 +00:00
hist FloatHist
2017-01-06 19:46:30 +00:00
}
func NewExpandedCpu() *ExpandedCpu {
2017-01-12 15:06:35 +00:00
cpu := &ExpandedCpu{ui.NewLineChart(), NewFloatHist(60)}
2017-01-07 20:37:11 +00:00
cpu.BorderLabel = "CPU"
2017-01-06 19:46:30 +00:00
cpu.Height = 10
cpu.Width = 50
cpu.X = 0
cpu.Y = 4
cpu.Data = cpu.hist.data
cpu.DataLabels = cpu.hist.labels
2017-01-07 20:37:11 +00:00
cpu.AxesColor = ui.ColorDefault
cpu.LineColor = ui.ColorGreen
2017-01-06 19:46:30 +00:00
return cpu
}
func (w *ExpandedCpu) Update(val int) {
2017-01-07 20:37:11 +00:00
w.hist.Append(float64(val))
2017-01-06 19:46:30 +00:00
}