Example #1
0
        /// <summary>
        /// Fills a SKPoint array of data points absolute pixel positions.
        /// </summary>
        /// <param name="graph">Graphics object.</param>
        /// <param name="area">Chart area.</param>
        /// <param name="series">Point series.</param>
        /// <returns>Array of data points position.</returns>
        override protected SKPoint[] GetPointsPosition(ChartGraphics graph, ChartArea area, Series series)
        {
            SKPoint[] pointPos = new SKPoint[series.Points.Count + 1];
            int       index    = 0;

            foreach (DataPoint point in series.Points)
            {
                // Change Y value if line is out of plot area
                double yValue = GetYValue(Common, area, series, point, index, 0);

                // Recalculates y position
                double yPosition = area.AxisY.GetPosition(yValue);

                // Recalculates x position
                double xPosition = area.circularCenter.X;

                // Add point position into array
                pointPos[index] = graph.GetAbsolutePoint(new SKPoint((float)xPosition, (float)yPosition));

                // Rotate position
                float     sectorAngle  = area.CircularPositionToAngle(point.XValue);
                SKMatrix  matrix       = SkiaSharpExtensions.CreateRotationDegrees(sectorAngle, graph.GetAbsolutePoint(area.circularCenter));
                SKPoint[] rotatedPoint = new SKPoint[] { pointPos[index] };
                matrix.TransformPoints(rotatedPoint);
                pointPos[index] = rotatedPoint[0];

                index++;
            }

            // Add last center point
            pointPos[index] = graph.GetAbsolutePoint(area.circularCenter);

            return(pointPos);
        }
Example #2
0
 /// <summary>
 /// Draws a cardinal spline through a specified array of SKPoint structures
 /// using a specified tension. The drawing begins offset from
 /// the beginning of the array.
 /// </summary>
 /// <param name="pen">Pen object that determines the color, width, and height of the curve.</param>
 /// <param name="points">Array of SKPoint structures that define the spline.</param>
 /// <param name="offset">Offset from the first element in the array of the points parameter to the starting point in the curve.</param>
 /// <param name="numberOfSegments">Number of segments after the starting point to include in the curve.</param>
 /// <param name="tension">Value greater than or equal to 0.0F that specifies the tension of the curve.</param>
 public void DrawCurve(
     SKPaint pen,
     SKPoint[] points,
     int offset,
     int numberOfSegments,
     float tension
     )
 {
     pen.IsAntialias = true;
     Graphics.DrawPath(SkiaSharpExtensions.CreateSpline(points), pen);
 }