Page 1 of 1
Series intersect
Posted: Fri May 04, 2007 1:31 am
by 9640436
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.
Posted: Fri May 04, 2007 7:36 am
by narcis
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.
Posted: Mon May 07, 2007 7:40 am
by 9640436
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.
Posted: Mon May 07, 2007 10:34 am
by narcis
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;
Posted: Tue May 08, 2007 12:01 am
by 9640436
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.
Posted: Tue May 08, 2007 8:34 am
by 9348258
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);
}
}
Posted: Wed May 09, 2007 12:40 am
by 9640436
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).
Posted: Thu May 10, 2007 9:18 am
by 9348258
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);
}
Posted: Fri May 11, 2007 6:47 am
by 9640436
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?
Posted: Fri May 11, 2007 9:42 am
by 9348258
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;
}
Posted: Mon May 14, 2007 12:34 am
by 9640436
Thanks Edu, I managed to get it to work. Cheers!
Posted: Tue Sep 18, 2007 6:30 am
by 6923298
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.
Posted: Tue Sep 18, 2007 7:52 am
by narcis
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!
Posted: Thu Sep 20, 2007 1:24 am
by 6923298
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!