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:
22
widgets/hist.go
Normal file
22
widgets/hist.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package widgets
|
||||
|
||||
type HistData struct {
|
||||
data []int
|
||||
labels []string
|
||||
maxSize int
|
||||
}
|
||||
|
||||
func NewHistData(max int) HistData {
|
||||
return HistData{
|
||||
data: make([]int, max),
|
||||
labels: make([]string, max),
|
||||
maxSize: max,
|
||||
}
|
||||
}
|
||||
|
||||
func (h HistData) Append(val int) {
|
||||
if len(h.data) >= h.maxSize {
|
||||
h.data = append(h.data[:0], h.data[1:]...)
|
||||
}
|
||||
h.data = append(h.data, val)
|
||||
}
|
||||
Reference in New Issue
Block a user