oxyplot: LineSeries has bad performance with large amount of data due to `aliased=false`

When plotting large amount of data (i.e. over 100k points) using LineSeries, it has bad perfomance and showing up with long seconds delay. (environment: .net 4.5.2 WindowsForms on Windows 7 (x64))

I figured out that this issue is due to rc.DrawClippedLine(…, aliased=false, …) in LineSeries.RenderLine(). Unfortunately aliased=false is hardcoded.

There is a workaround making delived class with overriding RenderLine().

public class MyLineSeries : LineSeries
{

    List<ScreenPoint> outputBuffer = null;

    public bool Aliased { get; set; } = true;

    protected override void RenderLine(IRenderContext rc, OxyRect clippingRect, IList<ScreenPoint> pointsToRender)
    {
        var dashArray = this.ActualDashArray;

        if (this.outputBuffer == null) 
        {
            this.outputBuffer = new List<ScreenPoint>(pointsToRender.Count);
        }

        rc.DrawClippedLine(clippingRect,
                           pointsToRender,
                           this.MinimumSegmentLength * this.MinimumSegmentLength,
                           this.GetSelectableColor(this.ActualColor),
                           this.StrokeThickness,
                           dashArray,
                           this.LineJoin,
                           this.Aliased,  // <-- this is the issue
                           this.outputBuffer);

    }
}

I made a test program to compare performance, attached. CheckLineSeriesAliased.zip Here is a result with 10k, 20k, 50k, 100k data / aliased=true or false.

length true false
10k 0.02[s] 0.36[s]
20k 0.04[s] 1.05[s]
50k 0.09[s] 8.51[s]
100k 0.19[s] 64.83[s]

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 6
  • Comments: 15 (12 by maintainers)

Most upvoted comments

Having run into this problem myself recently I gave this some more thought. I agree with @VisualMelon, I think this behaviour should be completely configurable by the user (with sensible default values). Also I think this should not be limited to LineSeries, or Series for that matter - what if someone wants aliased Annotations?

So I would propose: Add IsAliased property to PlotElement and use that for all render calls. Set defaults for each subclass such that the visual output is the same as it is now, e.g. set IsAliased=true for Axes, BoxPlotSeries, RectangleSeries

I will take care of this soon(ish) if there are no objections.