Axis Title Position

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Lakshmi
Newbie
Newbie
Posts: 40
Joined: Fri Oct 07, 2005 4:00 am
Location: India
Contact:

Axis Title Position

Post by Lakshmi » Tue Apr 10, 2007 1:02 pm

Hi

We have a requirement as to where we position the axis title position.
For the bottom axis it could be left, middle or right.
For the left axis it could be top, middle or bottom.

Is there any way of supporting the above thing with TeeChart.
Please comment.

Thank you.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Apr 12, 2007 10:01 am

Hi Lakshmi

TeeChart doesn't support your requirement by the moment. I've added it (TF02012168) to our defect list to be enhanced for future releases.

In the meantime, a workaround can be to use an Annotation Tools or something similar as below code:

Code: Select all

 
        private void Form1_Load(object sender, EventArgs e)
        {
            bar1.FillSampleValues(6);
            tChart1.Aspect.View3D = false;

            tChart1.Panel.MarginLeft = 5;
            tChart1.Panel.MarginBottom = 6;
        }

        private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            //Initialization Bottom Titles 
            String[] text_bottom = new String[] { "Left", "Middle", "Right" };
            int[] width_bottom = new int[3];
            int[] height_bottom = new int[3];
            for (int i = 0; i < 3; i++)
            {
                width_bottom[i] = Convert.ToInt32(g.TextWidth(text_bottom[i])) + 5;
                height_bottom[i] = Convert.ToInt32(g.TextHeight(text_bottom[i])) + 2;
            }

            int y_bottom = tChart1.Axes.Left.IEndPos + 20;
            int[] x_bottom = new int[3];
            x_bottom[0] = tChart1.Axes.Bottom.IStartPos;
            x_bottom[1] = (tChart1.Axes.Bottom.IEndPos - tChart1.Axes.Bottom.IStartPos) / 2 + width_bottom[1] * 3 / 2;
            x_bottom[2] = tChart1.Axes.Bottom.IEndPos - width_bottom[2];


            //Initialization Left Titles 
            String[] text_left = new String[] { "Top", "Middle", "Bottom" };
            int[] width_left = new int[3];
            int[] height_left = new int[3];
            for (int i = 0; i < 3; i++)
            {
                width_left[i] = Convert.ToInt32(g.TextWidth(text_left[i])) + 5;
                height_left[i] = Convert.ToInt32(g.TextHeight(text_left[i])) + 2;
            }

            int x_left = 5;
            int[] y_left = new int[3];
            y_left[0] = tChart1.Axes.Left.IStartPos + width_left[0];
            y_left[1] = (tChart1.Axes.Left.IEndPos - tChart1.Axes.Left.IStartPos) / 2 + width_left[1] * 3 / 2;
            y_left[2] = tChart1.Axes.Left.IEndPos;


            for (int i = 0; i < 3; i++)
            {
                //Bottom
                Size s_bottom = new Size(width_bottom[i], height_bottom[i]);
                Point p_bottom = new Point(x_bottom[i], y_bottom);
                Rectangle r_bottom = new Rectangle(p_bottom, s_bottom);

                g.Pen.Color = Color.Blue;
                g.Brush.Color = Color.Blue;
                g.Brush.Transparency = 50;
                g.Rectangle(r_bottom);
                g.TextOut(x_bottom[i], y_bottom, text_bottom[i]);

                //Left
                Size s_left = new Size(height_left[i], width_left[i]);
                Point p_left = new Point(x_left, y_left[i] - width_left[i]);
                Rectangle r_left = new Rectangle(p_left, s_left);

                g.Pen.Color = Color.Blue;
                g.Brush.Color = Color.Blue;
                g.Brush.Transparency = 50;
                g.Rectangle(r_left);
                g.RotateLabel(x_left, y_left[i], text_left[i], 90);
            }

                
        }
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Post Reply