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

ZoomRectangleManipulator updates curves, but not axes #467

Open
MRGaraffa opened this issue Apr 28, 2015 · 1 comment

Comments

@MRGaraffa
Copy link

commented Apr 28, 2015

Imported from http://discussion.oxyplot.org/topic/706260-zoomrectanglemanipulator-updates-all-curves-but-not-all-axes.

I have multiple y-axes and a single x-axis. When I use the ZoomRectangleManipulator methods, it correctly updates all of the LineSeries in the PlotModel. However, it does not update all of the axes. This is similar to what is described in GitHub issue #59, but I find it odd that it updates the Series contained in the axis without updating the axis itself.

// All axes are set to axis.IsZoomEnabled = true.

private ZoomRectangleManipulator _ZoomRectangleManipulator
void OnModelMouseDown(object sender, OxyMouseDownEventArgs e)
{
  _ZoomRectangleManipulator = new ZoomRectangleManipulator(PlotModel.PlotView);
  _ZoomRectangleManipulator.Started(e);
}
void OnModelMouseMove(object sender, OxyMouseEventArgs e)
{
  if (_ZoomRectangleManipulator != null)
  {
    _ZoomRectangleManipulator.Delta(e);
  }
}
void OnModelMouseUp(object sender, OxyMouseEventArgs e)
{
  if (_ZoomRectangleManipulator != null)
  {
    _ZoomRectangleManipulator.Completed(e);
    _ZoomRectangleManipulator = null;
  }
}

Any feedback on this or suggestions for alternate implementation of a drag & release zoom window would be appreciated.

Thank you.

Added - I am running the latest non-alpha version of OxyPlot for WPF (v2014.1.546).

@MRGaraffa

This comment has been minimized.

Copy link
Author

commented Jun 3, 2015

For those that are interested, my solution to this was to create my own ZoomRectangleManipulator utilizing the OxyPlot source code as a starting point, link provided below. The main difference between my implementation and OxyPlot's is in the Completed method, which I have provided below.

public override void Completed(OxyMouseEventArgs e)
{
     base.Completed(e);

     this.PlotView.HideZoomRectangle();

     if (this.zoomRectangle.Width > 10 && this.zoomRectangle.Height > 10)
     {
          // Added
          var xAxes = this.Axes.Where(axis => axis.IsHorizontal()).ToList();
          var yAxes = this.Axes.Where(axis => axis.IsVertical()).ToList();

          foreach(var xAxis in xAxes)     // Replaced 'if (this.XAxis != null)'
          {
               // Moved into foreach loop to handle each x-axis scale differently
               var p0 = xAxis.InverseTransform(this.zoomRectangle.Left, this.zoomRectangle.Top, yAxes.First());
               var p1 = xAxis.InverseTransform(this.zoomRectangle.Right, this.zoomRectangle.Bottom, yAxes.First());

               xAxis.Zoom(p0.X, p1.X);     // Replaced 'this.XAxis.Zoom(p0.X, p1.X);'

          }

          foreach(var yAxis in yAxes)     // Replaced 'if (this.YAxis != null)'
          {
               // Moved into foreach loop to handle each y-axis scale differently
               var p0 = xAxes.First().InverseTransform(this.zoomRectangle.Left, this.zoomRectangle.Top, yAxis);
               var p1 = xAxes.First().InverseTransform(this.zoomRectangle.Right, this.zoomRectangle.Bottom, yAxis);
               yAxis.Zoom(p0.Y, p1.Y);     // Replaced 'this.YAxis.Zoom(p0.Y, p1.Y);'
          }

          this.PlotView.InvalidatePlot();
     }
}

Please note that this only handles conditions where the ZoomRectangleManipulator is used. Scrolling in the PlotView will still only update the first x-axis and y-axis and scrolling on top of an axis will only update that axis.

(https://github.com/oxyplot/oxyplot/blob/4746a8872e76698b34b18c78f29200b569b61f22/Source/OxyPlot/PlotController/Manipulators/ZoomRectangleManipulator.cs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.