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