From 780c93dd444dcb13b9bfdfee3f8488181570f026 Mon Sep 17 00:00:00 2001 From: Spelchure Date: Wed, 16 Aug 2023 08:42:46 +0300 Subject: [PATCH] feat: limit sparkline bar height to the MaxHeight --- widgets/sparkline.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/widgets/sparkline.go b/widgets/sparkline.go index 840a8a7..ec963b5 100644 --- a/widgets/sparkline.go +++ b/widgets/sparkline.go @@ -17,7 +17,7 @@ type Sparkline struct { TitleStyle Style LineColor Color MaxVal float64 - MaxHeight int // TODO + MaxHeight int } // SparklineGroup is a renderable widget which groups together the given sparklines. @@ -66,6 +66,9 @@ func (self *SparklineGroup) Draw(buf *Buffer) { for j := 0; j < len(sl.Data) && j < self.Inner.Dx(); j++ { data := sl.Data[j] height := int((data / maxVal) * float64(barHeight)) + if height > sl.MaxHeight { + height = sl.MaxHeight + } sparkChar := BARS[len(BARS)-1] for k := 0; k < height; k++ { buf.SetCell(