Open Razakhel opened 1 year ago
calling SetupAxisLimitsConstraints(...) was roughly equivalent to calling SetupAxisLimits(..., ImPlotCond_Always)
This is incorrect (if I'm not mistaken myself).
SetupAxisLimits(..., ImPlotCond_Always)
forces the left/right (bottom/top) values of the axis to be the given values. When called, you cannot zoom or scroll on the affected axis anymore.SetupAxisLimits(..., ImPlotCond_Once)
only does it on the first frame, i.e. it sets the initial range of the axis. After that, you're free to zoom/scroll as much as you want.SetupAxisLimitsConstraints
only sets the maximum range of the plot, not the minimum range. So if your constrain is [a..b], then the axis limits can be anything within that [a..b] range. You can't go below a
, you can't go above b
but you can go anywhere in-between. So it's pointless to set the "constrains" if you have "limits(...always)". And "limits(...once)" should be within the range specified by "constrains".
And in your case, it's actually not expected to go from [0, 1.0] to [0, 4.0] just by setting the constrains, since [0..1] is within the [0..4] range. I suspect that you still have call to SetupAxisLimits(always)
somewhere.
Personally, I cannot reproduce the issue. It might have been a bug in implot that has been fixed since (you haven't specified what version you're using, myself I used v0.16) or something else is going on in your code (posting a more complete example would be useful).
I'm having trouble figuring out the behavior of
SetupAxisLimitsConstraints()
. As I understood, which may well be entirely wrong, callingSetupAxisLimitsConstraints(...)
was roughly equivalent to callingSetupAxisLimits(..., ImPlotCond_Always)
. However, this does not seem to be the case, at least for the very first frame: usingSetupAxisLimits()
with the_Always
condition is instantly taken into account, while the*Constraints()
version needs another frame to work as expected.With
ImPlot::SetupAxisLimits(ImAxis_X1, 0.0, maxValCount, ImPlotCond_Always);
, on the very first frame:With
ImPlot::SetupAxisLimitsConstraints(ImAxis_X1, 0.0, maxValCount);
, still on the very first frame:Rendering another frame, we get the expected result:
While it's not critical, it was not something I expected. Is it a bug, or am I missing something?