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

GraphNG: Adds support for soft min and soft max for better auto-scaling axis limits #30326

Merged
merged 1 commit into from Jan 16, 2021

Conversation

leeoniya
Copy link
Contributor

@leeoniya leeoniya commented Jan 16, 2021

softMin & softMax can prevent blips from turning into mountains when the data is mostly flat, and hardMin/hardMax can prevent intermittent spikes from flattening useful detail by clipping the spikes past a defined point. this PR includes the work started by @ryantxu in #30238 and should close at least #979 and #5984. (maybe more).

also, soft limits can be used to "always show 0" or "only autoscale positive values". (in most cases)

Closes #979
Closes #5984.

this includes a bump for uPlot to 1.6.1 that fixes a bug in the default y auto-ranging behavior. i checked all the test panels that have stable y ranges (the y axis ticks panel) and there is only a small difference that improves last panel by bringing the 0 into range.

it should be noted that there is no support for log scales here since the ranging functions are completely different. i'm inclined to wait until someone complains before putting any work into it because very often enabling log scales serves the same purpose as setting soft limits on linear scales (to squash spikes).

below...

top panels are the default ranging behavior. the wide version is the full dataset, and each smaller panel is different interesting subset of the same data. the bottom copies of the same panels all have the following limits: Hard: 1.5 - 6.0, Soft: 2.5 - 5.0:

image

@leeoniya leeoniya requested review from torkelo, ryantxu, a team and jackw and removed request for a team January 16, 2021 06:05
@leeoniya leeoniya removed the request for review from jackw January 16, 2021 06:08
Copy link
Member

@torkelo torkelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Lots will be happy with this new capability!

@torkelo torkelo changed the title GraphNG: implement softMin/softMax for auto-scaling stabilization. close #979. close #5984. GraphNG: Adds support for soft min and soft max for better auto-scaling axis limits Jan 16, 2021
@leeoniya leeoniya merged commit 803fe70 into master Jan 16, 2021
@leeoniya leeoniya deleted the graph-ng-soft-limits branch January 16, 2021 14:24
@leeoniya
Copy link
Contributor Author

@torkelo

i think this also closes #4156

and maybe closes #5541

@torkelo
Copy link
Member

torkelo commented Jan 16, 2021

Yea, both looks like we can close with this change😃😃

@adamkdean
Copy link

adamkdean commented Jan 16, 2021

@leeoniya @torkelo if this closes #4156, does that mean that we can now have say four graphs side by side which all have their min-max synchronised?

For example, imagine four temperature sensor graphs with an auto y-axis scale of 30 ºC to 40º C and values around 35 ºC. If one of the sensor values were to spike to 50 ºC and the y-axis range of it's respective graph to increase from 30 ºC to 50 ºC to cover the spike, would the other three graphs also be able to have their y-axes synchronised? If not, then I don't believe this closes #4156.

@leeoniya
Copy link
Contributor Author

leeoniya commented Jan 16, 2021

yeah, it's not a 100% fix but significantly improves the situation. i'm still pretty new to Grafana, so not sure how realistic a cross-panel y axis sync is.

coincidentally, there's a recent similar request in uPlot for this that i'm gonna work through: leeoniya/uPlot#433. disabling uPlot's built-in "zoom on selection end" looks like prerequisite, which Grafana already does. but this is more complicated because it needs to cross-sync specific units across specific panels, not just on zoom but also on data updates. and there needs to be some UI for defining which panels & units to sync.

part of this may hinge on synchronizing the data pipeline across all panels in a dashboard, which is being prototyped on-and-off.

@torkelo can re-open if he thinks this is a realistic thing for the future.

@adamkdean
Copy link

Thanks both. The synchronisation of graphs would be super useful, especially when you're monitoring grouped yet separate graphs and want to be able keep things visually consistent, so I think #4156 still remains an "in demand" request. That being said, this ticket is a great feature, just not the same one 😄 .

@simPod
Copy link
Contributor

simPod commented Jan 18, 2021

According to the diff, this is not available to the graph panel, right?

@leeoniya
Copy link
Contributor Author

the graph panel is on its way out and won't be getting much love going forward.

its replacement is called "Time series", which is where this will be available.

@mmatrosov
Copy link

Where can I find the exact formula on how these values are used? It is not the docs, they are ambiguous.

My understanding is the following:

y_max = clamp(max_over_data, soft_max, hard_max),
y_min = clamp(min_over_data, hard_min, soft_min),
where clamp(x, a, b) = max(a, min(x, b))

But I'm not sure what happens if soft_max is greater than hard_max or soft_min is less than hard_min.

@bwims
Copy link

bwims commented Oct 18, 2022

Hi,

I'm running 8.4.4 Is that a high enough version? I cannot see anything related to hard and soft in the axes definitions.

My interest is in always displaying the threshold line. (FYI I am displaying barometric pressure and want the "normal" threshold to be visible.

I got sent over here because the original question asking for threshold visibility was closed pointing here.

Any help / advice gratefully received!

@leeoniya
Copy link
Contributor Author

I cannot see anything related to hard and soft in the axes definitions.

the "hard" limits are just min and max. and the soft limits are softMin and softMax.

image

@bwims
Copy link

bwims commented Oct 18, 2022

Hi, thanks for replying. I had my pressure graph on "Graph", not "Time series" which looks like it got upgraded to remain the default. So that solves one problem. The other is that I don't quite understand what "soft" means. Do I put the min and max at the extremes and let the system work it out? Does it automatically take note of the threshold?

Thanks!

Edit: as far as I can see, it behaves just like the previous min, max.

@leeoniya
Copy link
Contributor Author

Edit: as far as I can see, it behaves just like the previous min, max.

if you only set min and max, then yes. they are treated as hard limits. we did not want to break that.

for your case, you can omit min and max and only set softMin and/or softMax to values that encompass minimum range you want to see. if your data exceeds those, then it will autoscale up to the hard limits (or to infinity if hard limits are not set).

@bwims
Copy link

bwims commented Oct 18, 2022

I see!

Many many thanks! That's great!

B.

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

Successfully merging this pull request may close these issues.

Always keep thresholds visible in graphs ('minimum' maximum) Graph: Limits on Y auto scale (min max)
8 participants