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

Ensure x values added in incrementing order in TlmGrapher #819

Closed
ryanatball opened this Issue Jun 28, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@ryanatball
Member

ryanatball commented Jun 28, 2018

Here is a possible implementation that sorts the x values if one with a lower value is attempted to be inserted.

if x_values.length ==0
x_values << x_value
y_values << y_value + @y_offset
else
if x_values.last <= x_value
x_values << x_value
y_values << y_value + @y_offset
else
loc = x_values.bsearch_index{|x| x > x_value}
x_values.insert(loc,x_value)
y_values.insert(loc,y_value +@y_offset)
end
end
@plot.redraw_needed = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment