init expanded view, add cpu histogram

This commit is contained in:
Bradley Cicenas
2017-01-06 19:46:30 +00:00
parent bebdfd844f
commit 99aac17030
6 changed files with 162 additions and 2 deletions

22
widgets/hist.go Normal file
View 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)
}