mirror of
https://github.com/bcicen/ctop.git
synced 2026-01-21 13:46:42 +08:00
rename expanded -> single view
This commit is contained in:
32
cwidgets/single/cpu.go
Normal file
32
cwidgets/single/cpu.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package single
|
||||
|
||||
import (
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
type Cpu struct {
|
||||
*ui.LineChart
|
||||
hist FloatHist
|
||||
}
|
||||
|
||||
func NewCpu() *Cpu {
|
||||
cpu := &Cpu{ui.NewLineChart(), NewFloatHist(55)}
|
||||
cpu.Mode = "dot"
|
||||
cpu.BorderLabel = "CPU"
|
||||
cpu.Height = 12
|
||||
cpu.Width = colWidth[0]
|
||||
cpu.X = 0
|
||||
cpu.DataLabels = cpu.hist.Labels
|
||||
|
||||
// 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 *Cpu) Update(val int) {
|
||||
w.hist.Append(float64(val))
|
||||
}
|
||||
Reference in New Issue
Block a user