Example4_6.ChartStyle.SetPieArea C# (CSharp) Method

SetPieArea() public method

public SetPieArea ( ) : Rectangle
return System.Drawing.Rectangle
        public Rectangle SetPieArea()
        {
            Offset = form1.PlotPanel.Width / 10;
            int height = form1.PlotPanel.Height - 2 * Offset;
            int width = height;
            Rectangle rect = new Rectangle(Offset, Offset, width, height);
            return rect;
        }

Usage Example

        public void AddLegend(Graphics g, DataSeries ds, ChartStyle cs)
        {
            if (ds.DataList.Count < 1)
            {
                return;
            }
            if (!IsLegendVisible)
            {
                return;
            }
            int numberOfDataValues = ds.DataList.Count;

            string[] legendLabels = new string[ds.LabelList.Count];
            for (int i = 0; i < ds.LabelList.Count; i++)
            {
                legendLabels[i] = (string)ds.LabelList[i];
            }
            // float offSet = 20;
            float xc          = 0f;
            float yc          = 0f;
            SizeF size        = g.MeasureString(legendLabels[0], LegendFont);
            float legendWidth = size.Width;

            for (int i = 0; i < legendLabels.Length; i++)
            {
                size = g.MeasureString(legendLabels[i], LegendFont);
                float tempWidth = size.Width;
                if (legendWidth < tempWidth)
                {
                    legendWidth = tempWidth;
                }
            }
            legendWidth = legendWidth + 35.0f;
            float hWidth       = legendWidth / 2;
            float legendHeight = 18.0f * numberOfDataValues;
            float hHeight      = legendHeight / 2;

            Rectangle rect = cs.SetPieArea();

            xc = rect.X + rect.Width + cs.Offset + 20 + hWidth / 2;
            yc = rect.Y + rect.Height / 2;
            DrawLegend(g, xc, yc, hWidth, hHeight, ds, cs);
        }
All Usage Examples Of Example4_6.ChartStyle::SetPieArea