From 4a4d9b58da7c4ebcbe17a37f498fa1e8c1a5ce02 Mon Sep 17 00:00:00 2001 From: ray Date: Mon, 31 May 2021 19:45:18 +0100 Subject: [PATCH] move guage label to left --- component/gauge/gauge.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/component/gauge/gauge.go b/component/gauge/gauge.go index a3960e8..767972b 100644 --- a/component/gauge/gauge.go +++ b/component/gauge/gauge.go @@ -88,9 +88,9 @@ func (g *Gauge) Draw(buffer *ui.Buffer) { var label string if g.percentOnly { - label = fmt.Sprintf("%s: %v%% ", g.title, util.FormatValue(percent, g.scale)) + label = fmt.Sprintf(" %s: %v%% ", g.title, util.FormatValue(percent, g.scale)) } else { - label = fmt.Sprintf("%s: %v%% (%v) ", g.title, 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 @@ -106,7 +106,7 @@ func (g *Gauge) Draw(buffer *ui.Buffer) { ) // draw label - labelXCoordinate := g.Inner.Min.X + (g.Inner.Dx() / 2) - int(float64(len(label))/2) + labelXCoordinate := g.Inner.Min.X labelYCoordinate := g.Inner.Min.Y + ((g.Inner.Dy() - 1) / 2) if labelYCoordinate < g.Inner.Max.Y { for i, char := range label {