Page 1 of 1

Extra white space in pie

Posted: Tue Feb 09, 2010 3:22 pm
by 9092401
Hi,

I have a problem where the pie has too much space between its' start (on the left) and the actual border of the panel (I've added an image to demonstrate).

Could you please advice me on how to control that space or eliminate it all together.

Thank you,

Jonathan

Re: Extra white space in pie

Posted: Thu Feb 11, 2010 10:13 am
by 10050769
Hello gcrnd,

I found a simple code that I think you could use in your application to control space there are between pie and margins. Please, check next code works as you want:

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private Steema.TeeChart.Styles.Pie pie1;
        private void InitializeChart()
        {
           //tChart1.Legend.Visible = false;
            pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);
            pie1.FillSampleValues(4);
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
            tChart1.Draw();

        }
        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            Rectangle rect = tChart1.Chart.ChartRect;
            int w = tChart1.Legend.Visible ? tChart1.Legend.Left - rect.Left : rect.Width;
            pie1.CustomXRadius = (w / 2) - getWidestMark(pie1);
            pie1.CustomYRadius = rect.Height / 2;
        }
        private int getWidestMark(Steema.TeeChart.Styles.Series s)
        {
            int tmp = 0; 

            if (s.Marks.Visible)
            {
                for (int i = 0; i < s.Marks.Positions.Count; i++)
                {
                    tmp = Math.Max(tmp,s.Marks.Positions[i].Width);
                }
            }

            return tmp;
        }
I hope will helps.

Thanks,