-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ViewBox.setLimits()
doesn't trigger update if view range not within new limits
#2415
Comments
Hi, Can I work on this issue |
Please, have at it! Thanks! |
Hi, i created a Pr for this issue. Please take a look at it and tell me if any change is required? |
@bbc131 Thanks for the detailed report, the code to reproduce and the suggested fix. One thing that I'm still puzzled about is what should be the desired behavior in the case where minXRange is set to a larger value than the current view range, which end of the range should be adjusted? In #2540 (👋🏻 @aksy2512 ) the suggestion is to adjust the boundary (right limit if x-axis, top limit if y-axis), but I'm not convinced that's what's actually warranted... or should we adjust both ends of the boundary an equal amount (assuming we don't come across other limits)... or does it just not matter 😆 Do you have an opinion on this @bbc131 ? |
Hi @j9ac9k, in short, I think it doesn't matter that much, which end you are changing in these cases. This is already a corner case I think. The original code seems to change the lower and upper end of the axis symmetrically. (But only after you try to click and drag the view a bit.) Now, playing again with this things, I figured another issue which needs to be taken into account, when fixing this issue: |
Yeah, I had thought about this too; as this calculation occurs after checking the other limits, so we have to make sure they're taken into account. |
Description
If you call for example
ViewBox.setLimits(minXRange=limit)
withlimit
being larger as the current visible range, theViewBox
doesn't update its view range. We are then in a state where the limits are not satisfied.My expectation is, that the view range is updated immediatly with the call of
setLimits()
.Only after some other trigger, like updating the view range by
ViewRange.setRange()
, the view range suddenly changes and the limits are satisfied.This can be seen as a workaround: Just call
setRange
with the current range.This is behaviour seems to be the case for all eight limit parameters (
xMin
, ...,yMax
,minXRange
, ...,maxYRange
)Code to reproduce
Use the following mwe to check the current behaviour:
The width of the
LinearRegionItem
sets theminXRange
limit of the right plot.At the beginning it's all good, the region has a width of 10 and the right plot a range of 20.
Increasing the regions width to above 20 doesn't affect the right plot.
Now, try to pan the right plot just a little bit, this will trigger the limits and the plot will "jump" into a state where the limits are satisfied.
The expected behaviour can be seen, if the workaround is enabled (see the
if 0
in the code).Suggested solution
I think the solution would be to extend
ViewBox.updateViewRange()
at line 1576.Between
for axis in [0, 1]:
andif aspect is not False and ...
one should compareviewRange
againstlimits
,minRng
andmaxRng
and adjustviewRange
accordingly.That shouldn't be that much work, so if you agree with this suggestion, I might find time in the near future to come up with a PR.
The text was updated successfully, but these errors were encountered: