-
Notifications
You must be signed in to change notification settings - Fork 23
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
plotter: Adjust min and max plot heights to be a factor of the min and max values #1612
plotter: Adjust min and max plot heights to be a factor of the min and max values #1612
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does make it so constant values get displayed instead of hidden, but there's something wrong with the update range - it's possible to get several consecutive values outside the widget (maybe related to #1561, if the canvasHeight is incorrect or something?), and when there are small changes they're confined to the middle of the widget instead of expanding to fill it:
Screen.Recording.2025-01-27.at.12.09.42.am.mov
Also, the issue you linked to seems to be about video connection logs - I'm not sure this PR fixes that?
de168c6
to
6f91e9e
Compare
@ES-Alexander everything is inside the canvas now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I knew it was squashing small fluctuations, but it took me a while to figure out why, and suggest an alternative/fix.
src/components/widgets/Plotter.vue
Outdated
maxValue = Math.max(...valuesHistory) | ||
const maxY = maxValue > 0 ? maxValue * 1.05 : maxValue * 0.95 | ||
minValue = Math.min(...valuesHistory) | ||
const minY = minValue > 0 ? minValue * 0.95 : minValue * 1.05 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxValue = Math.max(...valuesHistory) | |
const maxY = maxValue > 0 ? maxValue * 1.05 : maxValue * 0.95 | |
minValue = Math.min(...valuesHistory) | |
const minY = minValue > 0 ? minValue * 0.95 : minValue * 1.05 | |
maxValue = Math.max(...valuesHistory) | |
minValue = Math.min(...valuesHistory) | |
// Add a buffer to keep the plot neatly within bounds, and centered when there are no changes | |
const buffer = 0.05 * (maxValue != minValue ? maxValue - minValue : 1) | |
const maxY = maxValue + buffer | |
const minY = minValue - buffer |
I figured out why it was squashing small fluctuations! If the buffer is a fixed proportion of the values then if the values are changing by less than that proportion (e.g. due to a relatively large offset) then they end up getting compressed in the plot.
This alternative approach keeps a 5% buffer of the range for normal use-cases, and then treats a flatline of all the same values (i.e. range == 0
) as a special case that keeps the line centered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maaaaaan I'm testing with a sine wave here and you're absolutely right! Wtaf! Nice catch! |
6f91e9e
to
d45ad37
Compare
…d max values This prevents cases where the value is constant and no line appears in the plot, since the current and only value is equal to min and max. Co-authored-by: ES-Alexander <[email protected]>
d45ad37
to
0012c37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work well - nice! :D
Nice! Made sure to put you as co-author in this one! Thanks for the solution on the centering problem! |
This prevents cases where the value is constant and no line appears in the plot, since the current and only value is equal to min and max, like when monitoring an stable video frame rate.