From c8ba8e9491492425cb6c82670f31edf34d6be796 Mon Sep 17 00:00:00 2001 From: sqshq Date: Sat, 13 Apr 2019 19:23:44 -0400 Subject: [PATCH] fix out of range error for linux platform --- component/sparkline/sparkline.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/component/sparkline/sparkline.go b/component/sparkline/sparkline.go index a9c7e03..2e4aa84 100644 --- a/component/sparkline/sparkline.go +++ b/component/sparkline/sparkline.go @@ -90,7 +90,11 @@ func (s *SparkLine) Draw(buffer *ui.Buffer) { height := s.Dy() - 2 minValue := util.FormatValue(s.minValue, s.scale) maxValue := util.FormatValue(s.maxValue, s.scale) - curValue := util.FormatValue(s.values[len(s.values)-1], s.scale) + curValue := util.FormatValue(0, s.scale) + + if len(s.values) > 0 { + curValue = util.FormatValue(s.values[len(s.values)-1], s.scale) + } indent := 2 + util.Max([]int{ len(minValue), len(maxValue), len(curValue),