Source/OxyPlot.Avalonia/CanvasRenderContext.cs
/// <summary>
/// Draws the line using the MaxPolylinesPerLine and MinPointsPerPolyline properties.
/// </summary>
/// <param name="points">The points.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="dashArray">The dash array. Use <c>null</c> to get a solid line.</param>
/// <param name="lineJoin">The line join.</param>
/// <param name="aliased">Render aliased if set to <c>true</c>.</param>
/// <remarks>See <a href="https://oxyplot.codeplex.com/discussions/456679">discussion</a>.</remarks>
Draws the line using the MaxPolylinesPerLine and MinPointsPerPolyline properties.
Draws the line using the MaxPolylinesPerLine and MinPointsPerPolyline properties .
private void DrawLineBalanced(IList<ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased)
        {
            var numPointsPerPolyline = Math.Max(points.Count / MaxPolylinesPerLine, MinPointsPerPolyline);
            var polyline = CreateAndAdd<Polyline>();
            SetStroke(polyline, stroke, thickness, lineJoin, dashArray, 0, aliased);
            var pc = new List<Point>(numPointsPerPolyline);
            var n = points.Count;
            double lineLength = 0;
            var dashPatternLength = (dashArray != null) ? dashArray.Sum() : 0;
            var last = new Point();
            for (int i = 0; i < n; i++)
            {
                var p = aliased ? ToPixelAlignedPoint(points[i]) : ToPoint(points[i]);
                pc.Add(p);
                if (dashArray != null)
                {
                    if (i > 0)
                    {
                        var delta = p - last;
                        var dist = Math.Sqrt((delta.X * delta.X) + (delta.Y * delta.Y));
                        lineLength += dist;
                    }
                    last = p;
                }
                if (pc.Count >= numPointsPerPolyline)
                {
                    polyline.Points = pc;
                    if (i < n - 1)
                    {
                        var dashOffset = dashPatternLength > 0 ? lineLength / thickness : 0;
                        polyline = CreateAndAdd<Polyline>();
                        SetStroke(polyline, stroke, thickness, lineJoin, dashArray, dashOffset, aliased);
                        pc = new List<Point>(numPointsPerPolyline) { pc.Last() };
                    }
                }
            }
            if (pc.Count > 1 || n == 1)
            {
                polyline.Points = pc;
            }
        }
private void DrawLineBalanced ( IList < ScreenPoint > points , OxyColor stroke , double thickness , double [ ] dashArray , LineJoin lineJoin , bool aliased ) { var numPointsPerPolyline = Math . Max ( points . Count / MaxPolylinesPerLine , MinPointsPerPolyline ) ; var polyline = CreateAndAdd < Polyline > ( ) ; SetStroke ( polyline , stroke , thickness , lineJoin , dashArray , 0 , aliased ) ; var pc = new List < Point > ( numPointsPerPolyline ) ; var n = points . Count ; double lineLength = 0 ; var dashPatternLength = ( dashArray != null ) ? dashArray . Sum ( ) : 0 ; var last = new Point ( ) ; for ( int i = 0 ; i < n ; i ++ ) { var p = aliased ? ToPixelAlignedPoint ( points [ i ] ) : ToPoint ( points [ i ] ) ; pc . Add ( p ) ; if ( dashArray != null ) { if ( i > 0 ) { var delta = p - last ; var dist = Math . Sqrt ( ( delta . X * delta . X ) + ( delta . Y * delta . Y ) ) ; lineLength += dist ; } last = p ; } if ( pc . Count >= numPointsPerPolyline ) { polyline . Points = pc ; if ( i < n - 1 ) { var dashOffset = dashPatternLength > 0 ? lineLength / thickness : 0 ; polyline = CreateAndAdd < Polyline > ( ) ; SetStroke ( polyline , stroke , thickness , lineJoin , dashArray , dashOffset , aliased ) ; pc = new List < Point > ( numPointsPerPolyline ) { pc . Last ( ) } ; } } } if ( pc . Count > 1 || n == 1 ) { polyline . Points = pc ; } }
Draws the line using the MaxPolylinesPerLine and MinPointsPerPolyline properties.
Draws the line using the MaxPolylinesPerLine and MinPointsPerPolyline properties .
// balance the number of points per polyline and the number of polylines // alt. 1 // use multiple polylines with limited number of points to improve Avalonia performance // alt.2 ////if (dashArray != null) ////{ ////    lineLength += this.GetLength(polyline); ////} // start a new polyline at last point so there is no gap (it is not necessary to use the % operator)
points
IList<ScreenPoint>
None
stroke
OxyColor
The stroke color.
The stroke color .
thickness
double
None
dashArray
double[]
The dash array. Use null
The dash array . Use null
lineJoin
LineJoin
The line join.
The line join .
aliased
bool
Render aliased if set to true
Render aliased if set to true
remarks
None