show guage titles inside labels
This commit is contained in:
parent
a90bec834a
commit
f7eb0d3727
|
@ -28,17 +28,19 @@ type Gauge struct {
|
|||
scale int
|
||||
percentOnly bool
|
||||
palette console.Palette
|
||||
title string
|
||||
}
|
||||
|
||||
func NewGauge(c config.GaugeConfig, palette console.Palette) *Gauge {
|
||||
|
||||
g := Gauge{
|
||||
Block: component.NewBlock(c.Title, *c.Border, palette),
|
||||
Block: component.NewBlock("", *c.Border, palette),
|
||||
Consumer: data.NewConsumer(),
|
||||
color: *c.Color,
|
||||
scale: *c.Scale,
|
||||
percentOnly: *c.PercentOnly,
|
||||
palette: palette,
|
||||
title: c.Title,
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
@ -86,9 +88,9 @@ func (g *Gauge) Draw(buffer *ui.Buffer) {
|
|||
|
||||
var label string
|
||||
if g.percentOnly {
|
||||
label = fmt.Sprintf(" %v%% ", util.FormatValue(percent, g.scale))
|
||||
label = fmt.Sprintf("%s: %v%% ", g.title, util.FormatValue(percent, g.scale))
|
||||
} else {
|
||||
label = fmt.Sprintf(" %v%% (%v) ", util.FormatValue(percent, g.scale), util.FormatValue(g.curValue, g.scale))
|
||||
label = fmt.Sprintf("%s: %v%% (%v) ", g.title, util.FormatValue(percent, g.scale), util.FormatValue(g.curValue, g.scale))
|
||||
}
|
||||
|
||||
// draw bar
|
||||
|
|
Loading…
Reference in New Issue