gizak / termui

Golang terminal dashboard
MIT License
13.23k stars 786 forks source link

Correct looking at wrong index for PreviousHeight in plot.go #265

Closed GideonWolfe closed 4 years ago

GideonWolfe commented 4 years ago

Feel to reject this PR if I got the wrong Idea here, but this fixed one of my bugs. To find PreviousHeight, plot.go looks at line[1] as a value, but this causes a crash if the line has only one value.

I suspect to find the previous height, we want to look at line[i-1]. I added this and a simple check to make sure we aren't on the first data point, in which case there is no "PreviousHeight".

GideonWolfe commented 4 years ago

If you are looking to reproduce the issue, check out the plot.go in examples, and change

p0.Data = [][]float64{[]float64{5}}

And watch it crash

GideonWolfe commented 4 years ago

Gotta fix a few mistakes