How to get the coords where I clicked on the TChart?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Alex
Newbie
Newbie
Posts: 38
Joined: Tue Aug 31, 2004 4:00 am
Location: Austria/Europe

How to get the coords where I clicked on the TChart?

Post by Alex » Mon Mar 28, 2005 1:16 pm

Hi All!

Maybe a simple question, but I found no solution: If I click on the Chart how can I ask for the coordinates where I clicked to (based on the TChart axis)? I want to catch coordinates directly from the chart, the user should simply click on the chart... (independent of series)

Thanks in advance!

Best regards

Alex

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 29, 2005 9:12 am

Hi Alex,

Yes, you can use something like:

Code: Select all

		private void tChart1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			tChart1.Header.Text=e.X.ToString()+", "+e.Y.ToString();
		}
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

Alex
Newbie
Newbie
Posts: 38
Joined: Tue Aug 31, 2004 4:00 am
Location: Austria/Europe

Post by Alex » Tue Mar 29, 2005 11:14 am

Hi Narcis,

thanks for the hint. This returns the absolute values in pixel on the TChart. Using this, and the .axes.IStartPos / .IEndPos, I can scale the pixels to relative chart coordinates.
By the way: is there a way to directly get the coordinates related to the Chart-axis without this additional subroutine? (e.g. using the cursor tool)

Thanks!

Alex

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 29, 2005 11:38 am

Hi Alex,

Yes, you are right. You can use Cursor Tool for this, just have a look at the TeeChart features demo included with the installation, in the TeeChart program group an search for the cursor tool examples.
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

Alex
Newbie
Newbie
Posts: 38
Joined: Tue Aug 31, 2004 4:00 am
Location: Austria/Europe

Post by Alex » Tue Mar 29, 2005 11:52 am

Hi Narcis,

I've found the internal Chart-method to convert the e.x and e.y of the mouse-down-event:

Code: Select all

        posx = TChart1.Axes.Bottom.CalcPosPoint(e.X)
        posy = TChart1.Axes.Left.CalcPosPoint(e.Y)
The help isn't really correct, but it works (same description as CalcPosValue, difference only in the function syntax).

Thanks!

Alex

Post Reply