C# 如何从Telerik ChartDataPointCollection中找到我的最大点值

C# 如何从Telerik ChartDataPointCollection中找到我的最大点值,c#,.net,charts,telerik,C#,.net,Charts,Telerik,我有ChartView,它通过定时器接收读取时间数据。 我的图表仅包含60点,60点后最早的点被删除,因此我的图表仅包含60点 现在我想从我的图表中知道当前最大点: AreaSeries series; Telerik.Charting.DataPoint num = chartDataPointCollection.Max<Telerik.Charting.DataPoint>(); 我不知道为什么类Telerik.Charting.DataPoint没有实现IComparabl

我有
ChartView
,它通过定时器接收读取时间数据。 我的
图表
仅包含60点,60点后最早的点被删除,因此我的
图表
仅包含60点

现在我想从我的
图表中知道当前最大点:

AreaSeries series;
Telerik.Charting.DataPoint num = chartDataPointCollection.Max<Telerik.Charting.DataPoint>();

我不知道为什么类
Telerik.Charting.DataPoint
没有实现
IComparable
——也就是说,数据点不知道如何将自己与另一个数据点进行比较(是否要比较x值?y值?)。您可以循环遍历所有数据点,并跟踪最大值(x或y)和相应的数据点:

DataPoint maxPoint = null;
double maxValue = double.MinValue;
foreach (DataPoint point in chartDataPointCollection)
{
    if (point.X > maxValue)
    {
        maxValue = point.X; // or point.Y, or whatever criteria you want to use.
        maxPoint = point;
    }
}
if (maxPoint != null)
{
    // do stuff with the max point
}
DataPoint maxPoint = null;
double maxValue = double.MinValue;
foreach (DataPoint point in chartDataPointCollection)
{
    if (point.X > maxValue)
    {
        maxValue = point.X; // or point.Y, or whatever criteria you want to use.
        maxPoint = point;
    }
}
if (maxPoint != null)
{
    // do stuff with the max point
}