The default LineSeries implementation orders data points by independed value. This gives me strange results for data like this:
Is it possible to plot a line series where lines are drawn between the points in the original order?
I currently solved this by inheriting from LineSeries:
class UnorderedLineSeries : LineSeries
{
protected override void UpdateShape()
{
double maximum = ActualDependentRangeAxis.GetPlotAreaCoordinate(
ActualDependentRangeAxis.Range.Maximum).Value;
Func<DataPoint, Point> PointCreator = dataPoint =>
new Point(
ActualIndependentAxis.GetPlotAreaCoordinate(
dataPoint.ActualIndependentValue).Value,
maximum - ActualDependentRangeAxis.GetPlotAreaCoordinate(
dataPoint.ActualDependentValue).Value);
IEnumerable<Point> points = Enumerable.Empty<Point>();
if (CanGraph(maximum))
{
// Original implementation performs ordering here
points = ActiveDataPoints.Select(PointCreator);
}
UpdateShapeFromPoints(points);
}
bool CanGraph(double value)
{
return !double.IsNaN(value) &&
!double.IsNegativeInfinity(value) &&
!double.IsPositiveInfinity(value) &&
!double.IsInfinity(value);
}
}
Result: