mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Improve bargraph view so bar colors are configurable
Inspired by #624 Update the view object so that widget developers can configure bar color
This commit is contained in:
@@ -24,6 +24,7 @@ type Bar struct {
|
||||
Label string
|
||||
Percent int
|
||||
ValueLabel string
|
||||
LabelColor string
|
||||
}
|
||||
|
||||
// NewBarGraph creates and returns an instance of BarGraph
|
||||
@@ -78,9 +79,10 @@ func BuildStars(data []Bar, maxStars int, starChar string) string {
|
||||
//write the line
|
||||
buffer.WriteString(
|
||||
fmt.Sprintf(
|
||||
"%s%s[[red]%s[white]%s] %s\n",
|
||||
"%s%s[[%s]%s[white]%s] %s\n",
|
||||
bar.Label,
|
||||
strings.Repeat(" ", longestLabel-len(bar.Label)),
|
||||
bar.LabelColor,
|
||||
strings.Repeat(starChar, starCount),
|
||||
strings.Repeat(" ", maxStars-starCount),
|
||||
label,
|
||||
|
||||
Reference in New Issue
Block a user