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

Pan and Zoom not working #62

Open
Nuada26 opened this issue Jun 27, 2017 · 6 comments
Open

Pan and Zoom not working #62

Nuada26 opened this issue Jun 27, 2017 · 6 comments

Comments

@Nuada26
Copy link

Nuada26 commented Jun 27, 2017

Hi all,

I have a problem with my plotview in Xamarin forms, i see it but when i try to pan or zomm on it, it's not work.

This is my code in C#:

        var model = new PlotModel { Title = "Hello, Forms!", PlotAreaBorderColor = OxyColors.Transparent };

        var BottomAxis = new TimeSpanAxis();
        BottomAxis.Position = AxisPosition.Bottom;
        model.PlotAreaBorderThickness = new OxyThickness(0, 0, 0, 0);
        BottomAxis.IntervalLength = TimeSpanAxis.ToDouble(new TimeSpan(1,0,0));

        var LeftAxis = new LinearAxis();
        LeftAxis.Position = AxisPosition.Left;
        LeftAxis.Minimum = 0d;
        LeftAxis.Maximum = 50d;
        var myController = new PlotController();
        plotview.Controller = myController;
        
        model.Axes.Add(LeftAxis);
        model.Axes.Add(BottomAxis);

        var Serie = new LineSeries();
        Serie.Points.Add(new DataPoint(TimeSpanAxis.ToDouble(DateTime.Now.TimeOfDay.Subtract(new TimeSpan(0, 0, 20))),10d ));
        Serie.Points.Add(new DataPoint(TimeSpanAxis.ToDouble(DateTime.Now.TimeOfDay.Subtract(new TimeSpan(0, 3, 20))),55d ));
        Serie.Points.Add(new DataPoint(TimeSpanAxis.ToDouble(DateTime.Now.TimeOfDay.Subtract(new TimeSpan(0, 4, 20))),15d ));

        model.Series.Add(Serie);
        plotview.Model = model;

And this is View on XAML:

<oxy:PlotView x:Name="plotview" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3"/>

Any idea for resolve that?

Thanks in advance

@scastria
Copy link
Contributor

I also had the same problem. I debugged the ExampleBrowser running on iOS and I tracked the problem down to 2 issues with OxyPlot.Core.

Number 1

The constructor for PlotController installs 2 TouchDown bindings, the first is for handling Pan/Zoom and the second is for handling a tracker. Well, in the constructor, you will see multiple items being bound to the same event, however, those allow multiple bindings per event as long as the modifier is different. A modifier would be like which keyboard key or which mouse button. However, touch is touch with no modifier. This means the second binding for TouchDown (for the tracker) OVERWRITES the first binding for TouchDown (panning/zooming). So the first fix is to comment out the second tracker binding.

Number 2

Even after fixing problem number 1 above, panning/zooming on touch devices still doesn't work. This is because the Tracker touch manipulator extends the touch manipulator but the touch manipulator does NOT default the panning/zooming support to true. So the fix is to add a line to the constructor of TouchManipulator to set SetHandledForPanOrZoom = true;

@rapmue
Copy link

rapmue commented May 8, 2018

@scastria I came across the same issues with Windows.Forms. But I also noticed, that Number 2 is fixed with oxyplot/oxyplot#1184

Currently, I'm working on a fix for Number 1. As soon as I got my pull request ready, I'll attach it here.

@Anax7
Copy link

Anax7 commented Oct 8, 2018

Hello! Is there an update on this issue? I'm using OxyPlot.Core and OxyPlot.Xamarin.Android NuGets which are re-installed on 5/10/2018. I can't zoom the graphs using code. Touch zoom works properly.

@objorke objorke changed the title Pan and Zoom not work Pan and Zoom not working Oct 20, 2019
@objorke objorke added this to the v2.0 milestone Nov 28, 2019
@Setomba
Copy link

Setomba commented Jan 15, 2020

Hello
Is there an update or an ETA on this topic? I am using Oxyplot for Xamarin.Forms and not being able to zoom or pan the charts is unfortunately a breaking issue for me.

@objorke
Copy link
Member

objorke commented Feb 26, 2020

I don´t know the status on this issue. We depend on contributions to get this fixed!
(I recommend to include oxyplot-xamarin as source code (e.g. by using git submodule), not as nuget package, to make sure you get the latest version)

@Enduteri
Copy link

Enduteri commented Nov 2, 2023

I work with WPF, touch and pan was not working out of the box, with a little research I found that SnapTrackTouch is causing this issue. Binding to my own controller and unbinding all TouchDown commands from it, fixed touch input. I just had to bind PanZoomByTouch again:

var plotcontroller = new PlotController();
plotcontroller.UnbindTouchDown();
plotcontroller.BindTouchDown(PlotCommands.PanZoomByTouch);

In fact, both SnapTrackTouch and PanZoomByTouch work fine separately but not together. Snap track in my opinion could be disabled by default, it's not useful on a touch screen, the point tooltip is only visible for a split second. Or am I wrong and it can be used for other things as well?

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

No branches or pull requests

7 participants