mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
init expanded view, add cpu histogram
This commit is contained in:
30
widgets/expanded_cpu.go
Normal file
30
widgets/expanded_cpu.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package widgets
|
||||
|
||||
import (
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
type ExpandedCpu struct {
|
||||
*ui.BarChart
|
||||
hist HistData
|
||||
}
|
||||
|
||||
func NewExpandedCpu() *ExpandedCpu {
|
||||
cpu := &ExpandedCpu{ui.NewBarChart(), NewHistData(12)}
|
||||
cpu.BorderLabel = "CPU Util"
|
||||
cpu.Height = 10
|
||||
cpu.Width = 50
|
||||
cpu.BarColor = ui.ColorGreen
|
||||
cpu.BarWidth = 3
|
||||
cpu.BarGap = 1
|
||||
cpu.X = 0
|
||||
cpu.Y = 4
|
||||
cpu.Data = cpu.hist.data
|
||||
cpu.DataLabels = cpu.hist.labels
|
||||
return cpu
|
||||
}
|
||||
|
||||
func (w *ExpandedCpu) Update(val int) {
|
||||
w.hist.Append(val)
|
||||
w.Data = w.hist.data
|
||||
}
|
||||
Reference in New Issue
Block a user