Exemplo n.º 1
0
        private void CreatePieShape(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            PieShape shape = new PieShape(new RectangleF2D(new PointF(0, 30), new SizeF(80, 10)), 40, 270);

            shape.Appearance.ContentBrush = new SolidBrushObject(Color.Blue);
            shape.Name = "pieNeedle";
            needleShape.Add(shape);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Render pie 2d plot view.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context instance.</param>
        protected override void OnPaint(Rendering.DrawingContext dc)
        {
            base.OnPaint(dc);

            var ds = Chart.DataSource;

            if (ds != null && ds.SerialCount != 0)
            {
                var serial    = ds[0];
                var dataCount = serial.Count;

                // Sum up the data values
                double sum = 0;

                for (int i = 0; i < dataCount; i++)
                {
                    var data = serial[i];

                    if (data != null)
                    {
                        sum += (double)data;
                    }
                }

                // Draw the pie shapes
                RGFloat  currentAngle = 0;
                PieShape pie          = null;

                for (int i = 0; i < dataCount; i++)
                {
                    RGFloat scale = (RGFloat)(360.0 / sum);
                    var     data  = serial[i];

                    if (data != null)
                    {
                        RGFloat angle = (RGFloat)(data * scale);

                        pie            = CreatePieShape(ClientBounds);
                        pie.StartAngle = currentAngle;
                        pie.SweepAngle = angle;
                        pie.FillColor  = Chart.DataSerialStyles[i].FillColor;
                        pie.Draw(dc);

                        currentAngle += angle;
                    }
                }

                // Draw the category names over the pie shapes (experimental)

                /*currentAngle = 0;
                 *
                 * for (int i = 0; i < dataCount; i++)
                 * {
                 *      RGFloat scale = (RGFloat)(360.0 / sum);
                 *      var data = serial[i];
                 *
                 *      if (data != null)
                 *      {
                 *              RGFloat angle = (RGFloat)(data * scale);
                 *              currentAngle += angle;
                 *              var itemTitle = ds.GetCategoryName(i);
                 *              if (itemTitle != null)
                 *              {
                 *                      angle = currentAngle - angle / 2;
                 *                      var bounds = pie.ClientBounds;
                 *                      var x = Math.Sin(Math.PI * angle / 180) * bounds.Width / 3;
                 *                      var y = Math.Cos(Math.PI * angle / 180) * bounds.Height / -3;
                 *                      bounds.Offset((RGFloat)x, (RGFloat)y);
                 *                      dc.Graphics.DrawText(itemTitle, FontName, FontSize, ForeColor, bounds,
                 *                              ReoGridHorAlign.Center, ReoGridVerAlign.Middle);
                 *              }
                 *      }
                 * }*/
            }
        }