few changes to the source and one potential issue found

May 3, 2013 at 5:35 PM
Hi objo,
I started to use oxyplot not long ago, thanks for the great library.
While developing I traced into oxyplot source and make some changes. Need to know if the changes are good, and could it be included into official trunk?
  1. Added "Resolution" properties to LineSeries to give option on lower resolution drawing in high data count use case.
  2. BoxPlotSeries GetNearestPoint TrackerHitResult.Text should return DateTime for DateTimeAxis.
 -                            result.DataPoint.X,
+                            this.XAxis != null ? this.XAxis.GetValue(result.DataPoint.X) : result.DataPoint.X,
  1. RenderingExtension DrawClippedLine exception when trying to draw a line with single point. So I added a check for single point case and create an offset just like what the code did in latter single point case. Not sure if this is the best way.
// render the line if we are leaving the clipping region););
                    if (!clipping.IsInside(s1))
                    {
                        if (pts.Count > 0)
                        {
                          // Check if the line contains a single point
                          if (pts.Count == 1) {
                            // Add a second point to make sure the line is being rendered as a small dot
                            pts.Add(new ScreenPoint(pts[0].X + 1, pts[0].Y));
                            pts[0] = new ScreenPoint(pts[0].X - 1, pts[0].Y);
                          }

                            rc.DrawLine(
                                pts, stroke, strokeThickness, lineStyle.GetDashArray(), lineJoin, aliased);
                            if (pointsRendered != null)
                            {
                                pointsRendered(pts);
                            }

                            pts = new List<ScreenPoint>();
                        }
                    }
Coordinator
May 6, 2013 at 8:29 AM
thanks for the bug reports and correction code! I have corrected #2 and #3, and added examples to make sure it works.
How did you implement lower resolution in #1? The LineSeries has a MinimumSegmentLength property that works in screen coordinates.
Are you sampling the input data points - I think this could be handled by the application, not by the plotting library.
May 6, 2013 at 4:17 PM
Hi objo,
Thanks for the updated code, your changes are much elegant by moving the single point handling to a separate method.

As for #1 (resolution), I simply added a Resolution property to LineSeries and pass it along to RenderingExtensions.DrawMarkers.
            if (this.MarkerType != MarkerType.None)
            {
                rc.DrawMarkers(
                    pointsToRender, 
                    clippingRect, 
                    this.MarkerType, 
                    this.MarkerOutline, 
                    new[] { this.MarkerSize }, 
                    this.MarkerFill, 
                    this.MarkerStroke, 
                    this.MarkerStrokeThickness,
                    this.Resolution); // added Resolution property and pass it to draw markers
            }
Some background on my intention: I realize the 100K performance test is only good for non-markers line series. When there is markers, the performance degraded drastically due to markers drawing, obviously markers drawing requires much heavier processing than simple line drawing. Hence I try to reduce the number of markers when they overlapped, which is what DrawMarkers resolution argument is doing. Honestly the resolution method that I use (resolution 5) is just slight better than the original code, still not good enough for my application but I will look at possible way to improve that later.


I was considering handling in application code, but found DrawMarkers method to be resolution capable, so i just reuse it. After take a look at MinimumSegmentLeght, it is mainly to optimize line drawing, the markers drawing is not affected by this property, if I read it correctly... But I do see that I can use ScreenPointHelper.ResamplePoints to get resample screenpoints and pass it to DrawMarkers, what do you think?
Coordinator
Jun 8, 2013 at 9:55 AM
ok, I added a MarkerResolution property to the LineSeries.
Note: the last argument of the DrawMarkers method should also be provided when using the resolution argument (otherwise you will get marker flickering when panning)
Jun 13, 2013 at 4:35 PM
Thanks objo, that works great!