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

Feature: Flexible Y-Min and Y-Max settings. #5720

Closed
wants to merge 2 commits into from

Conversation

thoj
Copy link

@thoj thoj commented Aug 3, 2016

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):

  >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

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.

autoscale-example1
autoscale-example2
autoscale-example3
autoscale-example4
autoscale-display

@lpalm
Copy link

lpalm commented Aug 3, 2016

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:
Having a Level 1 threshold of 600 ("minimum") degrees and a level 2 threshold of 800 ("maximum") that are always visible on the graph, but still allowing points <600 or >800 to be visible if they're present. Having a minimum span of 200 would almost always work, but would hide the thresholds if we zoomed into a range where all points are in the range 1000-1100, for example.

@torkelo
Copy link
Member

torkelo commented Aug 7, 2016

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)

@lpalm
Copy link

lpalm commented Aug 7, 2016

Yeah, I figured we might as well allow strings in the Y-Min/Max fields to save space.

@thoj
Copy link
Author

thoj commented Aug 9, 2016

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
@thoj
Copy link
Author

thoj commented Aug 12, 2016

@lpalm @torkelo Did som refactoring and added unit tests. Now just using Y-Min and Y-Max.

@lpalm if you look at the first example image I think this is what you wanted?

p.s. This is the first time I've done unit tests in angular and it took me some time to gork, hope it's done right.

@thoj thoj changed the title Feature: Add Y-Span scaling to graph panel. Feature: Flexible Y-Min and Y-Max settings. Aug 12, 2016
function autoscaleSpanOverride(yaxis, data, options) {
var m, op, num, precision;
if (yaxis.min != null && data != null) {
m = yaxis.min.match(/([<=>~]*)\W*(\d+(\.\d+)?)/);
Copy link

@lpalm lpalm Aug 12, 2016

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)

Copy link
Author

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.

Copy link

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.

@lpalm
Copy link

lpalm commented Aug 12, 2016

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.

@torkelo
Copy link
Member

torkelo commented Sep 15, 2016

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 ❤️ !

@torkelo torkelo closed this Sep 15, 2016
@torkelo torkelo modified the milestones: 4.0.0-Beta1, 4.0.0 Sep 15, 2016
@torkelo torkelo reopened this Nov 6, 2016
@torkelo torkelo modified the milestones: 4.0.0-beta1, 4.0.0-beta2 Nov 9, 2016
@torkelo torkelo modified the milestones: 4.0.0-beta2, 4.0.0, 4.1.0 Nov 21, 2016
@torkelo torkelo removed this from the 4.0.0 milestone Nov 24, 2016
@torkelo torkelo modified the milestones: 4.2.0, 4.1.0 Dec 14, 2016
@torkelo torkelo added type/ux and removed pr/needs-manual-testing Before merge some help with manual testing & verification is requested labels Feb 14, 2017
@torkelo torkelo modified the milestones: 5.0, 4.2.0 Feb 14, 2017
@bergquist bergquist modified the milestones: 4.3.0, 5.0 Feb 14, 2017
@torkelo
Copy link
Member

torkelo commented Apr 25, 2017

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/external This PR is from external contributor type/ux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants