Series intersect

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Series intersect

Post by dave » Fri May 04, 2007 1:31 am

Hi,

I'm just wondering if there are any functions or methods to display text or marks on the point(s) where two different series intersect each other?

Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri May 04, 2007 7:36 am

Hi dave,

You can use CrossPoints function and make its marks visible. You'll find an example of this at All Features\Welcome !\Functions\Extended\Cross points in the features demo. The demo can be found at TeeChart's program group.
Best Regards,
Narcís Calvet / 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

dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Post by dave » Mon May 07, 2007 7:40 am

Thanks Narcis, I managed to get the CrossPoint working with a Styles.Point, however, I noticed that when I do a mouseover with MarkTips, it only shows the Y values. I would like the MarksTip to show the label on one of the series data (that intersects with another series). Is there a way how I can do this?

Also, could I change Styles.Point to show an x rather than a grey box?

Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon May 07, 2007 10:34 am

Hi dave,
Thanks Narcis, I managed to get the CrossPoint working with a Styles.Point, however, I noticed that when I do a mouseover with MarkTips, it only shows the Y values. I would like the MarksTip to show the label on one of the series data (that intersects with another series). Is there a way how I can do this?
Yes, try this:

Code: Select all

					marksTip1.Style = Steema.TeeChart.Styles.MarksStyles.Label;
Also, could I change Styles.Point to show an x rather than a grey box?
Something similar, try this:

Code: Select all

					points1.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.DiagCross;
Best Regards,
Narcís Calvet / 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

dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Post by dave » Tue May 08, 2007 12:01 am

Hi Narcis,

Thanks for the info. I'm already using

Code: Select all

 marksTip1.Style = Steema.TeeChart.Styles.MarksStyles.Label;
for my series lines, which works fine. However, when I include CrossPoints, MarksTip only show the Y-Value at points where the 2 series intersect. However, when the series are not intersecting, MarksTip will show the series label.

What I want is for MarksTip to also show the series label at points where the series intersects.

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

Post by Edu » Tue May 08, 2007 8:34 am

Hi Dave

This happens because the CrossPoints don't have labels. You can put the labels as below code:

Code: Select all

        private void Form1_Load(object sender, EventArgs e)
        {
            tChart1.Aspect.View3D = false;
           
            line1.Add(5,"five");
            line1.Add(2, "two");
            line1.Add(6, "six");
            line1.Add(3, "three");
            
            line2.Add(1,"one");
            line2.Add(6, "six");
            line2.Add(3, "three");
            line2.Add(8, "eight");

            //line 3 is using CrossPoints function.
            line3.CheckDataSource();
            line3.Pointer.Visible = true;

            for (int i = 0; i < line3.Count; i++)
            {
                line3.Labels[i] = "intersection point " + Convert.ToString(i + 1);
            }
        }
Best Regards,
Edu

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

dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Post by dave » Wed May 09, 2007 12:40 am

Thanks Edu. Is it possible to set MarksTip to ignore the CrossPoint labels and instead use the label from the intersecting series only?

This is because I find it difficult to construct the label for CrossPoint to what I want (using label from one of the series).

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

Post by Edu » Thu May 10, 2007 9:18 am

Hi Dave

You can change the text of the markTip in the "GetText" event of the markTip, also you can know which line is under the mouse cursor using the MouseMove event and series' Clicked method. You can do something similar as below code:

Code: Select all

      private void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
        {
            if (on_CrossPoints != -1) //The mouse are on the line that use the CrossPoint function
            {
                if (on_lines != -1) //The mouse are on one intersection
                    e.Text = line1[on_lines].Label;
                else //The mouse are on the line that use the CrossPoint but not on the intersection
                    e.Text = "";
            }
        }

        private int on_CrossPoints;
        private int on_lines;
        
        private void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            on_CrossPoints = line3.Clicked(e.X, e.Y);
            on_lines = line1.Clicked(e.X, e.Y);
        }
Best Regards,
Edu

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

dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Post by dave » Fri May 11, 2007 6:47 am

Hi Edu,

