Page 1 of 1

Cross point function. How does it work? Sample?

Posted: Mon Mar 13, 2006 3:02 pm
by 9079179
Hello,

I have been trying to get the cross point function to work with two existing series. I followed the instructions in the help, but it does not work. I added the cross point as "marks" so I was expecting to see marks when the lines crossed. Is there a simple example of using the cross point function?

In hopes of carrying this a little further...is there a way to apply the cross point function of a series and a "cross line" tool?

Thanks!

Posted: Mon Mar 13, 2006 3:10 pm
by narcis
Hi Jeff,

Depending on how are you populating the source series you may need to use CheckDataSource method as done here:

Code: Select all

Private Sub Form_Load()
    TChart1.AddSeries scLine
    TChart1.AddSeries scLine
    
    TChart1.AddSeries scLine
    TChart1.Series(2).SetFunction tfCrossPoints
    TChart1.Series(2).DataSource = "Series0,Series1"
    
    TChart1.Series(0).FillSampleValues 10
    TChart1.Series(1).FillSampleValues 10
    
    TChart1.Series(2).CheckDataSource
End Sub

Posted: Mon Mar 13, 2006 3:55 pm
by 9079179
Thanks. This seems to work, but I need a little more if possible. I want to have the intersections of the points be displayed in chart marks. You know the little yellow rectangles. Right now I have the values displayed in a label. Also...(the biggy)....Does this only work with series or can I create a cross line tool from the tools tab and use that as a datasource?

Thanks!

Private Sub Form_Load()
TChart1.AddSeries scLine
TChart1.AddSeries scLine

TChart1.AddSeries scLine
TChart1.Series(2).SetFunction tfCrossPoints
TChart1.Series(2).DataSource = "Series0,Series1"

TChart1.Series(0).FillSampleValues 10
TChart1.Series(1).FillSampleValues 10

TChart1.Series(2).CheckDataSource

Label1.Caption = TChart1.Series(2).XValues.Value(0) & ", " & TChart1.Series(2).YValues.Value(0)


End Sub

Posted: Mon Mar 13, 2006 4:07 pm
by narcis
Hi Jeff,
I want to have the intersections of the points be displayed in chart marks. You know the little yellow rectangles. Right now I have the values displayed in a label
Yes, this is possible, you just need to make the function series visible:

Code: Select all

Private Sub Form_Load()
    TChart1.AddSeries scLine
    TChart1.AddSeries scLine
    
    TChart1.AddSeries scLine
    TChart1.Series(2).SetFunction tfCrossPoints
    TChart1.Series(2).DataSource = "Series0,Series1"
    
    TChart1.Series(0).FillSampleValues 10
    TChart1.Series(1).FillSampleValues 10
    
    TChart1.Series(2).CheckDataSource
    
    TChart1.Series(2).Marks.Visible = Tr1ue
End Sub
Also...(the biggy)....Does this only work with series or can I create a cross line tool from the tools tab and use that as a datasource?
Sorry but I'm afraid I don't understand what are you meanning. TeeChart doesn't have cross line tool. Could you please be more specific about that?

Posted: Mon Mar 13, 2006 4:12 pm
by 9079179
Thanks.

In the Chart Tools Gallery there is a Color Line tool. Right click on the chart, choose edit, choose the Tools tab, click on Add, click on Axis tab. There is the Color Line tool.

Also...the mark works, but how do I get it to display the X and Y value of the point? Sorry...this is extremely new to me.

Thanks!

Posted: Mon Mar 13, 2006 9:34 pm
by 9079179
TChart1.Series(2).SetFunction tfCrossPoints
TChart1.Series(2).DataSource = "Series0,Series1"
TChart1.Series(2).CheckDataSource
TChart1.Series(2).Marks.Visible = True


The above cause a crash when the lines cross. Any ideas why? It appears to be the .CheckDataSource line that bombs.

Posted: Tue Mar 14, 2006 10:02 am
by narcis
Hi Jeff,
In the Chart Tools Gallery there is a Color Line tool. Right click on the chart, choose edit, choose the Tools tab, click on Add, click on Axis tab. There is the Color Line tool.

Also...the mark works, but how do I get it to display the X and Y value of the point? Sorry...this is extremely new to me.
Ok, If you want to know which points of a ColorLine tool intersect with a line series you'd better create a fake series (instead of the ColorLinetool) which has a Y constant value for all points and use it as a datasource for the function. For example, if you want a line at 700 Y value you can do something like the code below and make the constant line series visible or not.

Code: Select all

Private Sub Form_Load()
    TeeCommander1.Chart = TChart1
    
    TChart1.AddSeries scLine
    TChart1.AddSeries scLine
    
    TChart1.AddSeries scLine
    TChart1.Series(2).SetFunction tfCrossPoints
    TChart1.Series(2).DataSource = "Series0,Series1"
    
    TChart1.Series(0).FillSampleValues 10
    
    TChart1.Series(1).AddXY 0, 700, "", clNone
    TChart1.Series(1).AddXY TChart1.Series(0).Count - 1, 700, "", clNone
    TChart1.Series(1).Active = False
    
    TChart1.Series(2).CheckDataSource
    
    TChart1.Series(2).Marks.Visible = True
End Sub
The above cause a crash when the lines cross. Any ideas why? It appears to be the .CheckDataSource line that bombs.
It works fine for me here using latest TeeChart Pro v7 ActiveX version available. Which version are you using? If the problem persists, could you please send us an example we can run "as-is" to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Posted: Tue Mar 14, 2006 3:54 pm
by 9079179
My problem appears to have been that I was building the series in a sub and callling that sub multiple times. I needed to clear the series for my vertical line before I drew the new series.

Posted: Tue Mar 14, 2006 9:29 pm
by 9079179
The code you gave me appears to work..BUT...I have two charts on the same form in VB6. I am using TeeChart 6. My problem now is that while the value displays in the "Mark" for one chart. It does not display in my other chart. The code is the same. Do you have any ideas why the code would display marks appropriately in one chart on the same form and not another on the same form?

Just an added note here...

I got this to work by changing this line:

.DataSource = "Series0,Series4" ...to.... .DataSource = "Series0,Series3"

Now...my series should be series 4...so why does it work as series 3?

Thanks!

Posted: Wed Mar 15, 2006 10:15 am
by narcis
Hi Jeff,

Sorry but I don't understand your exact problem. Could you please send us an example we can run "as-is" to reproduce the problem here? You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Thanks in advance.