Limiting the zoom and restarting the axes

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

everytimer wrote at 2013-06-22 12:15:

Hello, I'm using OxyPlot for WPF and I can't find a way to reset the axes. I want to achieve the same effect as when you press the button "A" with the plot focused. I've seen in the source that ResetAxes is a public method but somehow I can't access to it.

My second question is how could I limit the zoomable area in code? I can't set it statically in XAML or in the initialization of the plot because my data will change and I want to limit the size depending on the data. Do I need to check before every PlotRefresh(true) my just added Series most extreme values and then use that values or is there something that already does that?

Thank you.

DJDAS wrote at 2013-06-24 10:26:

Hi,
for a project I had the same needs and I solved it by binding the AbsoluteMaximum and AbsoluteMinimum of the axes to a property which changes as per my needs (i.e. the date selected by the user) after this you can call ResetAxes in your code and the axes automatically zoom to your limits.
Hoping to be helpful!
Bye!

everytimer wrote at 2013-06-24 11:23:

Thank you, I can't find that ResetAxes method!! I can create one very easily with this one:
private void AxReset()
{
MyModel.Axes[0].Reset();
MyModel.Axes[1].Reset();
 }
But I wonder why I can't access that ResetAxes of yours! Maybe the version of OxyPlot? I'm using WPF but I only add
using OxyPlot;
using OxyPlot.Series;
using OxyPlot.Annotations;
using OxyPlot.Axes;
Because if I add OxyPlot.Wpf it interfere with others, very odd...

DJDAS wrote at 2013-06-24 11:37:

Sorry! You're right, I did my ResetAxes method too, where the Axis reset part is something like:
foreach (var axis in Plot.Axes)
    axis.InternalAxis.Reset();