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
Feature: Flexible Y-Min and Y-Max settings. #5720
Conversation
This is great. The "<X" and ">X" functions could potentially be applied directly to the Y-Min and Y-Max, respectively. This would allow for fine control over the min and max ranges separately. It could be useful when certain fixed Y values are important (e.g. 0 or some threshold), but still allowing points that cross those Y values to be displayed. Example: |
This is interesting, might need some refactoring and unit tests, and worth exploring @lpalm idea of having option for Y-Min and Y-Max separately. Another idea is to use the Y-Min and Y-max options for this (to allow strings in this input field as well) |
Yeah, I figured we might as well allow strings in the Y-Min/Max fields to save space. |
I'll se what I can do :) Thanks for your ideas :) |
Y-Min and Y-Max is now string. New usage for both Y-Min and Y-Max (Where X is a real number): >X Y-Max/Y-Max is auto if data is above X else X <X Y-Max/Y-Min is auto if data is below X else X =X Y-Max/Y-Min is scaled to current value +/- X ~X Y-Max/Y-Min is caled to average value +/- X Example: Y-Min: <100 Y-Max: >200 If all points are within 100 and 200: Y-Min is 100 and Y-Max is 200 If some points are above 200: Y-Min is 100 and Y-Max is auto If some points are below 100: Y-Min is auto and Y-Max is 200 if some points are below 100 and above 200: Y-Min and Y-Max is auto Tests for new settings added
5b777bc
to
839b320
Compare
function autoscaleSpanOverride(yaxis, data, options) { | ||
var m, op, num, precision; | ||
if (yaxis.min != null && data != null) { | ||
m = yaxis.min.match(/([<=>~]*)\W*(\d+(\.\d+)?)/); |
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.
Should we do:
/([<=>~]?)\W*(\d+(\.\d+)?)/
Or even (assuming we want to support >=, <=, which don't matter much for floating point, but may be more intuitive):
/(<|<=|>|>=|~|=)?\W*(\d+(\.\d+)?)/
Instead of:
/([<=>~]*)\W*(\d+(\.\d+)?)/
(Same for the Y-Max)
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.
@lpalm I have a bit of a difficult time figuring out where <= and >= would be useful? Could you explain one case for me?
I agree that the regex could be a lot better. I think we need \W* because \W would enforce a white space.
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.
It wouldn't be useful. Rather, it may be nice to treat >= as > and <= as < instead of just not working. Don't feel strongly about it.
Apologies about the \W*, looks like github treated the asterisk as an indication to italicize my text! I've edited it to be in block quotes now.
I'm not super familiar with the Grafana code base and style but LGTM! Thanks for putting this in, @thoj. And yes, that screenshot is exactly what I had in mind. |
sorry, this PR was refactored a bit in this PR (#6051) , I hit squash merge commit without thinking that this PR would not then be automatically detected as merged by github. Anyway, the feature is in master now, thank you for making Grafana better ❤️ ! |
closing this as this PR has drifted a bit too far from master. Need to figure out a UI for the expressions so they are discoverable (and not secret things you need to know about) |
Possible Issues: #979 #4156 #3935 #2759
Y-Min and Y-Max is now string.
New usage for both Y-Min and Y-Max (Where X is a real number):
Example: Y-Min: <100 Y-Max: >200
If all points are within 100 and 200: Y-Min is 100 and Y-Max is 200
If some points are above 200: Y-Min is 100 and Y-Max is auto
If some points are below 100: Y-Min is auto and Y-Max is 200
if some points are below 100 and above 200: Y-Min and Y-Max is auto
Unit tests for new settings added
More Examples:
In the following images you see temperature gauges that when using default auto-scaling is either noisy or show very little information because of a few values that are close to zero.
I can't set Y-Min and Y-Max because the temperatures will wander to much over a few days and would fall outside of Y-Min and Y-Max pretty quickly.