Relating series position to bottom axes position

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
rossmc
Newbie
Newbie
Posts: 57
Joined: Wed Apr 08, 2009 12:00 am

Relating series position to bottom axes position

Post by rossmc » Mon Nov 30, 2009 9:43 am

Hi

I need to know if there is a way to relate a point in a series values collection (for example position 1 in the series.yvalues) to it's relative position along the bottom axes? Series (in my usage anyway) do not always start plotting from the first point on the chart. For example the first bottom axes point may be 1 Jan 2009 but one of the series only starts plotting from 1 Feb 2009. So I need to know that yvalue item 1 in the series is plotted at the 21st tick along the bottom axes.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Relating series position to bottom axes position

Post by Sandra » Mon Nov 30, 2009 12:55 pm

Hello rossmc,
I need to know if there is a way to relate a point in a series values collection (for example position 1 in the series.yvalues) to it's relative position along the bottom axes?
I recommend use line2.CalcXPos (index), line2.CalcYPos (index) or similar methods that calculate for determined index his position in the screen. If it doesn't solve your problem or is not what you want, please explain exactly what would you do, because we can try to find a solution.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

rossmc
Newbie
Newbie
Posts: 57
Joined: Wed Apr 08, 2009 12:00 am

Re: Relating series position to bottom axes position

Post by rossmc » Mon Nov 30, 2009 2:11 pm

Those methods appear to return screen co-ordinates which won't help unless I can then convert the screen co-ordinate into a bottom axes value?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Relating series position to bottom axes position

Post by Yeray » Mon Nov 30, 2009 3:11 pm

Hi rossmc,

I'm not sure to understand what are you exactly trying to do either. If you want to get the first Y value of a series you can do series.YValue[0], if you want to get the Y coordinate in pixels that corresponds to that Y value, you can do as Sandra told you Series.CalcYPos(0). And the same applies for the X values, if you know the index of the value you want to get, series.XValue[index].

Also note that you can use the axes CalcPosValue and CalcPosPoint methods to calculate the pixel position for a given value or vice versa.

If you still find problems with it, please, try to explain what is your exact situation and/or send us a simple example project we can run as-is to reproduce the problem here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

rossmc
Newbie
Newbie
Posts: 57
Joined: Wed Apr 08, 2009 12:00 am

Re: Relating series position to bottom axes position

Post by rossmc » Tue Dec 01, 2009 6:23 am

I'll have another go at trying to explain this:

Let's assume I have 260 price points to plot. The bottom axes then represents one year from 1 Jan to 31 Dec. (Saturdays and Sundays excluded).

I then want to overlay a second price stream on the same chart using the same axes.

This second price stream only has prices from the beginning of Feb. This means the second price stream will not start at the beginning of the bottom axes, but only after a gap that is twenty points along the bottom axes.

Now I calculate a third, new line based on the second lines valuelist. This third line needs to start plotting at the same starting position in time, along the bottom axes, as the second line.

Now, without writing a bunch of code around this, I wanted to know if there is a method in the chart control that can tell me that the second line only starts plotting at the twentieth point along the bottom axes? (In other words, series.yvalue(0) is above bottom axes point 20)?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Relating series position to bottom axes position

Post by Yeray » Wed Dec 02, 2009 12:27 pm

Hi rossmc,

If I understood you well this example is doing what you want. Note that you can create your second series' first X Value taking your first series' 20th value or creating the DateTime directly if you know the exact day.

Code: Select all

        private void InitializeChart()
        {
            chartController1.Chart = tChart1;

            tChart1.Aspect.View3D = false;

            Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);

            points1.XValues.DateTime = true;

            DateTime tmpdate = new DateTime(2009,01,01);
            Random rnd = new Random();
            points1.Add(tmpdate, rnd.Next(100));
            tmpdate = tmpdate.AddDays(1);            
            while (tmpdate < new DateTime(2010,01,01))
            {
                if ((tmpdate.DayOfWeek != DayOfWeek.Saturday) && (tmpdate.DayOfWeek != DayOfWeek.Sunday))
                    points1.Add(tmpdate,points1.YValues[points1.Count-1] + rnd.Next(10) - 5);
                tmpdate = tmpdate.AddDays(1);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Steema.TeeChart.Styles.Points points2 = new Steema.TeeChart.Styles.Points(tChart1.Chart);

            points2.XValues.DateTime = true;

            //DateTime tmpdate = new DateTime(2009, 02, 01);
            DateTime tmpdate = tChart1[0].XValues.AsDateTime(20);
            Random rnd = new Random();
            points2.Add(tmpdate, rnd.Next(100));
            tmpdate = tmpdate.AddDays(1);
            while (tmpdate < new DateTime(2010, 01, 01))
            {
                if ((tmpdate.DayOfWeek != DayOfWeek.Saturday) && (tmpdate.DayOfWeek != DayOfWeek.Sunday))
                    points2.Add(tmpdate, points2.YValues[points2.Count - 1] + rnd.Next(10) - 5);
                tmpdate = tmpdate.AddDays(1);
            }
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply