Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors on line plots #267

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

GideonWolfe
Copy link

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.

I ran into an error that if the `line` has only one data point, looking at `line[1]` will cause an index out of bounds error.

I suspect you wanted to look at the previous value, which would be `line[i-1]` instead of `line[1]` correct? I added a simple check not to try and calculate the value if we are on the first item. 

Please feel free to reject this PR but it fixed a crash in my program and did not alter the output in any noticeable way so I'm gonna use it regardless.
@GideonWolfe
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant