Page 1 of 1

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

Posted: Mon Mar 28, 2005 1:16 pm
by 9523802
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

Posted: Tue Mar 29, 2005 9:12 am
by narcis
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();
		}

Posted: Tue Mar 29, 2005 11:14 am
by 9523802
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

Posted: Tue Mar 29, 2005 11:38 am
by narcis
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.

Posted: Tue Mar 29, 2005 11:52 am
by 9523802
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