diff --git a/widgets/compact.go b/widgets/compact.go index aebdbb2..b4acdd1 100644 --- a/widgets/compact.go +++ b/widgets/compact.go @@ -30,8 +30,8 @@ func NewCompact(id string, name string) *Compact { Cid: compactPar(id), Net: compactPar("-"), Name: compactPar(name), - Cpu: mkGauge(), - Memory: mkGauge(), + Cpu: slimGauge(), + Memory: slimGauge(), } } @@ -82,3 +82,14 @@ func (w *Compact) SetMem(val int64, limit int64, percent int) { } w.Memory.Percent = percent } + +func slimGauge() *ui.Gauge { + g := ui.NewGauge() + g.Height = 1 + g.Border = false + g.Percent = 0 + g.PaddingBottom = 0 + g.BarColor = ui.ColorGreen + g.Label = "-" + return g +} diff --git a/widgets/expanded.go b/widgets/expanded.go index e8ccdab..6579c2b 100644 --- a/widgets/expanded.go +++ b/widgets/expanded.go @@ -27,7 +27,7 @@ func NewInfo(id, name string) *ui.Table { []string{"id", id}, } p.Height = 4 - p.Width = 40 + p.Width = 50 p.FgColor = ui.ColorWhite p.Seperator = false return p diff --git a/widgets/expanded_mem.go b/widgets/expanded_mem.go index f832ca3..cbd5dd6 100644 --- a/widgets/expanded_mem.go +++ b/widgets/expanded_mem.go @@ -5,15 +5,13 @@ import ( ) type ExpandedMem struct { - *ui.MBarChart - valHist IntHistData - limitHist IntHistData + *ui.BarChart + hist IntHistData } func NewExpandedMem() *ExpandedMem { mem := &ExpandedMem{ - ui.NewMBarChart(), - NewIntHistData(8), + ui.NewBarChart(), NewIntHistData(8), } mem.BorderLabel = "MEM" @@ -21,21 +19,22 @@ func NewExpandedMem() *ExpandedMem { mem.Width = 50 mem.BarWidth = 5 mem.BarGap = 1 - mem.X = 51 - mem.Y = 4 + mem.X = 0 + mem.Y = 14 mem.TextColor = ui.ColorDefault - mem.Data[0] = mem.valHist.data - mem.Data[0] = mem.valHist.data - mem.Data[1] = mem.limitHist.data - mem.BarColor[0] = ui.ColorGreen - mem.BarColor[1] = ui.ColorBlack - mem.DataLabels = mem.valHist.labels - //mem.ShowScale = true + mem.Data = mem.hist.data + mem.BarColor = ui.ColorGreen + mem.DataLabels = mem.hist.labels + mem.NumFmt = byteFormatInt return mem } func (w *ExpandedMem) Update(val int, limit int) { - w.valHist.Append(val) - w.limitHist.Append(limit - val) - //w.Data[0] = w.hist.data + // implement our own scaling for mem graph + if val*4 < limit { + w.SetMax(val * 4) + } else { + w.SetMax(limit) + } + w.hist.Append(val) } diff --git a/widgets/expanded_net.go b/widgets/expanded_net.go index 21ec8c6..3019b13 100644 --- a/widgets/expanded_net.go +++ b/widgets/expanded_net.go @@ -14,23 +14,23 @@ type ExpandedNet struct { } func NewExpandedNet() *ExpandedNet { - net := &ExpandedNet{ui.NewSparklines(), NewDiffHistData(30), NewDiffHistData(30)} + net := &ExpandedNet{ui.NewSparklines(), NewDiffHistData(50), NewDiffHistData(50)} net.BorderLabel = "NET" - net.Height = 8 - net.Width = 35 + net.Height = 6 + net.Width = 50 net.X = 0 - net.Y = 15 + net.Y = 24 rx := ui.NewSparkline() rx.Title = "RX" - rx.Height = 2 + rx.Height = 1 rx.Data = net.rxHist.data rx.TitleColor = ui.ColorDefault rx.LineColor = ui.ColorGreen tx := ui.NewSparkline() tx.Title = "TX" - tx.Height = 2 + tx.Height = 1 tx.Data = net.txHist.data tx.TitleColor = ui.ColorDefault tx.LineColor = ui.ColorYellow diff --git a/widgets/util.go b/widgets/util.go index 53b2147..d7c7af9 100644 --- a/widgets/util.go +++ b/widgets/util.go @@ -43,17 +43,6 @@ func compactPar(s string) *ui.Par { return p } -func mkGauge() *ui.Gauge { - g := ui.NewGauge() - g.Height = 1 - g.Border = false - g.Percent = 0 - g.PaddingBottom = 0 - g.BarColor = ui.ColorGreen - g.Label = "-" - return g -} - func colorScale(n int) ui.Attribute { if n > 70 { return ui.ColorRed