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