mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
31 lines
518 B
Go
31 lines
518 B
Go
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
|
|
}
|