mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add custom label formatting, scale for expandedMem
This commit is contained in:
parent
72066aba6e
commit
e73732ae98
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user