Question

i have ChartView that received read time data via timer. my Chart contain only 60 points and after 60 points the oldest point deleted so my Chart contain only 60 points.

Now i want to know the current biggest point from my Chart:

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

The problem is that at this point error occurs:

At least one object must implement IComparable.

And i don't know why

Was it helpful?

Solution

The class Telerik.Charting.DataPoint doesn't implement IComparable - that is, the data point doesn't know how to compare itself to another data point (do you want to compare x values? y values?). You could loop through all data points, and keep track of the max value (x or y) and the corresponding datapoint:

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
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top