Cross point function. How does it work? Sample?

TeeChart for ActiveX, COM and ASP
Post Reply
Jeff
Newbie
Newbie
Posts: 22
Joined: Fri Nov 15, 2002 12:00 am
Location: Virginia, United States

Cross point function. How does it work? Sample?

Post by Jeff » Mon Mar 13, 2006 3:02 pm

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!

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 Mar 13, 2006 3:10 pm

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
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

Jeff
Newbie
Newbie
Posts: 22
Joined: Fri Nov 15, 2002 12:00 am
Location: Virginia, United States

Post by Jeff » Mon Mar 13, 2006 3:55 pm

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

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 Mar 13, 2006 4:07 pm

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?
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

Jeff
Newbie
Newbie
Posts: 22
Joined: Fri Nov 15, 2002 12:00 am
Location: Virginia, United States

Post by Jeff » Mon Mar 13, 2006 4:12 pm

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!

Jeff
Newbie
Newbie
Posts: 22
Joined: Fri Nov 15, 2002 12:00 am
Location: Virginia, United States

Post by Jeff » Mon Mar 13, 2006 9:34 pm

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.

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 Mar 14, 2006 10:02 am

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.
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

Jeff
Newbie
Newbie
Posts: 22
Joined: Fri Nov 15, 2002 12:00 am
Location: Virginia, United States

Post by Jeff » Tue Mar 14, 2006 3:54 pm

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.

Jeff
Newbie
Newbie
Posts: 22
Joined: Fri Nov 15, 2002 12:00 am
Location: Virginia, United States

Post by Jeff » Tue Mar 14, 2006 9:29 pm

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!

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

Post by Narcís » Wed Mar 15, 2006 10:15 am

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.
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

Post Reply