Thanks for the sample code. However, I only add the series in the code, so I'm just wondering how I could set on_CrossPoints and on_Lines in the tChart1_MouseMove procedure?

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

Post by Edu » Fri May 11, 2007 9:42 am

Hi Dave

You can accede to series using an index, the first serie that it's been added in the chart, has got value 0, the second value 1, you can see how to use this index in the below line:

Code: Select all

tChart1.Series[0]; //Return the first serie
Also can be interesting know which is the line whose corresponds to crossPoint function. The function has one property which returns the serie associated.

Code: Select all

crossPoints1.Series; //In the below example returns the "line3" 
Your code can be something similar as below code:

Code: Select all

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

        private void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
        {
            if (on_CrossPoints != -1) //The mouse are on the line that use the CrossPoint function
            {
                if (on_lines != -1) //The mouse are on one intersection
                    e.Text = tChart1.Series[0].Labels[on_lines];
                else //The mouse are on the line that use the CrossPoint but not on the intersection
                    e.Text = "";
            }
        }

        private int on_CrossPoints;
        private int on_lines;

        private void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            if (tChart1.Series.Count>0)
            {
                on_CrossPoints = crossPoints1.Series.Clicked(e.X, e.Y);
                on_lines = tChart1.Series[0].Clicked(e.X, e.Y);
            }
        }

        private Steema.TeeChart.Functions.CrossPoints crossPoints1;

        private void button1_Click(object sender, EventArgs e)
        {
            Line line1 = new Line(tChart1.Chart);
            line1.Add(5, "five");
            line1.Add(2, "two");
            line1.Add(6, "six");
            line1.Add(3, "three");

            Line line2 = new Line(tChart1.Chart);
            line2.Add(1, "one");
            line2.Add(6, "six");
            line2.Add(3, "three");
            line2.Add(8, "eight");

            //line 3 is using CrossPoints function.
            Line line3 = new Line(tChart1.Chart);
            crossPoints1 = new Steema.TeeChart.Functions.CrossPoints();  
            line3.DataSource = new object[]  {line1,line2};
            line3.Function = crossPoints1; 
            line3.CheckDataSource();
            line3.Pointer.Visible = true;            
        }
Best Regards,
Edu

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

dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Post by dave » Mon May 14, 2007 12:34 am

Thanks Edu, I managed to get it to work. Cheers!

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Post by pw » Tue Sep 18, 2007 6:30 am

Hi,

I'm having some intermittent Index Out Of Bound errors with my code. It's similar to the code given previously.

Code: Select all

        private void button1_Click(object sender, EventArgs e) 
        { 
            Line line1 = new Line(tChart1.Chart); 
            line1.Add(5, "five"); 
            line1.Add(2, "two"); 
            line1.Add(6, "six"); 
            line1.Add(3, "three"); 

            Line line2 = new Line(tChart1.Chart); 
            line2.Add(1, "one"); 
            line2.Add(6, "six"); 
            line2.Add(3, "three"); 
            line2.Add(8, "eight"); 

            //line 3 is using CrossPoints function. 
            Line line3 = new Line(tChart1.Chart); 
            crossPoints1 = new Steema.TeeChart.Functions.CrossPoints();  
            line3.DataSource = new object[]  {line1,line2}; 
            line3.Function = crossPoints1;  //Index out of bound error showing here
            line3.CheckDataSource(); 
            line3.Pointer.Visible = true;            
        }
I find it difficult to replicate the problem as it's intermittent. Do you have any suggestions on what could cause the index error to appear at that line of code?

Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Sep 18, 2007 7:52 am

Hi pw,

Not that I can think of without being able to reproduce the problem here. Maybe you could try setting the series Function before setting its DataSource. Also, which TeeChart version are you using? Are you using latest version available at the client area?

Thanks in advance!
Best Regards,
Narcís Calvet / 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

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Post by pw » Thu Sep 20, 2007 1:24 am

Hi Narcis,

I'm using .NET V2, haven't downloaded V3 yet,

I'll try to set the series Function first. Thanks for your help.

Cheers!

Post Reply