add diffhist struct, update expandednet widget

This commit is contained in:
Bradley Cicenas
2017-01-08 15:54:25 +00:00
parent 98a8cecfa1
commit 3b0373b34f
2 changed files with 45 additions and 10 deletions

View File

@@ -8,30 +8,30 @@ import (
type ExpandedNet struct {
*ui.Sparklines
rxHist IntHistData
txHist IntHistData
rxHist DiffHistData
txHist DiffHistData
}
func NewExpandedNet() *ExpandedNet {
net := &ExpandedNet{ui.NewSparklines(), NewIntHistData(60), NewIntHistData(60)}
net := &ExpandedNet{ui.NewSparklines(), NewDiffHistData(30), NewDiffHistData(30)}
rx := ui.NewSparkline()
rx.Title = "RX"
rx.Height = 3
rx.Height = 2
rx.Data = net.rxHist.data
rx.TitleColor = ui.ColorDefault
rx.LineColor = ui.ColorGreen
tx := ui.NewSparkline()
tx.Title = "TX"
tx.Height = 3
tx.Height = 2
tx.Data = net.txHist.data
tx.TitleColor = ui.ColorDefault
tx.LineColor = ui.ColorGreen
tx.LineColor = ui.ColorYellow
net.Lines = []ui.Sparkline{rx, tx}
net.Height = 12
net.Width = 50
net.Height = 8
net.Width = 35
net.X = 0
net.Y = 15
return net
@@ -39,7 +39,8 @@ func NewExpandedNet() *ExpandedNet {
func (w *ExpandedNet) Update(rx int64, tx int64) {
w.rxHist.Append(int(rx))
w.Lines[0].Title = fmt.Sprintf("RX [%s/s]", byteFormat(int64(w.rxHist.Last())))
w.txHist.Append(int(tx))
w.Lines[0].Title = fmt.Sprintf("RX (%s)", byteFormat(rx))
w.Lines[1].Title = fmt.Sprintf("TX (%s)", byteFormat(tx))
w.Lines[1].Title = fmt.Sprintf("TX [%s/s]", byteFormat(int64(w.txHist.Last())))
}