gizak / termui

Golang terminal dashboard
MIT License
13.06k stars 783 forks source link

Fix errors on line plots #267

Open GideonWolfe opened 4 years ago

GideonWolfe commented 4 years ago

When a plot only has one data point, the code will make it go out of bounds (at index one). Test this by going to the example and setting

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

And it will crash.

Now it checks the ith element instead of one, and starts reading the data from 0 instead of 1.

GideonWolfe commented 4 years ago

Honestly I may need to look at this again... Every time I think I fixed it, it crashes again. Every single time it's just bad indexing in the plot function, I need to look closer.