Skip to content

Axis: LockLimits()#1210

Merged
swharden merged 12 commits intomasterfrom
patch-demo-1179
Aug 21, 2021
Merged

Axis: LockLimits()#1210
swharden merged 12 commits intomasterfrom
patch-demo-1179

Conversation

@swharden
Copy link
Member

@swharden swharden commented Aug 18, 2021

This PR adds methods to lock axes to prevent them from being panned/zoomed. Solves #1179

multi

@swharden swharden linked an issue Aug 18, 2021 that may be closed by this pull request
@bclehmann
Copy link
Member

The naming here sounds a little bit too similar to AxisScaleLock, at least to me.

Maybe DisableInteractivity? Let me know what you're thinking.

@swharden
Copy link
Member Author

swharden commented Aug 18, 2021

The naming here sounds a little bit too similar to AxisScaleLock

Good point! I haven't done a deep dive into this topic yet, but according to #1197 some of the existing language results in unexpected behavior and may benefit from improvement.

I'm not totally sold on DisableInteractivity() because it's not clear if interactivity only applies to mouse events. I'm thinking a locked axis should remain unchanged if the axis limits are set manually or zoom/pan is called programmatically.

I agree with you Lock() is too ambiguous. Maybe LockLimits()?

EDIT: perhaps LockScale() should be added at the same time

Add a method to set lock state of axis limits to prevent edits/pan/zoom. #1179
@swharden swharden marked this pull request as ready for review August 19, 2021 02:41
@swharden
Copy link
Member Author

@bclehmann what do you think of the new API and demos?

Are you up for making the Avalonia demo or do you want me to do that? I'm cool either way

@bclehmann
Copy link
Member

bclehmann commented Aug 19, 2021

I don't mind doing it for Avalonia but I can't do it tonight. If you've already written a WPF version it's normally trivial to turn that into Avalonia, so it's not much work either way.

@bclehmann
Copy link
Member

bclehmann commented Aug 19, 2021

I like the API, it looks like you avoided splitting it up into different functions for disabling zoom and pan. I wonder if disabling pan but not zoom is a common usecase, if someone had a plot that was only drawn from x1 to x2 panning outside of that range is not useful.

It seems like that usecase would be better served by something like RestrictTo(start, end) orRestrictTo(x1, y1, x2, y2) anyways.

As for the demo, it seems fine, we mostly avoid MVVM elsewhere, I don't know if that was intentional or not? It is more WPF-ey, and I don't think it should be confusing to new people.

@swharden
Copy link
Member Author

swharden commented Aug 19, 2021

Thanks for your feedback @bclehmann!

it looks like you avoided splitting it up into different functions for disabling zoom and pan

I left the door open to possibly implement more similar functions later:

  • LockLimits() (this PR) - locks min/max. Resizing the figure stretches the contents.

  • LockSpan() - allows min/max to change together but the delta remains fixed. Resizing the figure stretches the contents.

  • LockScale() - keeps the units/pixel fixed. Resizing the figure does not change the scale of the contents.

mostly avoid MVVM [in demos] ... intentional or not?

It usually is the result of making the demo first for WinForms then copy/pasting to realize the same effect in WPF as a code-behind. Admittedly demos that use designs idiomatic to each platform would be better, but are a little more work to create.

I don't mind doing it for Avalonia but I can't do it tonight. If you've already written a WPF version it's normally trivial to turn that into Avalonia, so it's not much work either way.

No rush! If you're up for making the Avalonia demo that would be great. I can leave this PR open so you can create a PR into this branch, or I can merge this one into master and you can make a new branch/PR when you want - let me know what sounds good to you.

You're welcome to copy the WPF design (code-behind) or do something more idiomatic for Avalonia if you want to get fancy!

@bclehmann
Copy link
Member

I made a PR. It's fairly similar to the WPF version. #1215

@swharden swharden changed the title Axis: Lock() Axis: LockLimits() Aug 21, 2021
@swharden swharden merged commit 3ec15f5 into master Aug 21, 2021
@swharden swharden deleted the patch-demo-1179 branch August 21, 2021 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Demo: Pan and zoom one axis at a time

2 participants