From XValue to data table index ?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

From XValue to data table index ?

Post by moelski » Wed Feb 06, 2008 10:03 pm

Hi !

I think it is an easy task, but I can´t find a way - maybe it´s to late :roll:

I use the TColorBandTool for marking an area. I got to values back:
Tool.StartValue
Tool.EndValue

These are x values. But how du I get the resulting index of the data table? I need a call like this:

Code: Select all

Chart[0].XValue[Tool.StartValue];
I know that this wont work because XValue needs an index / integer value. How can I get the index for a given value?

Maybe I´m blinded ... :roll:

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

Post by Narcís » Thu Feb 07, 2008 9:29 am

Hi Dominik,

Yes, maybe some sleeping would help :wink:.

You can use Locate method as in the code snippet I posted here.
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

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Thu Feb 07, 2008 9:43 am

hi Narcis,

Ok that works ...
Chart[0].XValues.Locate(Tool.StartValue)

but one little problem left:

If you change the left position of the TColorBandTool then Tool.StartValue can contain values like 20,31252134 which is not a valid X value. The result is -1 ...

Is it possible to have a snapping for the TColorBandTool or the possibility that Locate uses the nearest value within the XValues?

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

Post by Narcís » Thu Feb 07, 2008 9:48 am

Hi Dominik,

Yes, in that case you need to use TNearestTool and its GetNearestPoint method as in the examples I posted here:

http://www.teechart.net/support/viewtop ... arestpoint
http://www.teechart.net/support/viewtop ... arestpoint

An alternative would be using a TCursorTool set to Snap=true, assign the ColorBand X value to it and let the cursor snap to the nearest point.
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