Hi!
I'm trying to get the X and Y coordinates of a mouse click in such a way that the coordinates are based on the X and Y values of an axis. I would think that in part, the axis used would have to be specified as in the case of the Y axis where there could be several axes.
Can someone guide me how to do this in VB.Net or C#?
Thanks
Mouse XY at click question
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Mouse XY at click question
Hi tirby,
Yes, you can do something like this:
Hope this helps!
Yes, you can do something like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(new Steema.TeeChart.Styles.Line()).FillSampleValues();
tChart1.Series.Add(new Steema.TeeChart.Styles.Line()).FillSampleValues();
tChart1.Axes.Left.EndPosition = 50;
Steema.TeeChart.Axis axis1 = new Steema.TeeChart.Axis();
axis1.StartPosition = 50;
tChart1.Axes.Custom.Add(axis1);
tChart1[1].CustomVertAxis = axis1;
tChart1.MouseClick += new MouseEventHandler(tChart1_MouseClick);
}
void tChart1_MouseClick(object sender, MouseEventArgs e)
{
Steema.TeeChart.Axis axis = new Steema.TeeChart.Axis();
for (int i = 0; i < tChart1.Axes.Count; i++)
{
axis = tChart1.Axes[i];
if (!axis.Horizontal)
{
if (axis.Clicked(axis.Position,e.Y))
{
break;
}
}
}
double x = tChart1.Axes.Bottom.CalcPosPoint(e.X);
double y = axis.CalcPosPoint(e.Y);
tChart1.Header.Text = x.ToString("#.##") + " - " + 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 |
Instructions - How to post in this forum |
Re: Mouse XY at click question
Thanks Narcis!
I think this will work!
I think this will work!