Example #1
0
                private static void DrawPie(Lbl.Charts.Serie Serie, System.Drawing.Graphics Canvas, System.Drawing.Size Size)
                {
                        decimal Sum = Serie.GetSum();

                        Rectangle PieRect = new Rectangle(0, 0, Size.Width, Size.Height);
                        if (PieRect.Width > PieRect.Height) {
                                PieRect.X += (PieRect.Width - PieRect.Height) / 2;
                                PieRect.Width = PieRect.Height;
                        } else {
                                PieRect.Y += (PieRect.Height - PieRect.Width) / 2;
                                PieRect.Height = PieRect.Width;
                        }

                        float LastAngle = 0;
                        foreach (Lbl.Charts.Element El in Serie.Elements) {
                                float ElementAngle = (float)(El.Value / Sum * 360);

                                Canvas.FillPie(System.Drawing.Brushes.Tomato, PieRect, LastAngle, LastAngle + ElementAngle);
                                LastAngle += ElementAngle;
                        }

                        LastAngle = 0;
                        foreach (Lbl.Charts.Element El in Serie.Elements) {
                                float ElementAngle = (float)(El.Value / Sum * 360);

                                Canvas.DrawPie(System.Drawing.Pens.Black, PieRect, LastAngle, LastAngle + ElementAngle);
                                LastAngle += ElementAngle;
                        }
                }