Beispiel #1
0
 void _chart_OnDrawCircle(object sender, Chart.DrawEventArgs <SingleDrawingData> e)
 {
     Canvas.DrawCircle((float)e.Data.X, (float)e.Data.Y, (float)e.Data.Size, new Paint()
     {
         Color = Colors[e.Data.SeriesNo]
     });
 }
Beispiel #2
0
 void _chart_OnDrawLine(object sender, Chart.DrawEventArgs <DoubleDrawingData> e)
 {
     Canvas.DrawLine((float)e.Data.XFrom, (float)e.Data.YFrom, (float)e.Data.XTo, (float)e.Data.YTo, new Paint()
     {
         Color = Colors[e.Data.SeriesNo], StrokeWidth = 2.5F
     });
 }
Beispiel #3
0
 void _chart_OnDrawBar(object sender, Chart.DrawEventArgs <DoubleDrawingData> e)
 {
     Canvas.DrawRect((float)e.Data.XFrom, (float)e.Data.YFrom, (float)e.Data.XTo, (float)e.Data.YTo, new Paint()
     {
         Color = Colors[e.Data.SeriesNo]
     });
 }
 /// <summary>
 /// _chart_s the on draw circle.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 private void _chart_OnDrawCircle(object sender, Chart.DrawEventArgs <SingleDrawingData> e)
 {
     using (var g = UIGraphics.GetCurrentContext())
     {
         g.SetLineWidth(2);
         Colors[e.Data.SeriesNo].SetFill();
         Colors[e.Data.SeriesNo].SetStroke();
         g.AddArc((float)e.Data.X, (float)e.Data.Y, (float)e.Data.Size, START_ANGLE, END_ANGLE, true);
         g.DrawPath(CGPathDrawingMode.FillStroke);
     }
 }
        /// <summary>
        /// _chart_s the on draw text.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void _chart_OnDrawText(object sender, Chart.DrawEventArgs <TextDrawingData> e)
        {
            TextBlock textBlock = new TextBlock {
                Foreground = Brush, Text = e.Data.Text
            };

            Canvas.SetLeft(textBlock, e.Data.X);
            Canvas.SetTop(textBlock, e.Data.Y);

            this.Children.Add(textBlock);
        }
        /// <summary>
        /// _chart_s the on draw bar.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void _chart_OnDrawBar(object sender, Chart.DrawEventArgs <DoubleDrawingData> e)
        {
            WPShapes.Rectangle rectangle = new WPShapes.Rectangle();
            rectangle.Fill   = new SolidColorBrush(Colors[e.Data.SeriesNo]);
            rectangle.Width  = e.Data.XTo - e.Data.XFrom;
            rectangle.Height = e.Data.YTo - e.Data.YFrom;

            Canvas.SetLeft(rectangle, e.Data.XFrom);
            Canvas.SetTop(rectangle, e.Data.YFrom);

            this.Children.Add(rectangle);
        }
        /// <summary>
        /// _chart_s the on draw bar.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void _chart_OnDrawBar(object sender, Chart.DrawEventArgs <DoubleDrawingData> e)
        {
            using (var g = UIGraphics.GetCurrentContext())
            {
                g.SetLineWidth(1);
                Colors[e.Data.SeriesNo].SetFill();
                Colors[e.Data.SeriesNo].SetStroke();

                var rect = new CGRect((float)e.Data.XFrom, (float)e.Data.YFrom, (float)(e.Data.XTo - e.Data.XFrom), (float)(e.Data.YTo - e.Data.YFrom));
                g.AddRect(rect);

                g.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
        /// <summary>
        /// _chart_s the on draw line.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void _chart_OnDrawLine(object sender, Chart.DrawEventArgs <DoubleDrawingData> e)
        {
            using (var g = UIGraphics.GetCurrentContext())
            {
                g.SetLineWidth(2.5F);
                Colors[e.Data.SeriesNo].SetFill();
                Colors[e.Data.SeriesNo].SetStroke();

                g.MoveTo((float)e.Data.XFrom, (float)e.Data.YFrom);
                g.AddLineToPoint((float)e.Data.XTo, (float)e.Data.YTo);

                g.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
        /// <summary>
        /// _chart_s the on draw circle.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void _chart_OnDrawCircle(object sender, Chart.DrawEventArgs <SingleDrawingData> e)
        {
            WPShapes.Ellipse ellipse = new WPShapes.Ellipse
            {
                Fill   = new SolidColorBrush(Colors[e.Data.SeriesNo]),
                Width  = e.Data.Size,
                Height = e.Data.Size
            };

            Canvas.SetLeft(ellipse, e.Data.X - (e.Data.Size / 2));
            Canvas.SetTop(ellipse, e.Data.Y - (e.Data.Size / 2));

            this.Children.Add(ellipse);
        }
        /// <summary>
        /// _chart_s the on draw circle.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void _chart_OnDrawCircle(object sender, Chart.DrawEventArgs <SingleDrawingData> e)
        {
            using (CGContext g = UIGraphics.GetCurrentContext())
            {
                g.SetLineWidth(2);
                Colors[e.Data.SeriesNo].SetFill();
                Colors[e.Data.SeriesNo].SetStroke();

                float startAngle = -((float)Math.PI / 2);
                float endAngle   = ((2 * (float)Math.PI) + startAngle);
                g.AddArc((float)e.Data.X, (float)e.Data.Y, (float)e.Data.Size, startAngle, endAngle, true);

                g.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
        /// <summary>
        /// _chart_s the on draw line.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void _chart_OnDrawLine(object sender, Chart.DrawEventArgs <DoubleDrawingData> e)
        {
            WPShapes.Line line = new WPShapes.Line
            {
                Stroke          = new SolidColorBrush(Colors[e.Data.SeriesNo]),
                StrokeThickness = 2,
                X1 = e.Data.XFrom,
                Y1 = e.Data.YFrom,
                X2 = e.Data.XTo,
                Y2 = e.Data.YTo
            };


            this.Children.Add(line);
        }
        /// <summary>
        /// _chart_s the on draw grid line.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void _chart_OnDrawGridLine(object sender, Chart.DrawEventArgs <DoubleDrawingData> e)
        {
            WPShapes.Line line = new WPShapes.Line
            {
                Stroke          = Brush,
                StrokeThickness = 2,
                X1 = e.Data.XFrom,
                Y1 = e.Data.YFrom,
                X2 = e.Data.XTo,
                Y2 = e.Data.YTo
            };


            this.Children.Add(line);
        }
Beispiel #13
0
        void _chart_OnDrawPie(object sender, Chart.DrawEventArgs <PieDrawingData> e)
        {
            double pieDegrees = 360;
            double size       = ((e.Data.X > e.Data.Y) ? e.Data.Y * 2 : e.Data.X * 2);

            for (int i = 0; i < e.Data.Percentages.Length; i++)
            {
                double value = e.Data.Percentages[i];

                Canvas.DrawArc(new RectF(0, 0, (float)size, (float)size), 0, (float)pieDegrees, true, new Paint()
                {
                    Color = Colors[i]
                });
                pieDegrees -= value;
            }
        }
        /// <summary>
        /// _chart_s the on draw pie.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void _chart_OnDrawPie(object sender, Chart.DrawEventArgs <PieDrawingData> e)
        {
            double size          = ((e.Data.X > e.Data.Y) ? e.Data.Y * 2 : e.Data.X * 2);
            double halfSize      = size / 2;
            var    previousPoint = new WPPoint(size, halfSize); // initial perimetric point (at 0 degrees)

            double totalDegrees = 0;

            for (int i = 0; i < e.Data.Percentages.Length; i++)
            {
                var path = new Path();

                var pathFigure = new PathFigure();
                pathFigure.IsClosed   = true;
                pathFigure.StartPoint = new WPPoint(halfSize, halfSize);

                var degrees = e.Data.Percentages[i];
                totalDegrees += degrees;
                // calculate perimetric point at totalDegrees
                double coordinateX = halfSize * Math.Cos(MathHelper.Deg2Rad(360 - totalDegrees));
                double coordinateY = halfSize * Math.Sin(MathHelper.Deg2Rad(360 - totalDegrees));

                var lineSegment = new LineSegment();
                lineSegment.Point = previousPoint;
                pathFigure.Segments.Add(lineSegment);

                previousPoint = new WPPoint(coordinateX + halfSize, coordinateY + halfSize); // actual perimetric point (will be the previous in the next iteration)

                var arcSegment = new ArcSegment();
                arcSegment.Size           = new WPSize(halfSize, halfSize);
                arcSegment.Point          = previousPoint;
                arcSegment.RotationAngle  = 0;
                arcSegment.IsLargeArc     = degrees > 180 ? true : false;
                arcSegment.SweepDirection = SweepDirection.Counterclockwise;
                pathFigure.Segments.Add(arcSegment);

                var pathGeometry = new PathGeometry();
                pathGeometry.Figures = new PathFigureCollection();

                pathGeometry.Figures.Add(pathFigure);

                path.Data = pathGeometry;
                path.Fill = new SolidColorBrush(Colors[i]);

                Children.Add(path);
            }
        }
Beispiel #15
0
        /// <summary>
        /// _chart_s the on draw pie.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void _chart_OnDrawPie(object sender, Chart.DrawEventArgs <PieDrawingData> e)
        {
            double totalDegrees = 0;

            for (var i = 0; i < e.Data.Percentages.Length; i++)
            {
                var degrees = e.Data.Percentages[i];
                using (var g = UIGraphics.GetCurrentContext())
                {
                    g.SetLineWidth(2);
                    this.Colors[i].SetFill();
                    this.Colors[i].SetStroke();
                    g.AddArc((float)e.Data.X, (float)e.Data.Y, (float)e.Data.Size, (float)(Math.PI / 180 * totalDegrees), (float)(Math.PI / 180 * degrees), true);
                    g.DrawPath(CGPathDrawingMode.FillStroke);
                }

                totalDegrees += degrees;
            }
        }
        /// <summary>
        /// _chart_s the on draw pie.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void _chart_OnDrawPie(object sender, Chart.DrawEventArgs <PieDrawingData> e)
        {
            double size          = ((e.Data.X > e.Data.Y) ? e.Data.Y * 2 : e.Data.X * 2);
            double halfSize      = size / 2;
            var    previousPoint = new WPPoint(halfSize, 0);

            for (int i = 0; i < e.Data.Percentages.Length; i++)
            {
                double value       = e.Data.Percentages[i];
                double coordinateX = halfSize * Math.Sin(value);
                double coordinateY = halfSize * Math.Cos(value);
                Path   path        = new Path();

                PathFigure pathFigure = new PathFigure();
                pathFigure.IsClosed = true;

                pathFigure.StartPoint = new WPPoint(halfSize, halfSize);

                LineSegment lineSegment = new LineSegment();
                lineSegment.Point = previousPoint;
                pathFigure.Segments.Add(lineSegment);

                previousPoint = new WPPoint(coordinateX + halfSize, coordinateY + halfSize);

                ArcSegment arcSegment = new ArcSegment();
                arcSegment.Size           = new WPSize(halfSize, halfSize);
                arcSegment.Point          = previousPoint;
                arcSegment.RotationAngle  = 0;
                arcSegment.IsLargeArc     = value > 180 ? true : false;
                arcSegment.SweepDirection = SweepDirection.Clockwise;
                pathFigure.Segments.Add(arcSegment);

                PathGeometry pathGeometry = new PathGeometry();
                pathGeometry.Figures = new PathFigureCollection();

                pathGeometry.Figures.Add(pathFigure);

                path.Data = pathGeometry;
                path.Fill = new SolidColorBrush(Colors[i]);
                this.Children.Add(path);
            }
        }
        /// <summary>
        /// _chart_s the on draw pie.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void _chart_OnDrawPie(object sender, Chart.DrawEventArgs <PieDrawingData> e)
        {
            double totalDegrees = 0;

            for (var i = 0; i < e.Data.Percentages.Length; i++)
            {
                var degrees = e.Data.Percentages[i];
                using (var g = UIGraphics.GetCurrentContext())
                {
                    g.SetLineWidth(2);
                    Colors[i].SetFill();
                    Colors[i].SetStroke();
                    g.MoveTo((float)e.Data.X, (float)e.Data.Y);
                    g.AddArc((float)e.Data.X, (float)e.Data.Y, (float)e.Data.Size,
                             (float)MathHelper.DegreesToRadians(360 - totalDegrees - degrees), (float)MathHelper.DegreesToRadians(360 - totalDegrees), false);
                    g.DrawPath(CGPathDrawingMode.FillStroke);
                }

                totalDegrees += degrees;
            }
        }
Beispiel #18
0
 void _chart_OnDrawText(object sender, Chart.DrawEventArgs <TextDrawingData> e)
 {
     Canvas.DrawText(e.Data.Text, (float)e.Data.X, (float)e.Data.Y, Paint);
 }
Beispiel #19
0
 void _chart_OnDrawGridLine(object sender, Chart.DrawEventArgs <DoubleDrawingData> e)
 {
     Canvas.DrawLine((float)e.Data.XFrom, (float)e.Data.YFrom, (float)e.Data.XTo, (float)e.Data.YTo, Paint);
 }
        /// <summary>
        /// _chart_s the on draw text.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private static void _chart_OnDrawText(object sender, Chart.DrawEventArgs <TextDrawingData> e)
        {
            var str = new NSString(e.Data.Text);

            str.DrawString(new CGPoint((float)e.Data.X, (float)e.Data.Y), UIFont.SystemFontOfSize(12));
        }