Repository: pterm/pterm (go)

Issue:
Bar chart causes panic when all values are zero (Horizontal only)
The following code causes the panic below  instead of rendering an empty bar graph.

```
func main() {
	bars := pterm.Bars{
		pterm.Bar{
			Label: "Bar 1",
			Value: 0,
		},
		pterm.Bar{
			Label: "Bar 2",
			Value: 0,
		},
		pterm.Bar{
			Label: "Longer Label",
			Value: 0,
		},
	}

	_ = pterm.DefaultBarChart.WithHorizontal().WithBars(bars).Render()
}
```

```
panic: strings: negative Repeat count

goroutine 1 [running]:
strings.Repeat(0x5c152f, 0x3, 0x8000000000000000, 0x5d4bb0, 0x1)
        /usr/local/go/src/strings/strings.go:529 +0x5e5
github.com/pterm/pterm.BarChartPrinter.Srender(0xc0001ac080, 0x3, 0x3, 0x1, 0x27, 0x4c, 0x5c2438, 0x6, 0x5c152f, 0x3, ...)
        /home/ayo/go/pkg/mod/github.com/pterm/pterm@v0.12.27/barchart.go:129 +0x4fc
github.com/pterm/pterm.BarChartPrinter.Render(0xc0001ac080, 0x3, 0x3, 0x1, 0x27, 0x4c, 0x5c2438, 0x6, 0x5c152f, 0x3, ...)
        /home/ayo/go/pkg/mod/github.com/pterm/pterm@v0.12.27/barchart.go:194 +0x58
main.main()
        /home/ayo/dev/demo/random/main.go:201 +0x178
exit status 2
```

Pull request:
fix(bar chart): fix panic when rendering empty horizontal bar chart
Fixes #233

### Description
The second argument to `strings.Repeat()` cannot be negative, and this causes a panic when the bar chart is rendered horizontally with zero values. This PR ensures that the argument to `strings.Repeat()` can no longer be zero this preventing the panic.

### Scope
> What is affected by this pull request?

- [x] Bug Fix
- [ ] New Feature
- [ ] Documentation
- [ ] Other

### Related Issue
Fixes #233 


### To-Do Checklist
- [x] I tested my changes
- [x] I have commented every method that I created/changed
- [x] I updated the examples to fit with my changes
- [x] I have added tests for my newly created methods


Patch:
diff --git a/barchart.go b/barchart.go
index f5f6d356..481229ba 100644
--- a/barchart.go
+++ b/barchart.go
@@ -126,7 +126,11 @@ func (p BarChartPrinter) Srender() (string, error) {
 		panels := Panels{[]Panel{{}, {}}}
 		for _, bar := range p.Bars {
 			panels[0][0].Data += "\n" + bar.Label
-			panels[0][1].Data += "\n" + bar.Style.Sprint(strings.Repeat(p.HorizontalBarCharacter, internal.MapRangeToRange(0, float32(maxBarValue), 0, float32(p.Width), float32(bar.Value))))
+			repeatCount := internal.MapRangeToRange(0, float32(maxBarValue), 0, float32(p.Width), float32(bar.Value))
+			if repeatCount < 0 {
+				repeatCount = 0
+			}
+			panels[0][1].Data += "\n" + bar.Style.Sprint(strings.Repeat(p.HorizontalBarCharacter, repeatCount))
 			if p.ShowValue {
 				panels[0][1].Data += " " + strconv.Itoa(bar.Value)
 			}


Test patch:
diff --git a/barchart_test.go b/barchart_test.go
index 3172b2e9..40082769 100644
--- a/barchart_test.go
+++ b/barchart_test.go
@@ -121,6 +121,21 @@ func TestBarChartPrinter_RenderNegativeBarValues(t *testing.T) {
 	}).Render()
 }
 
+func TestBarChartPrinter_RenderZeroBarValuesHorizontal(t *testing.T) {
+	DefaultBarChart.WithShowValue().WithHorizontal().WithBars(Bars{
+		Bar{
+			Label: "Test",
+			Value: 0,
+			Style: NewStyle(FgRed, BgBlue, Bold),
+		},
+		Bar{
+			Label: "Test",
+			Value: 0,
+			Style: NewStyle(FgRed, BgBlue, Bold),
+		},
+	}).Render()
+}
+
 func TestBarChartPrinter_RenderZeroBarValues(t *testing.T) {
 	DefaultBarChart.WithShowValue().WithBars(Bars{
 		Bar{