how to get the max point coordinate on the showing screen?

May 21, 2014 at 4:22 AM
I use oxyplot to show 2048 points, when I zoom specific area, how to get the max point coordinate on the showing screen, not the max point of the whole data?
Any ideas how I can do that?
May 21, 2014 at 6:32 AM
Edited May 21, 2014 at 7:41 AM
What do you need for getting the maximum of the whole data is:
MyData.Select( p => p.Y).Max();
For the data shown in the ViewPort: Get the ActualMinimum/ActualMaximum of the X axis in your Model (MyModel.Axes[0].ActualMinimum etc), perform the same operation as before but only for the interested points:
MyData.Select( p => p.Y && p.X > myMin && p.X < myMax).Max();
I haven't tested the code above, but should be enough to point you in the right direction.

Good luck
May 21, 2014 at 8:52 AM
Thanks, the operation can find the max point in the ViewPort.
Further, if there are two or more lines in the ViewPort, I need to run the operation specific times to get the max point of these lines. Have any methods to make the "MyData" cover all the points in different lines in the ViewPort?
May 21, 2014 at 10:22 AM
Edited May 21, 2014 at 10:26 AM
MyData in my example is a collection of points. You can loop for each of your LineSeries if you don't want/can't use the "source" data of that LineSeries:
List<string> names = new List<string>();
List<double> maxima = new List<double>();
foreach(LineSeries ls in MyModel.Series.OfType<LineSeries>())
{
    double max = ls.Points.Select( p => p.Y && p.X > myMin && p.X < myMax).Max();
    maxima.Add(max);
    names.Add(ls.Title);
}

//Show gathered maxima

for(int i=0; i<names.Count; i++)
{
    MessageBox.Show("Maximum of " + names[i] + " in the current view is " + maxima[i]);  
}
(Untested)

EDIT: I think the way of obtaining the maximum of a range is not correct (you wont be able to compile that), you can select the range using .Where from Linq namespace.

var range = MyData.Where(p => p.X > MyMin && p.X < MyMax);
double max = range.Select( p => p.Y).Max();
Good luck
Marked as answer by aoi on 5/21/2014 at 2:48 AM
May 21, 2014 at 10:53 AM
Thank you very much for helping me solve this problem with patience.That solved the problem.