Beispiel #1
0
        protected override void DrawNullPoint(ChartSerie serie, SKCanvas canvas)
        {
            //Some of the drawing algorithms index into pointsPerSerie
            var point = new SKPoint(float.MinValue, float.MinValue);

            pointsPerSerie[serie].Add(point);
        }
Beispiel #2
0
        /// <inheritdoc/>
        protected override void DrawBar(ChartSerie serie, SKCanvas canvas, float headerHeight, float itemX, SKSize itemSize, SKSize barSize, float origin, float barX, float barY, SKColor color)
        {
            //Drawing entry point at center of the item (label) part
            var point = new SKPoint(itemX, barY);

            pointsPerSerie[serie].Add(point);
        }
Beispiel #3
0
 /// <inheritdoc />
 protected override void DrawBar(ChartSerie serie, SKCanvas canvas, float headerHeight, float itemX, SKSize itemSize, SKSize barSize, float origin, float barX, float barY, SKColor color)
 {
     if (PointMode != PointMode.None)
     {
         var point = new SKPoint(barX - (itemSize.Width / 2) + (barSize.Width / 2), barY);
         canvas.DrawPoint(point, color, PointSize, PointMode);
     }
 }
Beispiel #4
0
 /// <inheritdoc />
 protected override void DrawBar(ChartSerie serie, SKCanvas canvas, float headerHeight, float itemX, SKSize itemSize, SKSize barSize, float origin, float barX, float barY, SKColor color)
 {
     using (var paint = new SKPaint
     {
         Style = SKPaintStyle.Fill,
         Color = color,
     })
     {
         (SKPoint location, SKSize size) = GetBarDrawingProperties(headerHeight, itemSize, barSize, origin, barX, barY);
         var rect = SKRect.Create(location, size);
         canvas.DrawRect(rect, paint);
     }
 }
Beispiel #5
0
        private void DrawLineArea(SKCanvas canvas, ChartSerie serie, SKPoint[] points, SKSize itemSize, float origin)
        {
            if (LineAreaAlpha > 0 && points.Length > 1)
            {
                using (var paint = new SKPaint
                {
                    Style = SKPaintStyle.Fill,
                    Color = SKColors.White,
                    IsAntialias = true,
                })
                {
                    using (var shaderX = CreateXGradient(points, serie.Entries, serie.Color, (byte)(LineAreaAlpha * AnimationProgress)))
                        using (var shaderY = CreateYGradient(points, (byte)(LineAreaAlpha * AnimationProgress)))
                        {
                            paint.Shader = EnableYFadeOutGradient ? SKShader.CreateCompose(shaderY, shaderX, SKBlendMode.SrcOut) : shaderX;

                            var path = new SKPath();

                            path.MoveTo(points.First().X, origin);
                            path.LineTo(points.First());

                            var last = (LineMode == LineMode.Spline) ? points.Length - 1 : points.Length;
                            for (int i = 0; i < last; i++)
                            {
                                if (LineMode == LineMode.Spline)
                                {
                                    var cubicInfo = CalculateCubicInfo(points, i, itemSize);
                                    path.CubicTo(cubicInfo.control, cubicInfo.nextControl, cubicInfo.nextPoint);
                                }
                                else if (LineMode == LineMode.Straight)
                                {
                                    path.LineTo(points[i]);
                                }
                            }

                            path.LineTo(points.Last().X, origin);
                            path.Close();
                            canvas.DrawPath(path, paint);
                        }
                }
            }
        }
Beispiel #6
0
        /// <inheritdoc />
        protected override void DrawBar(ChartSerie serie, SKCanvas canvas, float headerHeight, float itemX, SKSize itemSize, SKSize barSize, float origin, float barX, float barY, SKColor color)
        {
            using (var paint = new SKPaint
            {
                Style = SKPaintStyle.Fill,
                Color = color,
            })
            {
                var x      = barX - (itemSize.Width / 2);
                var y      = Math.Min(origin, barY);
                var height = Math.Abs(origin - barY);
                if (height < MinBarHeight)
                {
                    height = MinBarHeight;
                    if (y + height > Margin + itemSize.Height)
                    {
                        y = headerHeight + itemSize.Height - height;
                    }
                }

                var rect = SKRect.Create(x, y, barSize.Width, height);
                canvas.DrawRect(rect, paint);
            }
        }
Beispiel #7
0
        private void DrawLineArea(SKCanvas canvas, ChartSerie serie, SKPoint[] points, SKSize itemSize, float origin)
        {
            if (LineAreaAlpha > 0 && points.Length > 1)
            {
                using (var paint = new SKPaint
                {
                    Style = SKPaintStyle.Fill,
                    Color = SKColors.White,
                    IsAntialias = true,
                })
                {
                    using (var shaderX = CreateXGradient(points, serie.Entries, serie.Color, (byte)(LineAreaAlpha * AnimationProgress)))
                        using (var shaderY = CreateYGradient(points, (byte)(LineAreaAlpha * AnimationProgress)))
                        {
                            paint.Shader = EnableYFadeOutGradient ? SKShader.CreateCompose(shaderY, shaderX, SKBlendMode.SrcOut) : shaderX;

                            var path = new SKPath();

                            var     isFirst   = true;
                            var     entries   = serie.Entries;
                            var     lineMode  = LineMode;
                            var     last      = (lineMode == LineMode.Spline) ? points.Length - 1 : points.Length;
                            SKPoint lastPoint = points.First();
                            for (int i = 0; i < last; i++)
                            {
                                if (!entries.ElementAt(i).Value.HasValue)
                                {
                                    continue;
                                }

                                if (isFirst)
                                {
                                    path.MoveTo(points[i].X, origin);
                                    path.LineTo(points[i]);
                                    isFirst = false;
                                }

                                if (lineMode == LineMode.Spline)
                                {
                                    int next = i + 1;
                                    while (next < last && !entries.ElementAt(next).Value.HasValue)
                                    {
                                        next++;
                                    }

                                    if (next == last && !entries.ElementAt(next).Value.HasValue)
                                    {
                                        lastPoint = points[i];
                                        break;
                                    }

                                    var cubicInfo = CalculateCubicInfo(points, i, next, itemSize);
                                    path.CubicTo(cubicInfo.control, cubicInfo.nextControl, cubicInfo.nextPoint);
                                    lastPoint = cubicInfo.nextPoint;
                                }
                                else if (lineMode == LineMode.Straight)
                                {
                                    path.LineTo(points[i]);
                                    lastPoint = points[i];
                                }
                            }

                            path.LineTo(lastPoint.X, origin);
                            path.Close();
                            canvas.DrawPath(path, paint);
                        }
                }
            }
        }