how to do display x-Axis Label

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
grace
Newbie
Newbie
Posts: 10
Joined: Thu Feb 15, 2007 12:00 am

how to do display x-Axis Label

Post by grace » Thu Jun 07, 2007 6:16 am

how to do display x-Axis Label like 0 1 2 3 0 1 2 3 0 1 2 3
one axes not multi axis

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

Post by Edu » Thu Jun 07, 2007 7:55 am

Hi Grace

You can use the "GetAxisLabel" event of the chart to change x-Axis label, your code can be something similar as below code:

Code: Select all

 private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
        {
            if (sender == tChart1.Axes.Bottom) //Only x-Axis
                e.LabelText = (Convert.ToInt16(e.LabelText) % 4).ToString();            
        }
Best Regards,
Edu

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

grace
Newbie
Newbie
Posts: 10
Joined: Thu Feb 15, 2007 12:00 am

Post by grace » Thu Jun 07, 2007 9:11 am

please look this code

Code: Select all

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            TestLine();
        }

        public void TestLine()
        {


            Line line1 = new Line();
            Line line2 = new Line();
            line1.Add(1.5, 1.7);
            line1.Add(2.4, 2.9);
            line1.Add(3.6, 4.9);
            line1.Add(4.9, 5.6);
            line2.Add(5.7, 2.6);
            line2.Add(6.3, 3.5);
            line2.Add(7.9, 4.2);
            line2.Add(9.7, 4.3);
            this.tChart1.Chart.Series.Add(line1);
            this.tChart1.Chart.Series.Add(line2);
            line1.Pointer.Style = PointerStyles.Circle;
            line1.Pointer.Visible = true;

            line2.Pointer.Style = PointerStyles.Circle;
            line2.Pointer.Visible = true;


        }

        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Mark;
        }

        private void tChart1_GetAxisLabel(object sender, GetAxisLabelEventArgs e)
        {
            if (((Steema.TeeChart.Axis)sender).Equals(tChart1.Axes.Bottom)) e.LabelText = "Period " + Convert.ToString(e.ValueIndex);

        }
    }

grace
Newbie
Newbie
Posts: 10
Joined: Thu Feb 15, 2007 12:00 am

Post by grace » Thu Jun 07, 2007 9:14 am

9348258 wrote:Hi Grace

You can use the "GetAxisLabel" event of the chart to change x-Axis label, your code can be something similar as below code:

Code: Select all

 private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
        {
            if (sender == tChart1.Axes.Bottom) //Only x-Axis
                e.LabelText = (Convert.ToInt16(e.LabelText) % 4).ToString();            
        }
create two line , but only display one line x-Axis Label,
line2 x-Axis Label is gone

grace
Newbie
Newbie
Posts: 10
Joined: Thu Feb 15, 2007 12:00 am

Post by grace » Thu Jun 07, 2007 9:20 am

Image

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

Post by Edu » Thu Jun 07, 2007 9:58 am

Hi Grace

The parameter e.ValueIndex of the "GetAxisLabel" event returns -1 if the serie hasn't a label. So if you want to use this parameter you should put label as below code:

Code: Select all

line1.Add(1.5, 1.7, "1.5");
If you want that also the second line Axis label is displayed, you have two possibilities, the first is put also in the first line the same points to the second line as below code:

Code: Select all

line1.Add(5.7, 0, Color.Transparent);
            line1.Add(6.3, 0, Color.Transparent);
            line1.Add(7.9, 0, Color.Transparent);
            line1.Add(9.7, 0, Color.Transparent);

            line2.Add(5.7, 2.6,"5.7");
            line2.Add(6.3, 3.5, "6.3");
            line2.Add(7.9, 4.2, "7.9");
            line2.Add(9.7, 4.3, "9.7");
The other one is to use a custom labels, you can put this as below line:

Code: Select all

tChart1.Axes.Bottom.Labels.Items.Add(1.5, "1.5");

You can see more about custom labels in the "What's New?\Welcome !\Axes\Labels\Custom labels" example at the features demo. You'll find the demo at TeeChart's program group.
Best Regards,
Edu

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

grace
Newbie
Newbie
Posts: 10
Joined: Thu Feb 15, 2007 12:00 am

Post by grace » Tue Jun 12, 2007 7:34 am

but use this method:
The other one is to use a custom labels, you can put this as below line:

Code:
tChart1.Axes.Bottom.Labels.Items.Add(1.5, "1.5");

it is a problem that the items won't show friendly when there are so much points i added.and also it must can be zoom in or out.so if zoom out ,the items can't see what they are.how to do about it.can it change when the axie change?

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

Post by Edu » Tue Jun 12, 2007 9:01 am

Hi Grace

I think that it's better to put the labels directly, without event and without custom labels. The bottom axis paints the labels of the first serie. So, you should put all the labels in the first serie, in this case you shouldn't have problems with zoom and scroll. You can do something similar as below code:

Code: Select all

public void TestLine()
        {
            Line line1 = new Line();
            Line line2 = new Line();

            line1.Add(1.5, 1.7, GetPointLabel(line1));
            line1.Add(2.4, 2.9, GetPointLabel(line1));
            line1.Add(3.6, 4.9, GetPointLabel(line1));
            line1.Add(4.9, 5.6, GetPointLabel(line1));

            //The below lines puts the labels of second serie in a (nulls/transparents) points, of the first serie
            line2.Add(5.7, 2.6);       line1.Add(5.7, 0, GetPointLabel(line1), Color.Transparent);
            line2.Add(6.3, 3.5);       line1.Add(6.3, 0, GetPointLabel(line1), Color.Transparent);
            line2.Add(7.9, 4.2);       line1.Add(7.9, 0, GetPointLabel(line1), Color.Transparent);
            line2.Add(9.7, 4.3);       line1.Add(9.7, 0, GetPointLabel(line1), Color.Transparent);

            this.tChart1.Chart.Series.Add(line1);
            this.tChart1.Chart.Series.Add(line2);
            line1.Pointer.Style = PointerStyles.Circle;
            line1.Pointer.Visible = true;
            line2.Pointer.Style = PointerStyles.Circle;
            line2.Pointer.Visible = true;
        }

        private static string GetPointLabel(Line line1)
        {
            return "Period" + line1.Count.ToString();
        }
Best Regards,
Edu

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

grace
Newbie
Newbie
Posts: 10
Joined: Thu Feb 15, 2007 12:00 am

Post by grace » Wed Jun 13, 2007 12:25 am

thank you for your reply.but it still a problem that the line1 show in the chart will not the true line.because we add more points in it.we want the line shown like these :~~~ but it will be changed to these:~\~~.how to do let the more add part in line1 unvisible.

grace
Newbie
Newbie
Posts: 10
Joined: Thu Feb 15, 2007 12:00 am

Post by grace » Wed Jun 13, 2007 12:36 am

oh ..sorry,it's ok now .thank you

Post Reply